LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN message manipulation

Solved!
Go to solution

Your previous setup was flawed.  It would log 4900 frames into a new file, every 10 ms, even if no frames came in.  You were writing the entire buffer size to a new file.  My version takes the new data that comes in and writes it to a file.  I forgot to add the Set File Position to set it to the end after each write so that it would append the new data to the one file.  This would then fix that issue.  That's why you were were getting way too much data, you were writing the same data over and over into new files.

 

The attatched file should fix that.

0 Kudos
Message 11 of 16
(622 Views)

The text file still stores only one cycle worth of data. 

The buffer did bottleneck the code but it was only used to display the CAN table and targets for a longer time. It was not affecting logging. 

 

The current edit refreshes the target position plot every cycle and this information is too fast to read on the screen. The CAN table also does not display any frames. 

I have read that the set position file appends the data to the exisitng file but it didn't not work.

 

 

 

 

Regards,

Gagan

 

0 Kudos
Message 12 of 16
(615 Views)

I am attaching the code I had for one binary file that reads 27000 frames and makes a 120MB file. 

0 Kudos
Message 13 of 16
(611 Views)

There are multiple errors in that file.

You are write all files that are in the buffer every time the while loop iterates. What you are getting are duplicates of a lot of CAN frames. 

You should write only when you get new frames, and only the new frames.

 

Why are you reading the CAN raw, and then convert it to CAN frames directly after, when you can read CAN frames directly?

 

I have tried to modify your vi a bit, added another method for a buffer using a queue, I think that it is more simple.

 

I was not sure if you wanted to have the newest frames in top or bottom of the table.

 

One thing I'm not sure is working for you is the conversion to signals.

 

If you only what to display the latest received Frame for every unique CAN ID, then I also can show you that.

 

Message 14 of 16
(596 Views)

I agree, only new frames must be logged. 

 

That functions was not required to read CAN raw. It was an older version that incorporated that bit. 

 

It does'nt matter which part is first as I can manipulate it for offline data analysis.

 

 I stream CAN frames live, and I cannot check that part now but I will verify that in the morning. 

 

I don't need to show latest frames but some frames give information about the device status and I could filter that out to read out the specific information. The previous method to filter using arb ID removes all frames but I could make another separate table that displays the ones I want. 

 

 

Thanks a ton for all the help. 

 

 

 

Regards,

Gagan

0 Kudos
Message 15 of 16
(581 Views)

Hey, 

 

I just verified the code with live streaming. It is working well now. 

The text file size gets big but that's the amount of data storing. 

 

I made a code to filter the CAN frame according based on arb ID as you previously illustrated. I can make a seprate table to check for confirmation messages for configuration changes using CAN output (transmit to port)

 

But I'm not able to to find material on how to construct the CAN frame (ie the payload). Based on the database file, I make the the payload construction. I have read the CAN protocol version 2.0 from bosch and a few papers, but no examples on how to frame CAN messages have been mentioned. 

 

I have decoded the CAN frames read and have compared it to the message structure. Using the payload buts in binary, every message can be constructed and according to the given .dbc files. 

 

But the configuration arb ID does not show the changes made. There are two separate .dbc files for the device and I suspect writing through one .dbc file and reading through another might be causing the problem?

 

How to successfully write CAN messages that are one time send and for other setting cyclic transmit (I'm sure of the payload message but not sure about the timestamp)?

 

I am attaching the code and .dbc file I am working on. [I send 0x200 for change and receive 0x201 for confirmation. These belong to a different .dbc file (ch0) and the messages 0x513, 1536, 1794 and 1793 are in a different .dbc file. Currently I use write CANframes.vi to send a message and then run my version1.4.vi to check if the change has occured]

 

 

Regards,

Gagan 

0 Kudos
Message 16 of 16
(562 Views)