// convert from From Node/From Device/To Node/To Device to CAN ID public static long ConvNDID(FndTnd nd) { long id; id = (long)nd.Fn << 21; id += (long)nd.Fd << 14; id += (long)nd.Tn << 7; id += (long)nd.Td; return(id); }
public static FndTnd ConvIDND(long ID) { FndTnd nd = new FndTnd(); // 01111111000000000000000000000 7 bits for From Node nd.Fn = (byte)((ID >> 21) & 0x7F); // 00000000111111100000000000000 7 bits for From Device nd.Fd = (byte)((ID >> 14) & 0x7F); // 00000000000000011111110000000 7 bits for To Node nd.Tn = (byte)((ID >> 7) & 0x7F); // 00000000000000000000001111111 7 bits for To Device nd.Td = (byte)(ID & 0x7F); return(nd); }