lxbzmy / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
0 stars 0 forks source link

SerialPortEventListener hangs #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. initialize a port with socat -d -d PTY: PTY:
2. copy over the Event mask & SerialPortEventListener interface example from 
the projects' site
3. create and start a simple c program which prints data to the serial device 
periodically

What is the expected output? What do you see instead?
Since I modified the example to print out everything (converted to string) when 
the listener enters if(event.isRXCHAR()) I expected output from the running 
java program while the C program is also running (generating input on the port).
What happened instead is that the listener program printed out about 20-30 
events while the C program was still running.

What version of the product are you using? On what operating system?
Ubuntu 12.04
jSSC-0.9.0

Please provide any additional information below:
As I said above I modified the example to:

if (event.isRXCHAR()) {//If data is available
    try {
        byte buffer[] = serialPort.readBytes();
        if (buffer != null) {
            System.out.println(new String(buffer));
        }
    } catch (SerialPortException ex) {
        System.out.println(ex);
    }
}

the rest of the program is unchanged, except that I changed the port name to 
what socat opened (/dev/pts/6).

I also include the C program below, which I used to generate data and sent that 
to the port.

Original issue reported on code.google.com by ako...@gmail.com on 18 Dec 2012 at 3:33

GoogleCodeExporter commented 9 years ago

Original comment by ako...@gmail.com on 18 Dec 2012 at 3:34

Attachments:

GoogleCodeExporter commented 9 years ago
I could't reproduce this bug with this socat init string that you wrote: 

socat -d -d PTY: PTY:

I don't receive any event with this settings. But when I run socat with:

-d -d pty,raw,echo=0 pty,raw,echo=0

All works fine without any problems.

Original comment by scream3r.org@gmail.com on 15 Mar 2013 at 1:11