Serial Communications Overview
Excluding the 412DMX, each JNIOR model has a COM port (labelled RS-232) and an AUX port (labelled AUX Serial). Both are DB-9F Female 9-pin D-sub connectors. The AUX port has 4 active signals and the COM port 2. The pin assignments are as follows:
2 >> RS232 TX / RS485 TX- 3 << RS232 RX / RS485 RX- 5 GND 7 << RS232 RTS / RS485 RX+ 8 >> RS232 CTS / RS485 TX+
Each port provides at least a 3-wire RS-232 interface. A 3-wire connection contains only the Transmit (Tx), Receive (Rx) and Signal Ground (GND) circuits. The COM port is used for diagnostics, but the AUX port on the 410 is RS-485 capable. These ports can be taken over to send and receive messages from these ports.
Creating a Serial Connection
When creating applications to control a serial port, the Comm and IO classes are what can be used to control them from the JANOS runtime library. Using this class you can create Input and Output streams for either the AUX or COM ports to receive or send out data via the serial ports. Below is a very short example, that shows a quick reference to the Comm class to open the AUX serial port and after establishing an Output Stream sends out a string. I opened a serial connection from my computer using command line and connected to the AUX port of the JNIOR to see if the data went through successfully.
View on GitHub
I put the built jar file of this example application into the JNIOR’s flash folder and ran it from the Web UI’s console tab. After it has successfully run, I checked my serial connection to the AUX port of that JNIOR and saw the message went through.
Serial Connection Output
NOTE: AUX and COM ports can’t be opened more then one time, if they are then a PortInUseException error is thrown. An example of this happening is shown below where a serial port was opened twice.