public WriteVinceMotorMessageFloat32(uint f_ID, FOUR_SEGMENT_CODE f_FourCode, float f_DataValue) { byteList.Clear(); byteList.Add((byte)f_ID); byteList.Add((byte)0x10); byteList.Add((byte)0x00); byteList.Add((byte)f_FourCode); byteList.Add((byte)0x00); byteList.Add((byte)0x02); //数据长度和内容 byteList.Add((byte)0x04); //整体是小端传送,内部两个字节是大端传送。 unsafe { byte *pdata = (byte *)&f_DataValue; byteList.Add((byte)*(pdata + 1)); byteList.Add((byte)*(pdata + 0)); byteList.Add((byte)*(pdata + 3)); byteList.Add((byte)*(pdata + 2)); } //CRC uint result = crc_checksum(byteList.ToArray(), byteList.Count()); byteList.Add((Byte)((result >> 8) & 0xFF)); byteList.Add((Byte)(result & 0xFF)); }
public WriteVinceMotorMessage(uint f_ID, FOUR_SEGMENT_CODE StateCode, UInt16 f_DataValue) { byteList.Clear(); byteList.Add((byte)f_ID); byteList.Add((byte)0x06); byteList.Add((byte)0x00); byteList.Add((byte)StateCode); //整体是小端传送,内部两个字节是大端传送。 for (int i = 0; i < 2; i++) { byteList.Add((Byte)((f_DataValue >> i * 8) & 0xFF)); } //CRC uint result = crc_checksum(byteList.ToArray(), byteList.Count()); byteList.Add((Byte)((result >> 8) & 0xFF)); byteList.Add((Byte)(result & 0xFF)); }
public WriteVinceMotorMessageFloat(uint f_ID, FOUR_SEGMENT_CODE f_FourCode, float f_DataValue) { byteList.Add((byte)f_ID); byteList.Add((byte)0x10); byteList.Add((byte)0x00); byteList.Add((byte)f_FourCode); byteList.Add((byte)0x00); byteList.Add((byte)0x02); //数据长度和内容 byteList.Add((byte)0x04); for (int i = 3; i >= 0; i--) { //byteList.Add((Byte)((f_DataValue >> i * 8) & 0xFF)); } //CRC uint result = crc_checksum(byteList.ToArray(), byteList.Count()); byteList.Add((Byte)((result >> 8) & 0xFF)); byteList.Add((Byte)(result & 0xFF)); }
public WriteVinceMotorMessageInt32(uint f_ID, FOUR_SEGMENT_CODE f_FourCode, Int32 f_DataValue) { byteList.Clear(); byteList.Add((byte)f_ID); byteList.Add((byte)0x10); byteList.Add((byte)0x00); byteList.Add((byte)f_FourCode); byteList.Add((byte)0x00); byteList.Add((byte)0x02); //数据长度和内容 byteList.Add((byte)0x04); //整体是小端传送,内部两个字节是大端传送。 byteList.Add((Byte)((f_DataValue >> 8) & 0xFF)); byteList.Add((Byte)((f_DataValue >> 0) & 0xFF)); byteList.Add((Byte)((f_DataValue >> 24) & 0xFF)); byteList.Add((Byte)((f_DataValue >> 16) & 0xFF)); //CRC uint result = crc_checksum(byteList.ToArray(), byteList.Count()); byteList.Add((Byte)((result >> 8) & 0xFF)); byteList.Add((Byte)(result & 0xFF)); }