Author Topic: Serial Ports and Java Headaches  (Read 13220 times)

Z.K.

  • Member
  • ***
  • Posts: 1
Serial Ports and Java Headaches
« on: May 15, 2011, 06:33:10 pm »
I have been trying for several weeks now to get Java to work with a serial device.  It is an embedded device that implements a virtual serial port through USB.  It works great in putty or even in a C# program I wrote, but Java is a real pain and I have yet to make it work.  I am using rxtx serial library in Windows 7 and I can get it to work with a loopback device, but trying to send a command to the device I am trying to use results in no data being sent back and I am not sure why.

I would be really great if Serial Port Complete had Java code as well.  I have tried all the examples on the Internet I could find, but nothing seems to work.  The device I am trying to work with is called a Universal Bit Whacker (UBW) from www.sparkfun.com.  I send it a "V" command and it should return the firmware version, but nothing comes back for some reason.  If anyone has any ideas, that would be great. 

I will try using my Arduino and see if I have any better luck with that.

 ???

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Ports and Java Headaches
« Reply #1 on: May 15, 2011, 09:28:32 pm »
No matter what language you're using, serial ports boil down to port address, outputs and inputs, parameters, and flow control.

Be sure you're accessing the correct port on the PC.

Each output should connect to an input on the other end: TX to RX, CTS to RTS, DTR to DSR. Use a straight-through or null-modem cable as needed. If you have it working using the same PC but another language, the cable is correct.

Be sure the number of data, stop, and parity bits match on both ends.

Use the same flow-control method on both ends.

Also see:

http://rxtx.qbang.org/wiki/index.php/Writing_%22Hello_World%22_to_a_USB_to_serial_converter

Jan