优化日志
This commit is contained in:
@@ -32,9 +32,9 @@ type ValueDescriptor struct {
|
||||
|
||||
// SwitchCommands 定义了开关类指令所需的Modbus参数
|
||||
type SwitchCommands struct {
|
||||
// ModbusStartAddress 记录Modbus寄存器的起始地址,用于生成指令。
|
||||
// ModbusStartAddress 记录Modbus寄存器的起始地址,用于生成指令。(一般是第三到四字节)
|
||||
ModbusStartAddress uint16 `json:"modbus_start_address"`
|
||||
// ModbusQuantity 记录Modbus寄存器的数量,对于开关通常为1。
|
||||
// ModbusQuantity 记录Modbus寄存器的数量,对于开关通常为1。(一般是五到六字节)
|
||||
ModbusQuantity uint16 `json:"modbus_quantity"`
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ func (sc *SwitchCommands) SelfCheck() error {
|
||||
|
||||
// SensorCommands 定义了传感器读取指令所需的Modbus参数
|
||||
type SensorCommands struct {
|
||||
// ModbusFunctionCode 记录Modbus功能码,例如 ReadHoldingRegisters。
|
||||
// ModbusFunctionCode 记录Modbus功能码,例如 ReadHoldingRegisters。(一般是第二字节)
|
||||
ModbusFunctionCode command_generater.ModbusFunctionCode `json:"modbus_function_code"`
|
||||
// ModbusStartAddress 记录Modbus寄存器的起始地址,用于生成指令。
|
||||
// ModbusStartAddress 记录Modbus寄存器的起始地址,用于生成指令。(一般是第三到四字节)
|
||||
ModbusStartAddress uint16 `json:"modbus_start_address"`
|
||||
// ModbusQuantity 记录Modbus寄存器的数量,用于生成指令。
|
||||
// ModbusQuantity 记录Modbus寄存器的数量,用于生成指令。(一般是五到六字节)
|
||||
ModbusQuantity uint16 `json:"modbus_quantity"`
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ func (t *LoRaMeshUartPassthroughTransport) workerLoop() {
|
||||
t.runIdleState()
|
||||
case stateReceiving:
|
||||
t.runReceivingState()
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,6 +257,7 @@ func (t *LoRaMeshUartPassthroughTransport) executeSend(req *sendRequest) (*trans
|
||||
frame.WriteByte(currentChunk) // 当前包序号
|
||||
frame.Write(chunk) // 数据块
|
||||
|
||||
t.logger.Infof("构建LoRa数据包: %v", frame.Bytes())
|
||||
_, err := t.port.Write(frame.Bytes())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("写入串口失败: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user