You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.0 KiB
86 lines
3.0 KiB
using System; |
|
|
|
[Serializable] |
|
public static class Pc2McuProto |
|
{ |
|
public struct DeviceID |
|
{ |
|
public const byte PC = 0xA0; |
|
public const byte MCU = 0x0A; |
|
} |
|
public struct HumanAddress |
|
{ |
|
public const byte LeftPalm = 0x01;//左手手掌 |
|
public const byte RightPalm = 0x02;//右手手掌 |
|
public const byte LeftArm = 0x03;//左手手臂 |
|
public const byte RightArm = 0x04;//右手手臂 |
|
public const byte LeftShoulder = 0x05;//左手肩膀 |
|
public const byte RightShoulder = 0x06;//右手肩膀 |
|
public const byte LeftChest = 0x07;//左边胸部 |
|
public const byte RightChest = 0x08;//右边胸部 |
|
//... |
|
public const byte OtherAddress = 0xFF;//其他地址 |
|
} |
|
|
|
public struct CommandType |
|
{ |
|
public const byte ADC_IMU_16 = 0x01; |
|
public const byte CalibrationState1 = 0x02; |
|
public const byte CalibrationState2 = 0x03; |
|
public const byte SHAKE_CONTROLLER_COMMAND = 0x04; |
|
public const byte BATTERY_VOLTAGE_DATA = 0x05; |
|
public const byte CalibrationState5 = 0x06; |
|
public const byte LINK_STATUS = 0x07; |
|
public const byte CalibrationState7 = 0x08; |
|
public const byte CalibrationState8 = 0x09; |
|
public const byte CalibrationState9 = 0x0A; |
|
//... |
|
public const byte StateTransStop = 0xC8; |
|
public const byte DebugAngle1 = 0xC9; |
|
public const byte DebugAngle2 = 0xCA; |
|
public const byte DebugAngle3 = 0xCB; |
|
public const byte DebugAngle4 = 0xCC; |
|
public const byte DebugAngle5 = 0xCD; |
|
public const byte DebugAngle6 = 0xCE; |
|
public const byte DebugAngle7 = 0xCF; |
|
public const byte DebugAngle8 = 0xD0; |
|
public const byte DebugAngle9 = 0xD1; |
|
public const byte DebugAngle10 = 0xD2; |
|
public const byte DebugAngle11 = 0xD3; |
|
public const byte DebugAngle12 = 0xD4; |
|
public const byte DebugAbduce1 = 0xD5; |
|
public const byte DebugAbduce2 = 0xD6; |
|
public const byte DebugAbduce3 = 0xD7; |
|
|
|
public const byte HeartBeat = 0x68; |
|
|
|
public const byte StopDataReceive = 0xA0;//停止接收数据 |
|
|
|
} |
|
|
|
public struct DataType |
|
{ |
|
public const byte AngleAndAbduceData = 0x01;//幅度角+倾角数据 |
|
public const byte AngleData = 0x02;//幅度角数据 |
|
public const byte IMUData = 0x03;//IMU数据 |
|
public const byte AbduceData = 0x04;//倾角数据 |
|
public const byte AccelerationData = 0x05;//加速度数据 |
|
public const byte GyroData = 0x06;//陀螺仪数据 |
|
public const byte OffsetData = 0x07;//位移数据 |
|
//... |
|
public const byte AllData = 0xC8;//幅度数据+倾角数据+重力速度(全数据主要用于调试) |
|
//... |
|
public const byte OtherData = 0xFF;//其他数据 |
|
} |
|
|
|
|
|
public static byte check_num(byte[] buffer, int size) |
|
{ |
|
byte cr = 0; |
|
for (int i = 2; i < size - 1; i++) |
|
{ |
|
cr += buffer[i]; |
|
} |
|
return cr; |
|
} |
|
}
|
|
|