Java/RXTX issue Windows XP -
i'm testing java/mysql pos system i've written small bar, , having problems cash draw.
the cash drawer has rj11 plug connected via usb->serial box, , writing data device triggers draw open.
i'm having problems rxtx, , wasn't sure if code, library or drivers device?
ideally, i'd connection created when user logs in system, , closed when log out, moment, code opens connection, writes data , closes when sale rung (there 1-2 second delay between hitting save button , drawer opening, frustrating).
when app first starts, drawer works fine few sales (haven't identified pattern), stops working. shows range of exceptions occurring, mixing either nosuchport, portinuse or plain accessdenied message. usually, restarting app , disconnecting/reconnecting usb working again few more sales.
i can connect device using hyperterminal, , works consistently, without issue.
java code:
public static void opentill() { try { portid = (commportidentifier) commportidentifier.getportidentifier("com3"); serialport = (serialport) portid.open("drawer_port", 2000); outputstream = serialport.getoutputstream(); serialport.setserialportparams(2400, serialport.databits_8, serialport.stopbits_1, serialport.parity_none); serialport.setrts(false); serialport.setinputbuffersize(8192); serialport.setoutputbuffersize(8192); serialport.setflowcontrolmode(serialport.flowcontrol_xonxoff_in | serialport.flowcontrol_xonxoff_out); outputstream.write("k".getbytes()); outputstream.close(); outputstream = null; serialport.close(); serialport = null; } catch (exception ex) { ex.printstacktrace(); } }
i've tried few different settings, trying mimic close can settings hyperterminal uses (by checking portmon), still not working.
any suggestions appreciated!
thanks, ryan.
cannot find wrong code, can suggest starting points debugging:
try same code sun's (errr.. oracle's) javax.comm implementation. windows version no longer available download site, can still found in other places. if don't want use implementation in final setup, might find problem. there other alternatives such serialio.
use com0com install virtual com port. enable logging (see last question in readme.txt file). compare logs when use code logs when using hyperterminal, , differences.
try different serial -> usb converter. in experience, many of these don't implement rs232 properly, or have plenty of bugs.
edit:
if discover rxtx bug, reason don't want switch javax.comm implementation (i've seen happen :-) here additional hints may useful (i try above suggestions first anyway):
are calls
setinputbuffersize
,setoutputbuffersize
required? try removing them. device use xon/xoff flow control? if not, try setting flow control none. device require rts disabled? if not, remove line well. also, try set serial port params before opening output stream. of course, none of should make difference, might triggering rxtx bug.is problem related opening , closing port in sequence several times? try keep port open. on each sale, do:
outputstream.write("k".getbytes()); outputstream.flush();
and see if problem still reproduces.
Comments
Post a Comment