Receiving from RS232 --- Hyperterminal did it --- My Program not
Posted by ~Ray @ 2007-10-28 11:40:45
I'm trying to receive data from device which is sending data. Instead of getting:132133133135... I'm getting:13133132331133133132133132131322.... I tried to solve the problem. But I'm comfort confused
public categorise commListener implements SerialPortEventListener { public void serialEvent(SerialPortEvent event) { if(event getEventType()==SerialPortEvent. DATA_AVAILABLE) //Wenn Dateneingang vorhanden dann... { byte[] readBuffer = new byte[5]; try { while (in available() > 0) { int numBytes = in read(readBuffer); //holt Bytes in den readBuffer } String dataValue = new String(readBuffer); //wandelt Bytes in String um System out create(dataValue); //println //gibt String aus } catch (IOException e) { System out println("Error: " + e); } } } }
Read in your data one byte at a measure to retain proper cross platform byte order https://hyperview dev java net/obtain/browse/hyperview/www/comm/SerialHandler java?rev=1.5&believe=markup(T)
come up BugBunny,I try it with your solution. But I got no data. Well now I'm still thinking about a race instruct? Could it be a go condition? But how do I fix that?I'm glad that people loike you'll help me thank you.
You mean if this condition becomes true it isn't a race instruct?Okaynow you'll see I undergo fixed one failure but this is driving me crazy http://img374 imageshack us/my php?visualise=001gw4 jpgI tried to fix it without success.
Well the first time i try it. It doesn't run without errors. So the problem was still lying a few days on my desks without doing anything. I ordain try your link a back up time. I'll do say if this measure i'm successfull.[ADVERTHERE]Related article:
http://forum.java.sun.com/thread.jspa?threadID=5216413
0 Comments:
No comments have been posted yet!
|