调整 GeneralDeviceService
This commit is contained in:
@@ -100,7 +100,7 @@ func GenerateModbusRTUReadCommand(slaveAddress uint8, functionCode ModbusFunctio
|
||||
return command, nil
|
||||
}
|
||||
|
||||
// GenerateModbusRTUWriteCommand 生成Modbus RTU写入单个线圈的指令
|
||||
// GenerateModbusRTUSwitchCommand 生成Modbus RTU写入单个线圈的指令
|
||||
// 该函数专门用于生成 Modbus RTU 的写入单个线圈 (0x05) 指令,用于控制开关。
|
||||
//
|
||||
// 参数:
|
||||
@@ -113,7 +113,7 @@ func GenerateModbusRTUReadCommand(slaveAddress uint8, functionCode ModbusFunctio
|
||||
//
|
||||
// []byte: 完整的Modbus RTU指令字节切片。
|
||||
// error: 如果参数无效或生成过程中出现错误,则返回错误信息。
|
||||
func GenerateModbusRTUWriteCommand(slaveAddress uint8, coilAddress uint16, onOffState bool) ([]byte, error) {
|
||||
func GenerateModbusRTUSwitchCommand(slaveAddress uint8, coilAddress uint16, onOffState bool) ([]byte, error) {
|
||||
// 1. 校验从站地址
|
||||
if slaveAddress == 0 || slaveAddress > 247 {
|
||||
return nil, fmt.Errorf("从站地址无效: %d, 必须在1-247之间", slaveAddress)
|
||||
|
||||
Reference in New Issue
Block a user