LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Strings in CAN messages

Hi,
I own two dual port NI-CAN cards. I am able to send and receive
floats from one machine to another using CAN. I'd also like to send
strings. Is this possible? Any clues on how I can do this?

Thanks,

Mustafa
0 Kudos
Message 1 of 2
(2,888 Views)
Mustafa,

Interesting idea, I'm not sure exactly why you want to do this because it's not something that many people use CAN for, but it is certainly possible. Basically, CAN works in 8 byte frames, so you couldn't send more than 8 bytes in any given frame and you would have to use multiple frames to transmit a string of any higher length. Packing the data into the frame is all you have to do. Since we're in the CVI forum, I'm guessing that you're using CVI functions like ncRead/ncWrite. Basically, put the proper string in the struct that you pass to ncWrite and read it back from ncRead. As long as you are sending single-byte ASCII-style characters, you can put 8 characters in a frame using ASCII encoding and read them out just the same. Watch out for the strin
g termination as most C-style strings expect a NULL '\0' character at the end so that functions do not read past the end of the string.

Hope this helps, and let me know if I can be of further assistance by posting here.

Scott B
National Instruments
Applications Engineer
0 Kudos
Message 2 of 2
(2,888 Views)