1 /// 2 module modbus.types; 3 4 package(modbus) enum MAX_BUFFER = 260; 5 6 version (modbus_verbose) 7 public import std.experimental.logger; 8 9 /// 10 struct Message 11 { 12 /// device number 13 ulong dev; 14 /// function number 15 ubyte fnc; 16 /// data without changes (BigEndian) 17 const(void)[] data; 18 19 const(ubyte)[] ubdata() const @property 20 { return cast(const(ubyte)[])data; } 21 /// packet number for RTU, transaction id for TCP 22 ulong stamp; 23 } 24 25 /// 26 enum FunctionCode : ubyte 27 { 28 readCoils = 0x01, /// 01 (0x01) 29 readDiscreteInputs = 0x02, /// 02 (0x02) 30 readHoldingRegisters = 0x03, /// 03 (0x03) 31 readInputRegisters = 0x04, /// 04 (0x04) 32 writeSingleCoil = 0x05, /// 05 (0x05) 33 writeSingleRegister = 0x06, /// 06 (0x06) 34 readExceptionStatus = 0x07, /// 07 (0x07) Serial line only 35 diagnostics = 0x08, /// 08 (0x08) Serial line only 36 getCommEventCounter = 0x0B, /// 11 (0x0B) Serial line only 37 writeMultipleCoils = 0x0F, /// 15 (0x0F) 38 writeMultipleRegisters = 0x10, /// 16 (0x10) 39 readFileRecord = 0x14, /// 20 (0x14) 40 writeFileRecord = 0x15, /// 21 (0x15) 41 maskWriteRegister = 0x16, /// 22 (0x16) 42 readWriteMultipleRegisters = 0x17, /// 23 (0x17) 43 readFIFOQueue = 0x18, /// 24 (0x18) 44 } 45 46 /// 47 enum FunctionErrorCode : ubyte 48 { 49 illegalFunction = 1, /// 1 50 illegalDataAddress = 2, /// 2 51 illegalDataValue = 3, /// 3 52 slaveDeviceFailure = 4, /// 4 53 acknowledge = 5, /// 5 54 slaveDeviceBusy = 6, /// 6 55 memoryParityError = 8, /// 8 56 gatewayPathUnavailable = 0xA, /// 0xA 57 gatewayTargetDeviceFailedToRespond = 0xB, /// 0xB 58 }