go fmt ./...

This commit is contained in:
Josh Deprez 2023-05-19 17:50:26 +10:00
parent 079cd7efc9
commit c846ac1ead
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
2 changed files with 122 additions and 87 deletions

View file

@ -31,10 +31,13 @@ func NewClient2(packager Packager, transporter Transporter) Client {
}
// Request:
//
// Function code : 1 byte (0x01)
// Starting address : 2 bytes
// Quantity of coils : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x01)
// Byte count : 1 byte
// Coil status : N* bytes (=N or N+1)
@ -62,10 +65,13 @@ func (mb *client) ReadCoils(address, quantity uint16) (results []byte, err error
}
// Request:
//
// Function code : 1 byte (0x02)
// Starting address : 2 bytes
// Quantity of inputs : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x02)
// Byte count : 1 byte
// Input status : N* bytes (=N or N+1)
@ -93,10 +99,13 @@ func (mb *client) ReadDiscreteInputs(address, quantity uint16) (results []byte,
}
// Request:
//
// Function code : 1 byte (0x03)
// Starting address : 2 bytes
// Quantity of registers : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x03)
// Byte count : 1 byte
// Register value : Nx2 bytes
@ -124,10 +133,13 @@ func (mb *client) ReadHoldingRegisters(address, quantity uint16) (results []byte
}
// Request:
//
// Function code : 1 byte (0x04)
// Starting address : 2 bytes
// Quantity of registers : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x04)
// Byte count : 1 byte
// Input registers : N bytes
@ -155,10 +167,13 @@ func (mb *client) ReadInputRegisters(address, quantity uint16) (results []byte,
}
// Request:
//
// Function code : 1 byte (0x05)
// Output address : 2 bytes
// Output value : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x05)
// Output address : 2 bytes
// Output value : 2 bytes
@ -196,10 +211,13 @@ func (mb *client) WriteSingleCoil(address, value uint16) (results []byte, err er
}
// Request:
//
// Function code : 1 byte (0x06)
// Register address : 2 bytes
// Register value : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x06)
// Register address : 2 bytes
// Register value : 2 bytes
@ -232,12 +250,15 @@ func (mb *client) WriteSingleRegister(address, value uint16) (results []byte, er
}
// Request:
//
// Function code : 1 byte (0x0F)
// Starting address : 2 bytes
// Quantity of outputs : 2 bytes
// Byte count : 1 byte
// Outputs value : N* bytes
//
// Response:
//
// Function code : 1 byte (0x0F)
// Starting address : 2 bytes
// Quantity of outputs : 2 bytes
@ -274,12 +295,15 @@ func (mb *client) WriteMultipleCoils(address, quantity uint16, value []byte) (re
}
// Request:
//
// Function code : 1 byte (0x10)
// Starting address : 2 bytes
// Quantity of outputs : 2 bytes
// Byte count : 1 byte
// Registers value : N* bytes
//
// Response:
//
// Function code : 1 byte (0x10)
// Starting address : 2 bytes
// Quantity of registers : 2 bytes
@ -316,11 +340,14 @@ func (mb *client) WriteMultipleRegisters(address, quantity uint16, value []byte)
}
// Request:
//
// Function code : 1 byte (0x16)
// Reference address : 2 bytes
// AND-mask : 2 bytes
// OR-mask : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x16)
// Reference address : 2 bytes
// AND-mask : 2 bytes
@ -359,6 +386,7 @@ func (mb *client) MaskWriteRegister(address, andMask, orMask uint16) (results []
}
// Request:
//
// Function code : 1 byte (0x17)
// Read starting address : 2 bytes
// Quantity to read : 2 bytes
@ -366,7 +394,9 @@ func (mb *client) MaskWriteRegister(address, andMask, orMask uint16) (results []
// Quantity to write : 2 bytes
// Write byte count : 1 byte
// Write registers value : N* bytes
//
// Response:
//
// Function code : 1 byte (0x17)
// Byte count : 1 byte
// Read registers value : Nx2 bytes
@ -397,9 +427,12 @@ func (mb *client) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAdd
}
// Request:
//
// Function code : 1 byte (0x18)
// FIFO pointer address : 2 bytes
//
// Response:
//
// Function code : 1 byte (0x18)
// Byte count : 2 bytes
// FIFO count : 2 bytes

View file

@ -67,6 +67,7 @@ type tcpPackager struct {
}
// Encode adds modbus application protocol header:
//
// Transaction identifier: 2 bytes
// Protocol identifier: 2 bytes
// Length: 2 bytes
@ -118,6 +119,7 @@ func (mb *tcpPackager) Verify(aduRequest []byte, aduResponse []byte) (err error)
}
// Decode extracts PDU from TCP frame:
//
// Transaction identifier: 2 bytes
// Protocol identifier: 2 bytes
// Length: 2 bytes