SerialPort 串口 访问电子秤
每次18个字节(Bytes)
串行口通信格式:1个起始位,7个通信位,1个停止位,1个校验位。
波特率:9600bps
输出格式:18字节连续输出
数据位置 含义 描述
Byte1 STX(起始位) 0x02
Byte2 状态字A
bit6 0
bit5 1
bit4--bit3 11 (假设) 分度值因子
bit2--bit0 11 (假设) 小数点位置
Byte3 状态字B
bit6 1/0
bit5 1/0
bit4 1/0
bit3 1/0
bit2 1/0
bit1 1/0
bit0 1/0
byte4 状态字C
bit6 1/0
bit5 1/0
bit4 1/0
bit3 1/0
bit2 1/0
bit1 1/0
bit0 1/0
byte5 ---byte 10 6位毛重或净重值
byte11---byte 16 6为皮重值
byte 17 CR 是回车符 0x0D
byte 18 checksum 检验和 0x00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SerialPort com = new SerialPort(comAddress);
com.BaudRate = 9600;//300-9600
com.DataBits = 8;
com.StopBits = StopBits.One;
com.Parity = Parity.Even;
//打开串口
com.Open();
我用C#中的SerialPort 来操作串口,请问如何获取数据,解析数据,谢谢@!!