I have a CAN message as below - it contains the status of 5 solenoids in Byte 0 and Byte 1. As I have shown a solenoid that is ON is represented by a bit combination of 01. 00 is OFF. 10 or 11 is fault. So I just have to check for 01 or 00 and then if both are not matching declare fault.
0x18FF0308 = 55 01 00 00 00 00 00 00
First swap Byte 0 and Byte 1 and then form a 16 bit integer.
0x0155 = 00000001 01010101 ( All Solenoids ON )
One way is to do is a bit wise mask then AND for each solenoid and then decide . For instance for Solenoid 1 the mask will be 0x0001 and for Solenoid 2 it will be 0x0004 and so on.
Any other simple way ??