Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read/write individual bits from/to CAN when using Channel API functions?

I want to read several CAN channels and write to a CAN channel by using NI-CAN Channel API functions. Some channels consist of one byte of 8 bit length, where every individual bit represents a status bit that has to be read or set (i.e. 1000 0000 or 0100 0000 ...). How can I specify the individual bits?
0 Kudos
Message 1 of 4
(6,419 Views)
Hello Zelba,

cannot specify individual bits in that way since the data type of the channel API is DBL.
They only way would be to specify a own channel for every bit.

Regards
Paul
0 Kudos
Message 2 of 4
(6,398 Views)
Thank you, Paul.
I feared that this might be the answer....
0 Kudos
Message 3 of 4
(6,394 Views)

Well the trick is to just crate or have in your case a unsigned 8 bit channel. You can then use a 8 bit unsigned integer datatype to write your bit pattern. See the attached VI. If you are using a C language it should be even easier.

DirkW

0 Kudos
Message 4 of 4
(6,375 Views)