Serial Communications

Written on: September 12, 2022 2:44 pm

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.

package serialportexample;

import com.integpg.comm.AUXSerialPort;
import com.integpg.comm.PortInUseException;
import com.integpg.comm.SerialPort;
import java.io.IOException;
import java.io.OutputStream;

public class SerialPortExample {

    public static SerialPort AUX = null;
    public static OutputStream outputStream = null;
    
    public static void main(String[] args) throws PortInUseException, IOException {

        //create aux port object and open an aux port connection.
        AUX = new AUXSerialPort();
        AUX.open();

        //create object for aux outputstream and send message out aux port.
        outputStream = AUX.getOutputStream();
        outputStream.write("This was sent from the AUX port.".getBytes());

    }

}

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.

By | Updated On October 19, 2022 1:08 pm | No Comments


 

INTEG Process Group, inc. © 2022

Real-Time
Mon - Fri, 8am - 4pm EST
P: 724-933-9350
PureChat
Always Available
Contact Form
sales@integpg.com
support@integpg.com

@integpg
@jniordev