go fmt ./...
This commit is contained in:
parent
079cd7efc9
commit
c846ac1ead
2 changed files with 122 additions and 87 deletions
|
@ -31,10 +31,13 @@ func NewClient2(packager Packager, transporter Transporter) Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x01)
|
// Function code : 1 byte (0x01)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of coils : 2 bytes
|
// Quantity of coils : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x01)
|
// Function code : 1 byte (0x01)
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Coil status : N* bytes (=N or N+1)
|
// Coil status : N* bytes (=N or N+1)
|
||||||
|
@ -62,10 +65,13 @@ func (mb *client) ReadCoils(address, quantity uint16) (results []byte, err error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x02)
|
// Function code : 1 byte (0x02)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of inputs : 2 bytes
|
// Quantity of inputs : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x02)
|
// Function code : 1 byte (0x02)
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Input status : N* bytes (=N or N+1)
|
// Input status : N* bytes (=N or N+1)
|
||||||
|
@ -93,10 +99,13 @@ func (mb *client) ReadDiscreteInputs(address, quantity uint16) (results []byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x03)
|
// Function code : 1 byte (0x03)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of registers : 2 bytes
|
// Quantity of registers : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x03)
|
// Function code : 1 byte (0x03)
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Register value : Nx2 bytes
|
// Register value : Nx2 bytes
|
||||||
|
@ -124,10 +133,13 @@ func (mb *client) ReadHoldingRegisters(address, quantity uint16) (results []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x04)
|
// Function code : 1 byte (0x04)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of registers : 2 bytes
|
// Quantity of registers : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x04)
|
// Function code : 1 byte (0x04)
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Input registers : N bytes
|
// Input registers : N bytes
|
||||||
|
@ -155,10 +167,13 @@ func (mb *client) ReadInputRegisters(address, quantity uint16) (results []byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x05)
|
// Function code : 1 byte (0x05)
|
||||||
// Output address : 2 bytes
|
// Output address : 2 bytes
|
||||||
// Output value : 2 bytes
|
// Output value : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x05)
|
// Function code : 1 byte (0x05)
|
||||||
// Output address : 2 bytes
|
// Output address : 2 bytes
|
||||||
// Output value : 2 bytes
|
// Output value : 2 bytes
|
||||||
|
@ -196,10 +211,13 @@ func (mb *client) WriteSingleCoil(address, value uint16) (results []byte, err er
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x06)
|
// Function code : 1 byte (0x06)
|
||||||
// Register address : 2 bytes
|
// Register address : 2 bytes
|
||||||
// Register value : 2 bytes
|
// Register value : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x06)
|
// Function code : 1 byte (0x06)
|
||||||
// Register address : 2 bytes
|
// Register address : 2 bytes
|
||||||
// Register value : 2 bytes
|
// Register value : 2 bytes
|
||||||
|
@ -232,12 +250,15 @@ func (mb *client) WriteSingleRegister(address, value uint16) (results []byte, er
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x0F)
|
// Function code : 1 byte (0x0F)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of outputs : 2 bytes
|
// Quantity of outputs : 2 bytes
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Outputs value : N* bytes
|
// Outputs value : N* bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x0F)
|
// Function code : 1 byte (0x0F)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of outputs : 2 bytes
|
// Quantity of outputs : 2 bytes
|
||||||
|
@ -274,12 +295,15 @@ func (mb *client) WriteMultipleCoils(address, quantity uint16, value []byte) (re
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x10)
|
// Function code : 1 byte (0x10)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of outputs : 2 bytes
|
// Quantity of outputs : 2 bytes
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Registers value : N* bytes
|
// Registers value : N* bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x10)
|
// Function code : 1 byte (0x10)
|
||||||
// Starting address : 2 bytes
|
// Starting address : 2 bytes
|
||||||
// Quantity of registers : 2 bytes
|
// Quantity of registers : 2 bytes
|
||||||
|
@ -316,11 +340,14 @@ func (mb *client) WriteMultipleRegisters(address, quantity uint16, value []byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x16)
|
// Function code : 1 byte (0x16)
|
||||||
// Reference address : 2 bytes
|
// Reference address : 2 bytes
|
||||||
// AND-mask : 2 bytes
|
// AND-mask : 2 bytes
|
||||||
// OR-mask : 2 bytes
|
// OR-mask : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x16)
|
// Function code : 1 byte (0x16)
|
||||||
// Reference address : 2 bytes
|
// Reference address : 2 bytes
|
||||||
// AND-mask : 2 bytes
|
// AND-mask : 2 bytes
|
||||||
|
@ -359,6 +386,7 @@ func (mb *client) MaskWriteRegister(address, andMask, orMask uint16) (results []
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x17)
|
// Function code : 1 byte (0x17)
|
||||||
// Read starting address : 2 bytes
|
// Read starting address : 2 bytes
|
||||||
// Quantity to read : 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
|
// Quantity to write : 2 bytes
|
||||||
// Write byte count : 1 byte
|
// Write byte count : 1 byte
|
||||||
// Write registers value : N* bytes
|
// Write registers value : N* bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x17)
|
// Function code : 1 byte (0x17)
|
||||||
// Byte count : 1 byte
|
// Byte count : 1 byte
|
||||||
// Read registers value : Nx2 bytes
|
// Read registers value : Nx2 bytes
|
||||||
|
@ -397,9 +427,12 @@ func (mb *client) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request:
|
// Request:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x18)
|
// Function code : 1 byte (0x18)
|
||||||
// FIFO pointer address : 2 bytes
|
// FIFO pointer address : 2 bytes
|
||||||
|
//
|
||||||
// Response:
|
// Response:
|
||||||
|
//
|
||||||
// Function code : 1 byte (0x18)
|
// Function code : 1 byte (0x18)
|
||||||
// Byte count : 2 bytes
|
// Byte count : 2 bytes
|
||||||
// FIFO count : 2 bytes
|
// FIFO count : 2 bytes
|
||||||
|
|
|
@ -67,6 +67,7 @@ type tcpPackager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode adds modbus application protocol header:
|
// Encode adds modbus application protocol header:
|
||||||
|
//
|
||||||
// Transaction identifier: 2 bytes
|
// Transaction identifier: 2 bytes
|
||||||
// Protocol identifier: 2 bytes
|
// Protocol identifier: 2 bytes
|
||||||
// Length: 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:
|
// Decode extracts PDU from TCP frame:
|
||||||
|
//
|
||||||
// Transaction identifier: 2 bytes
|
// Transaction identifier: 2 bytes
|
||||||
// Protocol identifier: 2 bytes
|
// Protocol identifier: 2 bytes
|
||||||
// Length: 2 bytes
|
// Length: 2 bytes
|
||||||
|
|
Loading…
Reference in a new issue