![]() func (s *Server) ListenRTU(serialConfig *serial.Write Multiple Holding Registers (Code 16) A Modbus client uses this function to write multiple holding register values within the Modbus server. Modbus functions operate on memory registers to monitor and control devices on the network. func (frame *RTUFrame) SetException(exception *Exception) The Modbus server responds by sending the starting address and quantity of coils that were written too.On TCP/IP, the MODBUS server is addressed using its IP address. func (frame *RTUFrame) SetData(data byte) This field is used for routing purpose when addressing a MODBUS serial line sub-network.func (frame *RTUFrame) GetFunction() uint8.func NewRTUFrame(packet byte) (*RTUFrame, error).func WriteSingleCoil(s *Server, frame Framer) (byte, *Exception).func WriteMultipleCoils(s *Server, frame Framer) (byte, *Exception).func WriteHoldingRegisters(s *Server, frame Framer) (byte, *Exception).func WriteHoldingRegister(s *Server, frame Framer) (byte, *Exception).func ReadInputRegisters(s *Server, frame Framer) (byte, *Exception).func ReadHoldingRegisters(s *Server, frame Framer) (byte, *Exception).func ReadDiscreteInputs(s *Server, frame Framer) (byte, *Exception).func ReadCoils(s *Server, frame Framer) (byte, *Exception).func GetException(frame Framer) (exception Exception).func Uint16ToBytes(values uint16) byte.func SetDataWithRegisterAndNumberAndValues(frame Framer, register uint16, number uint16, values uint16).func SetDataWithRegisterAndNumberAndBytes(frame Framer, register uint16, number uint16, bytes byte) Functions modbus, Create Modbus object read, Read data from Modbus server write, Perform a write operation to the connected Modbus server writeRead, Perform.func SetDataWithRegisterAndNumber(frame Framer, register uint16, number uint16).Results, err := client.ReadHoldingRegisters(0, 3) Modbus Function Code 1 (Hex 0x01) This function code is used by TOP Server when requesting a read of one or more (up to 2000 at a time) output coils or 0xxxxx type discrete/boolean addresses. _, err = client.WriteMultipleRegisters(0, 3, byte) Connect manually so that multiple requests are handled in one session Handler := modbus.NewTCPClientHandler("localhost:1502") Change the port number as required.Ĭhange the address to 0.0.0.0 to listen on all network interfaces.Īn example of a client writing and reading holding regsiters: package main Modbus typically uses port 502 (standard users require special permissions to listen on port 502). The server will continue to listen until killed (-c). Example Modbus TCP ServerĬreate a Modbus TCP Server (Slave): package main Modbus requests are processed in the order they are received and will not overlap/interfere with each other. On start, all values are initialzied to zero. The server internally allocates memory for 65536 coils, 65536 discrete inputs, 653356 holding registers and 65536 input registers. The Golang Modbus Server (Slave) responds to the following Modbus function requests: (s) RegisterFunctionHandler(funcCode, function) ![]() ![]() SetDataWithRegisterAndNumberAndValues(frame, register, number, values) SetDataWithRegisterAndNumberAndBytes(frame, register, number, bytes) SetDataWithRegisterAndNumber(frame, register, number) ![]() PC:192.168.50.138 const Modbus = require('jsmodbus')Ĭonst server = new (netServer)Ĭonst client = new Listening on Multiple TCP Ports and Serial Devices The master plc I use is "Panasonic FP7", and I have their official software "FPWIN GR7" so that I can use the PC to see the data flow, but the software lake of the function so I want to create one using nodeJS, there is my code :
0 Comments
Leave a Reply. |