package protocol import ( "git.noahlan.cn/noahlan/nnet/packet" ) type ( Packet interface { packet.IPacket Copy() Packet Modbus SetBody(data []byte) SetError(err *MError) } Modbus interface { GetFunction() uint8 GetAddress() uint8 } ModbusHeader struct { Address uint8 Function uint8 } ) func GetError(pkg Packet) (err MError) { function := pkg.GetFunction() if (function & 0x80) != 0 { err = MError(pkg.GetBody()[0]) } return }