Page 1 of 1

PCANBasic Trace Problem

Posted: Fri 28. Jul 2023, 05:02
by Ken0711
Hi,

I depended on the PcanBasic C# Sample tracefile to develop my own program and transfer the sample code to my application ,and the trace record success
but the trace file have issue ,depend on mine calculation of message interval ,when interval less than 0.2ms ,it would be recorded twice ,if more than 0.2 ms ,its Ok

so why recoded twice ?

as shown my code and trace file !

Code: Select all

      const bool IsFD = false;
        const bool TraceFileSingle = true;
        const bool TraceFileDate = true;
        const bool TraceFileTime = true;
        const bool TraceFileOverwrite = false;
        const bool TraceFileDataLength = false;
        const uint TraceFileSize = 30;
        const string TracePath = "";
        const int TimerInterval = 1;
        private System.Timers.Timer m_Timer;

  private bool StartTrace()
        {
            uint iStatus = PCANBasic.PCAN_PARAMETER_ON;

            TPCANStatus stsResult = PCANBasic.SetValue(UDSApi.PUDS_USBBUS1, TPCANParameter.PCAN_TRACE_STATUS, ref iStatus, sizeof(int)); // We activate the tracing by setting the parameter.

            if (stsResult != TPCANStatus.PCAN_ERROR_OK)
            {
                ShowStatus(stsResult);
                return false;
            }
            return true;
        }
        private void SetTimer()
        {
            m_Timer = new System.Timers.Timer(TimerInterval);
            m_Timer.Elapsed += OnTimedEvent; // Hook up the Elapsed event for the timer. 
            m_Timer.AutoReset = true;
            m_Timer.Enabled = true;
        }

        private void OnTimedEvent(Object source, ElapsedEventArgs e)
        {
            ReadMessages();
        }
        
        private void ReadMessages()
        {
            // We read at least one time the queue looking for messages. If a message is found, we look again trying to 
            // find more. If the queue is empty or an error occurr, we get out from the dowhile statement.
            TPCANStatus stsResult;
            
            do
            {
                stsResult = IsFD ? PCANBasic.ReadFD(UDSApi.PUDS_USBBUS1, out TPCANMsgFD CANMsgFD) : PCANBasic.Read(UDSApi.PUDS_USBBUS1, out TPCANMsg CANMsg);
                if (stsResult != TPCANStatus.PCAN_ERROR_OK && stsResult != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
                {
                    //ShowStatus(stsResult);
                    return;
                }               

            } while ((!Convert.ToBoolean(stsResult & TPCANStatus.PCAN_ERROR_QRCVEMPTY)));
        } 
Thanks!

Re: PCANBasic Trace Problem

Posted: Fri 28. Jul 2023, 09:12
by K.Wagner
Hello,

You mean, you are using the trace functionality within PCAN-Basic and you are getting double entries in the trace file, when message are being sent faster than 200 microseconds? Howe are you checking it, i.e. how do you know, that the messages are twice? are you counting them in some manner?

Your code shows, that you are using the trace sample project code 1:1. Tests with the sample project for tracing doesn't show any problem in our side. Here is a picture of the results doing a transmission similar to that what you described:
_
Tracing 6 messages with interval 1ms @ 1MB/s (PCAN-USB Pro FD)
Tracing 6 messages with interval 1ms @ 1MB/s (PCAN-USB Pro FD)
Tracing.PNG (100.35 KiB) Viewed 16039 times
_
You can see in the picture that we are sending 6 messages with an interval of 1ms and tracing with the PCAN-Basic functionality, using a connection of 1MB/s. You can see that the same number of sent messages are also received. Note too, that the time difference between the last 6 messages is highlighted and showing, that those messages are being sent faster than 200 microseconds.

If there were double entries, you would just have a difference betweent the amount of sent messages and received messages.

It is recommended, that you attach a PCAN-View to the same channel and also active the trace there. Then you can compare if the information in both trace files is the same.

Re: PCANBasic Trace Problem

Posted: Fri 28. Jul 2023, 09:40
by Ken0711
HI Wagner,

Thaks for your suggestion !

I recoded trace by the CANOE simultaneously ,and CAN record is Normal. As shown below ,i only cut part of message

1.737720 1 784 Rx d 8 02 10 02 55 55 55 55 55
1.738197 1 78C Rx d 8 06 50 02 00 32 01 F4 55
1.841994 1 784 Rx d 8 02 19 0A 55 55 55 55 55
1.843198 1 78C Rx d 8 03 7F 19 11 55 55 55 55
1.948845 1 784 Rx d 8 02 27 09 55 55 55 55 55
1.950209 1 78C Rx d 8 06 67 09 B4 53 C5 42 55
2.057223 1 78C Rx d 8 02 67 0A 55 55 55 55 55
2.165802 1 784 Rx d 8 10 0B 34 00 44 40 08 80
2.166244 1 78C Rx d 8 30 00 00 55 55 55 55 55
2.167316 1 784 Rx d 8 21 00 00 00 40 00 55 55
2.168242 1 78C Rx d 8 04 74 20 04 02 55 55 55
2.176804 1 784 Rx d 8 14 02 36 01 00 00 01 05
2.177245 1 78C Rx d 8 30 00 00 55 55 55 55 55
2.178409 1 784 Rx d 8 21 FF FF FF FF FF FF FF

i also tried the intervalTime with different value(100,200,250,300,500),The result is same !

I just want to know whether your side met the similar issue,if not ,i will check my code !

Thanks !

Re: PCANBasic Trace Problem

Posted: Fri 28. Jul 2023, 09:50
by K.Wagner
Hello,
Ken0711 wrote:
Fri 28. Jul 2023, 09:40
I recoded trace by the CANOE simultaneously ,and CAN record is Normal
please make a trace with PCAN-View as suggested before, and let us see where are the double entries.
Ken0711 wrote:
Fri 28. Jul 2023, 09:40
I just want to know whether your side met the similar issue,if not ,i will check my code !
As shown in my last post, we cannot reproduce a behavior like you describe. So, no, we never met a similar issue.