Knowledge Base
Valid For#Open_Serial
Applies ToAll

This instruction opens a serial port for use as a MODBUS Master.

Function Prototype
#Open_Serial Port(PortNumber) ModbusMaster(
BaudRate,
Parity,
MessageGap,
QueryTimeout,
QueryAttempts
)
ParameterOptionDescription
BaudRatemandatoryThe baudrate to be used. Legal values are 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, (230400, 460800)*
ParitymandatoryMay be either:n = noneo = odde = even
MessageGapmandatorySee description here. Set to 0 for the default.
QueryTimeoutoptionalTime to wait for a Modbus Slave to respond in units of 10ms.  So 50 would be 0.5 seconds.  Defaults to 100 (ie, 1 second)
QueryAttemptsoptionalNumber of times to re-send to a slave that isn’t responding.  Defaults to 0 which is taken to mean no retries, just send once.
Description

This hash function sets the serial port up for use with the ModBusRTU master. Once initiated and configured, the SPLat controller Firmware takes care of all the low level communications activity. ModBus documentation.

Port() is only available on SPLat 32 bit controllers (black boards).

*The (high speed baud rates) are only available on SPLat 32 bit controllers (black boards).

Note that 32-bit controllers allow use of Modbus on multiple ports.  It has been successfully tried with Master mode on one port and Slave mode on another.