PCAN-OBDII API calls returning error.

A free API for vehicle diagnostics according to OBD-2 (ISO 15765-4)
Post Reply
ajitnatu
Posts: 2
Joined: Fri 18. Mar 2016, 07:55

PCAN-OBDII API calls returning error.

Post by ajitnatu » Fri 18. Mar 2016, 08:51

Hello,

I am using PCAN-OBDII library API and running the OBDII C++ sample project on laptop.
All the required libraries/dlls like PCAN-UDS, PCAN-ISOTP and PCAN-Basic are present.
Also since, I do not get run-time errors of missing DLLs, I am assuming that the required
DLLs are found at run-time. PCAN USB hardware is connected to the laptop.

Please refer the following sample code snippet:

Code: Select all

	// Set the PCAN-Channel to use (PCAN-USB Channel 1)
	Channel = POBDII_USBBUS1;

	// Define logging (of creation and destruction, and for newly created connections)
	BYTE debug = POBDII_LOGGING_TO_STDOUT;
	OBDII_SetValue(POBDII_USBBUS1, POBDII_PARAM_LOGGING, &debug, 1);
	printf("Channel: 0x%02x, CAN BUS Status: 0x%02x\n\n", Channel, OBDII_GetStatus(Channel));
	
	status = OBDII_Initialize(Channel, POBDII_BAUDRATE_500K, 0, 0, 0);
OBDII_GetStatus(Channel) returns 0x01 i.e POBDII_ERROR_NOT_INITIALIZED.
Subsequent OBDII_Initialize() returns 0x15 i.e POBDII_ERROR_UNSUPPORTED_ECUS.

With the same hardware, if I run the UDS sample project, UDS_Initialize(Channel, PUDS_BAUD_500K, 0, 0, 0);
returns successfully. I have successfully tested all the UDS requests with my ECU.

I have been working on this for a few hours now and haven't been able to figure out what
could cause the OBDII calls to fail. Am I missing something ? Would appreciate suggestions on this.

Many thanks,
Ajit (India)
Last edited by K.Wagner on Fri 18. Mar 2016, 09:03, edited 1 time in total.
Reason: Added [code] tag for better readability

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: PCAN-OBDII API calls returning error.

Post by K.Wagner » Fri 18. Mar 2016, 09:26

Hello,

please note that OBD-II requires the detection of ECUS by analysing responses to some stimulation messages sent by the API. If this fails, then you will receive the error "POBDII_ERROR_UNSUPPORTED_ECUS".

Note too that the API was written following the defined OBDII norms, strictly. This error could be an indicator that the ECU is possibly missing to response something, or the API is missing to understand any response from the ECU. You could try to connect the PCAN-View software to the same USB adapter, before starting your application, and trace the data being communicated. In this way you could check in which point the communication is failing.

By the way, we do have an OBDII-Tool software, for free, that could use for testing too. You find this in our web page, in the Product-DVD, folder "PreRelease\PCAN-OBD-II-Viewer-BETA". This tool was written using the PCAN-OBDII API. Try to detect your ECU with this tool.
Best regards,
Keneth

ajitnatu
Posts: 2
Joined: Fri 18. Mar 2016, 07:55

Re: PCAN-OBDII API calls returning error.

Post by ajitnatu » Fri 18. Mar 2016, 09:51

Hello Kenneth,

Thanks for the reply.

However, the function, OBDII_GetStatus(Channel), which is called after OBDII_SetValue(...)
but before OBDII_Initialize(...) returns Status = 0x01 i.e POBDII_ERROR_NOT_INITIALIZED.

According to PCAN OBDII documentation:
POBDII_ERROR_NOT_INITIALIZED: Indicates that the given POBDII channel cannot be used because it was
not found in the list of reserved channels of the calling application.

Hence, I suspect that there is an issue related to detection/initialization of the PCAN dongle even before
any data is sent on CAN. What do you think ?
I had captured the trace in PCAN View, but there was no data. I will now also try using the PCAN-OBDII tool.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: PCAN-OBDII API calls returning error.

Post by K.Wagner » Fri 18. Mar 2016, 10:30

ajitnatu wrote:However, the function, OBDII_GetStatus(Channel), which is called after OBDII_SetValue(...)
but before OBDII_Initialize(...) returns Status = 0x01 i.e POBDII_ERROR_NOT_INITIALIZED.
Which error dou you receive as result from OBDII_Initialize? You will always get the POBDII_ERROR_NOT_INITIALIZED error, while the function has not been called sucessfully first.
ajitnatu wrote:POBDII_ERROR_NOT_INITIALIZED: Indicates that the given POBDII channel cannot be used because it was not found in the list of reserved channels of the calling application.
Since the Channel was not initialized correctly (because OBDII_Initialize failed or it was even never called), then the Channel is indeed not in the list of channels that the API has. Maybe the word "reserved" causes here understanding problems. It means, the channels that have been initalized and reserved for be used with your application (note that you can initialize more than one device).
ajitnatu wrote:Hence, I suspect that there is an issue related to detection/initialization of the PCAN dongle even before any data is sent on CAN. What do you think ?
As I wrote, without initialization, there is no data.
ajitnatu wrote:I had captured the trace in PCAN View, but there was no data. I will now also try using the PCAN-OBDII tool.
If the channel never was initialized, you never will see data. Let me know if the OBDII Tool can connect. Note that we have tested this tool on cars from different manufactures (real environment) with success.
Best regards,
Keneth

Post Reply