Guys,
Ok, one more final update for the night… I have had some limited success with reading a USB port and none with reading a UART port. The UART port is actually the goal of this project as I am currently using python to proxy information to java via a socket.
Here is what I have done:
- Installed newest distro (not sure this made a difference, but needed to be done anyway)
- opkg update
- opkg install openjdk-6-jre
- opkg install rxtx
4a. I had to copy all files from /usr/lib/jni/librxtx* to /usr/lib/jvm/java-6-openjdk/jre/lib/arm to make the libraries work at all. This was not done by the install rxtx above. Probably a better way todo this with a link if someone would like to comment on that.
- Run my program which basically just spits out the com ports. Output reads:
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
RXTX Warning: Removing stale lock file. /var/lock/LCK…ttyUSB0
/dev/ttyUSB0 - Serial
Note: Changing the version of the jar file doesn’t get rid of the warning regardless. However, that is the USB device that is hooked up. It is spitting out a 9600 baud GPS signal from a UART to RS232 serial converter.
- When I run this on windows I come up with:
$GPRMC,053000.004,V,4035.6940,N,12223.2450,W,0.00,0.00,300512,N69
$GPVTG,0.00,T,M,0.00,N,0.00,K,N32
$GPGGA,053001.004,4035.6940,N,12223.2450,W,0,0,172.8,M,-22.8,M,71
$GPGLL,4035.6940,N,12223.2450,W,053001.004,V,N5A
$GPGSA,A,1,1E
$GPGSV,1,1,01,25,2578
$GPRMC,053001.004,V,4035.6940,N,12223.2450,W,0.00,0.00,300512,N68
$GPVTG,0.00,T,M,0.00,N,0.00,K,N32
- However, when I change only the port ID to /dev/ttyUSB0 it comes up with the following on the BeagleBone:
GGL43.90,22.40W54104VN5E.,M-28M,7
GGAA1,1
$PT,00,M00,00,*2325,00,.0301,N6
GGA,542044364,22.45,128,2.,*6
$PS,*E$PS,079
GRC03004V43.90,22.40W.000,05,*F
GGL43.90,22.40W54304VN5C.,M-28M,7
GGAA1,1
It’s obviously getting something and parts of it are right. However, it’s not getting it correctly. I would post all my code up here, but it’s several files. Here are the biggies though:
This code spins up some stuff:
inBuffer = new StringBuffer();
outBuffer = new StringBuffer();
portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/ttyUSB0");
CommPort commPort = portIdentifier.open(“test”, 2000);
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
reader = new SerialReader(serialPort.getInputStream(), inBuffer);
writer = new SerialWriter(serialPort.getOutputStream(), outBuffer);
new Thread(reader).start();
new Thread(writer).start();
Then later this code reads it. This is the thread that gets started:
byte[] buffer = new byte[1024];
int len = -1;
try {
while ((len = this.in.read(buffer)) > -1) {
if (pause) {
continue;
}
if(stop) {
return;
}
String str = new String(buffer, 0, len);
System.out.print(str);
inBuffer.append(str);
}
} catch (IOException e) {
e.printStackTrace();
}
If anyone could provide insight into getting a direct UART connection or even fixing this problem I would grateful. I will be spending some more time with this and update you guys if anything comes up.
Cheers,
Gregg