修改驱动程序
This commit is contained in:
1 parent
063c3fcc07
commit
a69c1a58d6
39 files changed
+1627
-641
No files matched your search
@@ -22,11 +22,24 @@ int modbus_m_read_regist(uint8_t id,uint16_t addr,uint16_t length,uint8_t * data
|
||||
return index;
|
||||
}
|
||||
|
||||
//// 解析通过03 命令读取回来额寄存器数据
|
||||
//int modbus_m_read_regist_ack(uint)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
// 写入寄存器
|
||||
// addr 寄存器地址
|
||||
// id 丛机地址
|
||||
// length 读取丛机数据长度
|
||||
int modbus_m_write_regist(uint8_t id,uint16_t addr,uint16_t key,uint8_t * data)
|
||||
{
|
||||
uint16_t index = 0,crc;
|
||||
data[index++] = id;
|
||||
data[index++] = 0x06;
|
||||
data[index++] = (addr >> 8) & 0x00FF;
|
||||
data[index++] = addr & 0x00FF;
|
||||
data[index++] = (key >> 8) & 0x00FF;
|
||||
data[index++] = key & 0x00FF;
|
||||
crc = MX_CRC_CALC(data,index);
|
||||
data[index++] = crc & 0x00FF;
|
||||
data[index++] = (crc >> 8) & 0x00FF;
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user