Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:11:47+00:00 2026-05-17T01:11:47+00:00

I’m currently testing a Java/MySQL POS system I’ve written for a small bar, and

  • 0

I’m currently testing a Java/MySQL POS system I’ve written for a small bar, and am having problems with the cash draw.

The cash drawer has an RJ11 plug connected via a USB->Serial box, and writing any data to the device triggers the draw to open.

I’m having problems with RXTX, and wasn’t sure if it was my code, the library or drivers for the device?

Ideally, I’d like the connection to be created when a user logs in to the system, and closed when they log out, but for the moment, the code just opens the connection, writes the data and closes when a sale is rung up (there is a 1-2 second delay between hitting the save button and the drawer opening, which is frustrating).

When the app first starts, the drawer works fine for a few sales (haven’t identified a pattern), but then stops working. It shows a range of exceptions occurring, mixing either NoSuchPort, PortInUse or just a plain AccessDenied message. Usually, restarting the app and disconnecting/reconnecting the USB will get it working again for a few more sales.

I can connect to the device using HyperTerminal, and it works consistently, without any 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 a few different settings, trying to mimic as close as I can the settings HyperTerminal uses (by checking PortMon), but still not working.

Any suggestions would be greatly appreciated!

Thanks,
Ryan.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:11:47+00:00Added an answer on May 17, 2026 at 1:11 am

    Cannot find anything wrong with the code, but I can suggest some starting points for debugging:

    • Try the same code with Sun’s (errr.. Oracle’s) javax.comm implementation. The Windows version is no longer available for download from their site, but it can still be found in other places. Even if you don’t want to use this implementation in your final setup, it might help you find the problem. There are also other alternatives such as SerialIO.

    • Use com0com to install a virtual com port. Enable logging (see last question in the README.txt file). Compare the logs when you use your code with the logs you get when using HyperTerminal, and look for any differences.

    • Try a different serial -> USB converter. In my experience, many of these don’t implement RS232 properly, or have plenty of bugs.

    Edit:

    If you discover that this is actually a rxtx bug, but for some reason don’t want to switch to another javax.comm implementation (I’ve seen this happen 🙂 here are some additional hints that may be useful (I would try the above suggestions first anyway):

    • Are the calls to setInputBufferSize, setOutputBufferSize required? Try removing them. Does the device actually use XON/XOFF flow control? If not, try setting flow control to none. Does the device require RTS disabled? If not, remove this line as well. Also, try to set the serial port params before opening the output stream. Of course, none of this should make any difference, but you might be triggering some rxtx bug.

    • Is the problem related to opening and closing the port in sequence several times? You could try to keep the port always open. On each sale, just do:

      outputStream.write("k".getBytes());
      outputStream.flush();
      

      And see if the problem still reproduces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.