Losing messages

Windows® Compatible Software for Displaying CAN Messages
Post Reply
antred
Posts: 4
Joined: Thu 3. Sep 2015, 13:50

Losing messages

Post by antred » Thu 3. Sep 2015, 14:13

Hi,

First off, my problem isn't purely a PCAN-View issue, so I apologize in advance if this isn't the correct sub forum. Anyway, I'm using the Peak PCAN-USB adapter (firmware version: 2.8, driver versiom: 3.8.2) and PCAN-View version 4.0.28.419 on Windows 7.

I have a C++ application that uses Keneth Wagner's PCAN-Basic API to read messages from the bus. Basically, the C++ app runs in an infinite loop and uses the following code to keep pulling incoming messages from the bus:

Code: Select all

TPCANMsg msg = {};
TPCANTimestamp ts = {};

// m_CAN_handle is a pointer to an instance of Keneth Wagner's PCANBasicClass.
const TPCANStatus ret = m_CAN_handle->Read( getHandleValue( QString::fromStdString( m_openHandle ) ), &msg, &ts );

if ( ret == PCAN_ERROR_OK )
{
	// copy driver specific type to msg data
	dataIn.id = msg.ID;
	dataIn.flags = msg.MSGTYPE;
	dataIn.len = msg.LEN;

	for ( std::size_t i = 0; i < CANDRIVER_MAX_DATA; ++i )
	{
		dataIn.data[ i ] = msg.DATA[ i ];
	}

	timestamp.ms = ts.millis;
	timestamp.us = ts.micros;

	return cOK;
}
else
{
    // print error message ...
}
Any successfully received message is printed to a log file, byte for byte. So far, so good. Now things are getting a little weird. I'm also running PCAN-View alongside my C++ app, to trace any messages going across the bus, and I've noticed that the trace lists tons of messages that aren't showing up in my log.
In other words, there are messages that my C++ code should have received but for some reason did not. The PCAN-View trace proves that these messages went through the PCAN-USB adapter, but for whatever reason I'm not able to read those messages. I'm not getting an error code either. It's as though these messages are somehow lost. And it's not all messages either. Most of the messages shown in the PCAN-View trace show up in my own log as well, but some don't. Now you may think that I'm seeing those messages in the PCAN-View trace but not in my own receive-log because maybe my C++ program is _sending_ instead of receiving them, but this cannot be the case because my C++ program NEVER sends any messages of that particular type.

Now comes the weirdest part of all. Occassionally, like maybe in 1 out of 10 runs or so, some of those "missing" messages are actually picked up by my program! :?

I've been trying to get to the root of this issue for the last 8 hours and I'm at my wit's end here. Does anyone have any ideas what it is that I might be doing wrong here?

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Losing messages

Post by PEAK-Support » Thu 3. Sep 2015, 15:42

Please first check following Driver Setups:
- Update to the latest PEAK-System Driver (at the moment Sep.2015, it´s 4.0.16)
- Check if your USB Port is a USB 3.0 Port - if yes - see herewhat to do next.

If you still have problems, we need the complete code - only parts of it does not help - for example you never check the Msg.Type. You also could simply switch on the internal Data Logger of the PCAN-Basic API (SetParam PCAN_TRACE_STATUS etc.) and you have a 100% copy of the real CAN Frames that your Application driverqueue receive. Compare it with your Log file it must be the same - if not something is wrong in your code.
You could send your code to support@peak-system.com - we could check it.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

antred
Posts: 4
Joined: Thu 3. Sep 2015, 13:50

Re: Losing messages

Post by antred » Thu 3. Sep 2015, 16:08

Thanks for your response! I've updated the drivers, and suddenly the previously missing messages are getting through! :o I'm hoping that it stays that way and that it's not just some weird timing issue that I've somehow covered up by rebooting the system or something silly like that.

About the code, that's a bit problematic. It's part of a pretty large code base, and I can't easily give the code away (company guidelines). For now the problem seems to have disappeared, but if it returns I might try to make a minimal working example program and send you the code.

I have USB 2.0, by the way.

antred
Posts: 4
Joined: Thu 3. Sep 2015, 13:50

Re: Losing messages

Post by antred » Mon 13. Feb 2017, 14:35

Well, more than a year later I can report that the problem never did return. I have no idea what exactly did cause the issue, but whatever it was, the driver update seems to have helped. :)

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Losing messages

Post by PEAK-Support » Mon 13. Feb 2017, 14:46

Thank you for the feedback!
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply