LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing J1939 data stream

I am working on J1939 and have looked through the J1939 frame input stream.vi in LabVIEW examples. Parsing the data stream coming from J1939 is what I am aiming to do as every byte holds information for the products that I am working on. LabVIEW example code and front panel images while running is attached. 

Download All
0 Kudos
Message 1 of 10
(3,894 Views)

What exactly is your question?

0 Kudos
Message 2 of 10
(3,816 Views)

How can I parse the the data stream frames? I have attached the block diagram for the example and the front panel. How can I access the frame data from the block diagram to parse it? That is my question. 

0 Kudos
Message 3 of 10
(3,811 Views)

The data in the frames is in the wire coming out of the X-NET Read (the one that says "Frame CAN" under it), going into the "CAN Frame 2 Table" VI in the example. You may also want to take a look at the J1939 Protocol Reference Example, if you haven't already, even though it's from several years back.

0 Kudos
Message 4 of 10
(3,791 Views)

Now, that brings me back to the parsing part. The data goes through X-NET read and "CAN Frame 2 Table" VI. Frames are listed after and this is where I want to get them and parse them. "CAN Frame 2 Table" is the VI the process for creating the frame list is happening. But I am not so clear about the case blocks. Also, how I can parse the data byte by byte. That is the next step. CAN Frame 2 Table FP and BD images are attached. 

Download All
0 Kudos
Message 5 of 10
(3,776 Views)

This sounds more like an issue of LabVIEW basics than J1939 specifically. You want to create a new VI (function) that takes the same data input as CAN Frame 2 Table, parses it however you want, and outputs the desired data.

 

X-NET Read gives you an array of clusters. Each array element is cluster representing a CAN frame. The CAN data, as an array of bytes, is available in the "Payload" element of the cluster.

0 Kudos
Message 6 of 10
(3,769 Views)

I was able to get hold of the CAN frame data. Payload is the part that I am aiming to process as it holds device's movement dimensional values. I have created a case for each device, building 3x2 and 2x2 arrays in each case. Transferring them to an array through case structure is the part I like to get some advise. 

0 Kudos
Message 7 of 10
(3,741 Views)

I want to parse the CAN payload into arrays where each byte is accesible through LabVIEW. Attached images  are the block diagrams for a LV example where I have modified to see if I could succeed. My main question is how each payload byte could be accessed? 

0 Kudos
Message 8 of 10
(3,665 Views)

Hi mjafarin9,

 

My main question is how each payload byte could be accessed? 

The payload is an array of U8/bytes.

Array elements are accessed using IndexArray or autoindexing loops. Both methods are very basic LabVIEW knowledge: did you take the free beginner lessons offered by NI?

 

In your "modified BD":

- What's the point of taking a subarray of the first 8 bytes of the payload? For standard CAN the payload will contain at max 8 bytes…

- Why do you wire the payload content (aka data) as selector to a case structure? Do you really want to treat each possible data value with a different case?

 

My main question is: what are you really trying to do?

 

Edit: I merged your threads because of the very related problem.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(3,624 Views)

Hi GerdW,

 

Thanks for your response. Yes, array auto indexing and Indexarray are both are the basic of the basic LabVIEW. 

As for the payload's subarray of 8 elements, there are other steps that I am aiming to work on e.g. saving each subarray seperately but that is not an issue at the moment. 

As for wiring the payload content and treating them with different cases, you got it. Being a part of the machine control project, every byte has values that should be treated and programmed differently from its neighbouring bytes. 

 

0 Kudos
Message 10 of 10
(3,596 Views)