MODBUS Master Manual
What is it?
The MODBUS Master application is part of the JNIOR Modular Application design that allows you to configure and control the polling of MODBUS slave devices from the JNIOR. The JNIOR can be configured to query multiple Slave devices and multiple Tags per Slave device.
This application does not do anything with the data other than post it on the Message Pump for other applications to consume and user in their business logic. You must run another application on the JNIOR that is designed to consume and process the MODBUS tag read messages.
Adding a MODBUS Slave
A MODBUS Slave is a device that will be queried or commanded from the JNIOR. A MODBUS Slave can be connected via a Serial network or the Ethernet network. Serial Slaves can use the MODBUS RTU protocol or the MODBUS ASCII protocol. A slave that is on the Ethernet network must be a MODBUS TCP protocol device. A slave has two other configuration items. They both have default values and can be left alone if you want. First, there is a timeout. This is how long the application should wait for a response to a MODBUS query before considering the Tag to be in bad status. The second is the number of retries. This is how many bad Tag reads can be performed before considering the Slave to be BAD itself.
Adding a MODBUS Tag
A MODBUS Tag is a piece of data or an array of data that is collected from the MODBUS Slave device. The data comes from the MODBUS device by specifying an Address and the type of data to be collected. The MODBUS function that is used to query the data comes from the Address.
An address that starts with 0 will issue a Read Coils query for the address. This is a bit level function.
An address that starts with 1 will issue a Read Inputs query for the address. This is a bit level function.
An address that starts with 3 will issue a Read Input Registers query for the address. This is register level function.
An address that starts with 4 will issue a Read Holding Registers query for the address. This is register level function.
How does this work with the Message Pump?
A message gets put on the message pump containing information about the tag that was read. Another application, INTEG supplied or customer written, can consume that message. Here is an example of the MODBUS Master application being used in a situation where a customer wants to publish MODBUS registers to a MODBUS broker.
The MODBUS Master reads the Tags. If the value changed from the last read, then a message containing the tag name and value is posted to the Message Pump. From there our Tasker application consumes that MODBUS tag update message as a Trigger and executes a Task that posts a MQTT Publish message. Finally the MQTT application consumes the publish message and performs the MQTT publish to the broker.
Here is an image illustrating the above mentioned scenario.

Wiring the JNIOR for RS-485
The JNIOR Model 410 is the only JNIOR capable of handling RS-485 communications. The DB9 connection must be wired in a certain way to facilitate a 2 wire implementation. The main thing that needs to be done is tying the RX- and TX- lines together as well as tying the RX+ and TX+ lines together. The software will then see what is sent but the code will handle this. Here is an image of a wired port for RS-485

Troubleshooting
To see what the JNIOR is sending and receiving you can issue the iolog -ao
command. The AUX port buffer will dump to the screen to show you what the communication looks like. This can help you troubleshoot wiring issues. Here is an example of that the log looks like.
modbus_rtu_test /> iolog -ao -- 02/16/22 16:12:41.151 01 04 -01- 00 -04- 00 -00- 00 -00- 01 -00- 31 -01- CA -31--CA- ...........1.J1J -01--04--02--00--03--F9--31- 01 03 -01- 00 -03- 00 -00- 00 -00- .....y1......... 01 -00- 84 -01- 0A -84--0A--01--03--02--00--39--78--56- 01 01 ...........9xV.. -01- 00 -01- 00 -00- 00 -00- 01 -00- FD -01- CA -FD--CA--01--01- .........}.J}J.. -01--01--90--48- ...H -- 02/16/22 16:12:46.842 +4.856 01 04 -01- 00 -04- 00 -00- 00 -00- 01 -00- 31 -01- CA -31--CA- ...........1.J1J -01--04--02--00--03--F9--31- 01 03 -01- 00 -03- 00 -00- 00 -00- .....y1......... 01 -00- 84 -01- 0A -84--0A--01--03--02--00--39--78--56- 01 01 ...........9xV.. -01- 00 -01- 00 -00- 00 -00- 01 -00- FD -01- CA -FD--CA--01--01- .........}.J}J.. -01--01--90--48- ...H -- 02/16/22 16:12:52.011 +4.877 01 04 -01- 00 -04- 00 -00- 00 -00- 01 -00- 31 -01- CA -31--CA- ...........1.J1J -01--04--02--00--03--F9--31- 01 03 -01- 00 -03- 00 -00- 00 -00- .....y1......... 01 -00- 84 -01- 0A -84--0A--01--03--02--00--39--78--56- 01 01 ...........9xV.. -01- 00 -01- 00 -00- 00 -00- 01 -00- FD -01- CA -FD--CA--01--01- .........}.J}J.. -01--01--90--48- ...H