I am trying to communicate with Omron PLC CP1E-N40DR-A over USB-to-RS232 cable, using a Java program. Following is my basic code—
public void startComm() {
PrintStream os;
try {
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM4");
SerialPort serialPort = (SerialPort) portId.open("MyApp", 2000);
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_7, SerialPort.STOPBITS_2, SerialPort.PARITY_EVEN);
os = new PrintStream(serialPort.getOutputStream(), true);
os.print("@00WD0620007050*");
os.print("\r");
} catch (IOException e) {
e.printStackTrace();
} catch (PortInUseException e) {
e.printStackTrace();
} finally {
if (os != null) os.close();
}
}
This code produces no effect on the DM area. In this code I am trying write “0070” at location “0620”. The connector and its driver are alright because CX-Programmer is working fine using the same cable.
Any pointers for this would certainly help me.
Thanks