0

I'm developing an application that involves a device, card dispenser specifically and there is provided documentation for its API. According to the documentation, for example, sending "C45" command will raise the card lift up.

So based on jSSC API in communicating with serial, it will be like this,

SerialPort serialPort = new SerialPort("COM2");
try {
    serialPort.openPort();//Open serial port
    serialPort.setParams(SerialPort.BAUDRATE_9600, 
                         SerialPort.DATABITS_8,
                         SerialPort.STOPBITS_1,
                         SerialPort.PARITY_NONE);
    serialPort.writeBytes("C45".getBytes());
    serialPort.closePort();//Close serial port
}
catch (SerialPortException ex) {
    System.out.println(ex);
}

But executing this code does nothing to device, issuing "C45" has to be raising its card lift.

One more this, the device includes a demo program but probably it runs with programming languages under Visual Studio and it does not include the source code, just the documentation.

Thanks!

Erieze Lagera
  • 422
  • 6
  • 19
  • Couple of idle suggestions: a) add a \r\n to the end of the C45 b) add Thread.sleep(500) statements between each line to check for any races? c) try the setParams call before the openPort? – tariksbl Sep 30 '14 at 01:03
  • @tariksbl The code illustrated above is working and now I know where I'm wrong. Based on the documentation, it requires a strict format when sending commands. It requires SOH, STX, etc, along with the command. Thanks anyway! If you're gonna program Serial ports with Java, JSCC is one of the easiest and handy API against gnu.io and other Serial Communication in Java. – Erieze Lagera Sep 30 '14 at 05:05

0 Answers0