views:

29

answers:

0

Hey Guys,

Having a few issues with RxTx (still!). I'm using RxTx to control a USB->Serial bridge device that opens a cash drawer for my POS system. When a user enters their clerk number and logs into the system, RxTx opens up the connection to the bridge using the following code:

try {
    portID = (CommPortIdentifier) CommPortIdentifier.getPortIdentifier("COM4");
    drawerPort = (SerialPort) portID.open("pid", 5000);
    drawerPort.setSerialPortParams(2400, SerialPort.DATABITS_8,
                     SerialPort.STOPBITS_1,
                     SerialPort.PARITY_NONE);

    drawerPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);

    outToDrawer = drawerPort.getOutputStream();


} catch (NoSuchPortException ex) {
    ex.printStackTrace();
} catch (PortInUseException ex) {
    ex.printStackTrace();
} catch (UnsupportedCommOperationException ex) {
    ex.printStackTrace();
} catch (IOException ex) {
    ex.printStackTrace();
}

When a sale is made, any data that is written to the device will trigger the drawer to open, so at the end of the sale I just call

outToDrawer.write("1".getBytes());

and to close (which is called when the user logs out, or the system is turned off (windows is put into standby mode):

outToDrawer.close();
drawerPort.close();

Using PortMon, I'm seeing that RxTx is continually polling the device, PortMon, which is refreshing every second, quickly fills up with lots of:

java.exe  IOCTL_SERIAL_GET_COMMSTATUS    Serial2   SUCCESS
java.exe  IOCTL_SERIAL_GET_COMMSTATUS    Serial2   SUCCESS
java.exe  IOCTL_SERIAL_GET_COMMSTATUS    Serial2   SUCCESS
java.exe  IOCTL_SERIAL_GET_COMMSTATUS    Serial2   SUCCESS
java.exe  IOCTL_SERIAL_GET_COMMSTATUS    Serial2   SUCCESS
java.exe  IOCTL_SERIAL_GET_MODEMSTATUS   Serial2   SUCCESS

the device seems to be working properly, opening the drawer when I call it, but I am unable to close the connection, or put the PC into standby mode, giving me the error:

The device driver for the 'Prolific USB-to-Serial Comm Port (COM4)' device is
preventing the machine from entering standby. 
Please close all applications and try again. 
If the problem persists, you may need to update this driver.

When I'm connected to the device using HyperTerminal, the system will go into standby as normal.

I'm pulling my hair out with this one guys! Been working on it for ages! Any suggestions will be greatly appreciated! =) Ta.