Adjust tracing sampling frequency
Adjust tracing sampling frequency
I'm using PCAN-Basic to build a custom application to interact with my hardware, and I've been successful in writing data to a .trc trace file. I'm getting a new data point about once every 0.1 ms. I want to slow this down (once per second, once per minute) to allow for longer tests. Is there a parameter I can use to change the sampling rate that produces the trace file? I checked the PCAN-Parameter documentation and didn't see anything.
Thanks
Thanks
Re: Adjust tracing sampling frequency
Hello,
this is no possible. Writing in the trace file occurs only when a message is read. Since PCAN-Basic doesn't read messages actively, but only when you call the function CAN_Read, or CAN_ReadFD (according to your configuration), you cannot adjust a time for flushing data. The only thing you could is to read slower, but I think this could be more a backdraw than a progress.
this is no possible. Writing in the trace file occurs only when a message is read. Since PCAN-Basic doesn't read messages actively, but only when you call the function CAN_Read, or CAN_ReadFD (according to your configuration), you cannot adjust a time for flushing data. The only thing you could is to read slower, but I think this could be more a backdraw than a progress.
Best regards,
Keneth
Keneth
Re: Adjust tracing sampling frequency
Yes, that's what I want. I want to read data slower (less frequently) to collect data over a longer period of time. How would I go about doing this with PCAN-Basic?
Re: Adjust tracing sampling frequency
Hello,
then you just need to call CAN_Read less frequently. Each call to the CAN_Read function will return just one message, so you can use a timer, set its interval to the frequency you want to read and call the CAN_Read function each time the time elapses. But keep in mind that doing so could lead to queue overruns errors, if the queue gets full because it is being read to slow. Note that the reception queue can contain up to 32767, and there is no parameter in PCAN-Basic to ask the current message count of it. You may want to set a filter, if you are expecting just a set of IDs.
then you just need to call CAN_Read less frequently. Each call to the CAN_Read function will return just one message, so you can use a timer, set its interval to the frequency you want to read and call the CAN_Read function each time the time elapses. But keep in mind that doing so could lead to queue overruns errors, if the queue gets full because it is being read to slow. Note that the reception queue can contain up to 32767, and there is no parameter in PCAN-Basic to ask the current message count of it. You may want to set a filter, if you are expecting just a set of IDs.
Best regards,
Keneth
Keneth
Re: Adjust tracing sampling frequency
Thanks, I'm trying this but still having issues. It seems like the frequency of the time stamps in the trace file in the same no matter how often I call CAN_Read(). To be clear, what I really want is less frequent data in the resulting trace file for analysis purposes.
Re: Adjust tracing sampling frequency
Hello,
Just to read a message "later" doesn't mean that they will change their timestamps. You need to understand more how CAN works.
If you just want to take a "snapshot" of the data at certain point and to have this in a trace file, then you will need to do more steps. Note that a trace file is actually thought to get "all" data you are transmitting. I see folowing ways to go:
- As I said before, setting of some filters to just get interesting messages for you. In this way, not all data received but the data important for you is placed in the trace file.
- You could start and stop tracing each time you need to get data. The problem here is that you will have several trace files (one for every trace trigger you do).
- You can use the parameter PCAN_RECEIVE_STATUS (see PCAN-Parameter_Documentation.pdf). Configuring this to off tells the API to discard messages coming from the device. Configuring this to on again, restores the reception of messages. You could use a timer to enable this each X amount of time, wait the time you want to trace messages, and disabling it again.
Best regards,
Keneth
Keneth