Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data isn't read from a PTY #2

Open
kidwm opened this issue Jan 30, 2016 · 5 comments
Open

Data isn't read from a PTY #2

kidwm opened this issue Jan 30, 2016 · 5 comments
Labels

Comments

@kidwm
Copy link

kidwm commented Jan 30, 2016

https://nodejs.org/api/stream.html#stream_event_data

Or how should I get data from serial port with serialport-stream?

@edef1c
Copy link
Collaborator

edef1c commented Jan 31, 2016

It's a readable stream — it should emit data events just fine if you listen for them…?

@edef1c edef1c added the invalid label Jan 31, 2016
@edef1c
Copy link
Collaborator

edef1c commented Jan 31, 2016

Just checked, data events work fine.

@edef1c edef1c closed this as completed Jan 31, 2016
@kidwm
Copy link
Author

kidwm commented Feb 1, 2016

Thanks for checking, I used socat to test my code:

try {
    fs.accessSync(path, fs.F_OK);
    port = new Serial(path, 9600);
    port.on('open', function(){
        console.log('serial path: ' + path);
    });
    port.on('data', function(chunk){
        console.log(chunk);
    });
} catch (error) {
    if (error.code === 'ENOENT') console.log('serial path: ' + path + ' is not available');
}

I could see the data I pushed into /dev/pts/1 in /dev/pts/2 with gtkterm, but got nothing with this code snippet, did I do something wrong?

@edef1c edef1c reopened this Feb 3, 2016
@edef1c
Copy link
Collaborator

edef1c commented Feb 3, 2016

Welp, that's a pickle — mind helping me repro this? I'm not entirely sure how to get a PTY pair set up like that.
I've been considering using a net.Socket instead of the current fs.ReadStream/fs.WriteStream hack, which is how node core handles TTYs (it's the only way of having a duplex fd).

So far I haven't done that because:

  • I didn't have a case where the current approach didn't work
  • Nobody else seemed to be using this module much

Neither of those seem to be true now, so if I can reproduce this easily for testing, I could get started on that. (heck, maybe I could even write some integration tests using PTY pairs!)

@edef1c edef1c added bug and removed invalid labels Feb 3, 2016
@edef1c edef1c changed the title support 'data' event Data isn't read from a PTY Feb 3, 2016
@kidwm
Copy link
Author

kidwm commented Feb 4, 2016

Sure, this is my current test command:

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

I've used this to testing node-serialport before trying serialport-stream.
Please let me know if need other further help, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants