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

multiple ports #37

Closed
ghost opened this issue Feb 10, 2012 · 23 comments
Closed

multiple ports #37

ghost opened this issue Feb 10, 2012 · 23 comments
Milestone

Comments

@ghost
Copy link

ghost commented Feb 10, 2012

i experienced problems while reading from multiple ports simultaneously.
up to 4 ports everything worked fine, when adding a fifth port reading is strange.

Data is only received after another port sent data as well.

Some quick code to test:

var sp = new SerialPort("/dev/tty.USA49Wfd1P1.1", global.serialOptions);
sp.on("data", datalistener);

var sp2 = new SerialPort("/dev/tty.USA49Wfd1P2.2", global.serialOptions);
sp2.on("data", datalistener);

var sp3 = new SerialPort("/dev/tty.USA49Wfd2P1.1", global.serialOptions);
sp3.on("data", datalistener);

var sp4 = new SerialPort("/dev/tty.USA49Wfd2P2.2", global.serialOptions);
sp4.on("data", datalistener);

var sp5 = new SerialPort("/dev/tty.USA49Wfd1P3.3", global.serialOptions);
sp5.on("data", datalistener);

Did anyone got similiar results or got an idea how to fix this? thank you.

@robbles
Copy link

robbles commented Aug 19, 2012

I'm seeing the same issue. Up to 4 ports as well, then after that I start seeing strange issues like connections hanging.

This seems like a serious bug in node-serialport - has this been looked into at all?

@voodootikigod
Copy link
Collaborator

Given that the normal use case for serialport port is opening a single port, deeming this a "serious bug" is a bit dramatic. Can I get a bit of insight from both or one of you as to why you are opening multiple serialports in single process? Might help me with context as to what is going on. I have looked into this, but can't see anything glaringly obvious as to what is the matter. If you can't talk publicly about it, please contact me directly.

@robbles
Copy link

robbles commented Aug 19, 2012

Sorry, didn't mean to sound dramatic - I'm using node-serialport for a project in a hackathon and I haven't had a lot of sleep. You're right that this is a unusual use case - we're controlling a group of Bluetooth serial devices using node.

The reason I was concerned was just that I didn't see any mention of a hardcoded limit anywhere, and I thought it might be indicative of a more serious problem. I know for sure that more of these serial ports CAN be opened, since the workaround we used was to use several child processes to handle the serial ports.

Haven't had a chance to check out the test case that jewepasch posted, but I have enough serial devices right now to do so, so I can update you on that soon enough.

@voodootikigod
Copy link
Collaborator

No worries on the drama - fully appreciate the situation and thank you for the details.

The child process also supports more isolated control, so I would recommend that BUT that said, I want to track down the issue. I am a bit strapped for time right now, but should be able to debug it soon.

Thanks for the details.

Chris Williams

@voodootikigod (http://twitter.com/voodootikigod) | GitHub (http://github.com/voodootikigod)

The things I make that you should check out:
SaferAging (http://www.saferaging.com/) | JSConf (http://jsconf.com/) | PromoteJS (http://promotejs.com/) | Minute With (http://minutewith.com/)

Help me end the negativity on the internet, share this (http://jsconf.eu/2011/an_end_to_negativity.html).

On Sunday, August 19, 2012 at 7:06 PM, Rob O'Dwyer wrote:

Sorry, didn't mean to sound dramatic - I'm using node-serialport for a project in a hackathon and I haven't had a lot of sleep. You're right that this is a unusual use case - we're controlling a group of Bluetooth serial devices using node.
The reason I was concerned was just that I didn't see any mention of a hardcoded limit anywhere, and I thought it might be indicative of a more serious problem. I know for sure that more of these serial ports CAN be opened, since the workaround we used was to use several child processes to handle the serial ports.
Haven't had a chance to check out the test case that jewepasch posted, but I have enough serial devices right now to do so, so I can update you on that soon enough.


Reply to this email directly or view it on GitHub (#37 (comment)).

@ghost
Copy link
Author

ghost commented Feb 19, 2013

Same issue. I'm seeing a limit of 3 ports. Is there a solution, temporary or otherwise?

@JayBeavers
Copy link
Collaborator

I've scanned quickly through the javascript, linux, and windows code. I see nothing in these codebases which jumps out at me as limiting or slowing down when multiple serial ports are used.

However, assuming Linux is the OS, I have found known issues in the Serial-HOWTO guide for Linux. Among the notes are:

Number of Serial Ports Supported

If you have more than 4 (or possibly 2) serial ports, then you must insure that the kernel
knows this. It can be done by configuring the kernel when compiling or by a parameter
given to the kernel when it starts (boot-prompt or kernel command line).

Extremely Slow: Text appears on the screen slowly after long delays

It's likely mis-set/conflicting interrupts. Here are some of the symptoms which will happen the
first time you try to use a modem, terminal, or serial printer. In some cases you type
something but nothing appears on the screen until many seconds later. Only the last
character typed may show up.

I'd suggest that it is highly likely an OS or driver or device issue rather than an issue with this library. I'd recommend combing through the Serial-HOWTO article to see if you can find a solution there.

@robbles
Copy link

robbles commented Jul 19, 2013

@JayBeavers It's been a while since I touched the code related to this, but I was seeing this issue on both Linux and OS X.

I also have a hard time believing it's a kernel issue since I was able to work around the limit by simply forking a child process for each port.

I'll dig up the app I was working on and test it again. Maybe @jewepasch and I were running into the same issue with different causes, since I was using Bluetooth serial ports (is there an OS limit on those?).

@JayBeavers
Copy link
Collaborator

Fair enough, most of this doc was talking about the old 16550 days. Perhaps we're seeing issues at the device driver level or the bluetooth communications stack level.

@robbles, did you try reproducing the same environment using a different programming platform, e.g. talking to the serial ports via C directly?

@robbles
Copy link

robbles commented Jul 19, 2013

I did some testing of this using socat to create virtual serial ports.

I wrote a simple async python script that reads from 5 different serial ports (basically the equivalent of the original posted by jewepasch). It seems to work fine, but the node-serialport one shows ioctl errors, gets mangled data from the serial port and seems to buffer after the first line of data is received.

https://gist.github.com/robbles/6042075

If you want to try it out, just run the shell script and then run either the python or node script. The serialports are created as linked pairs of /tmp/ttysAN, /tmp/ttysBN.

@voodootikigod
Copy link
Collaborator

Awesome test case thanks will use it to debug!

On Friday, July 19, 2013, robbles wrote:

I did some testing of this using socathttp://justcheckingonall.wordpress.com/2009/06/09/howto-vsp-socat/to create virtual serial ports.

I wrote a simple async python script that reads from 5 different serial
ports (basically the equivalent of the original posted by jewepasch). It
seems to work fine, but the node-serialport one shows ioctl errors, gets
mangled data from the serial port and seems to buffer after the first line
of data is received.

https://gist.github.com/robbles/6042075

If you want to try it out, just run the shell script and then run either
the python or node script. The serialports are created as linked pairs of
/tmp/ttysAN, /tmp/ttysBN.


Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-21275840
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

Help me end the negativity on the internet, share
thishttp://jsconf.eu/2011/an_end_to_negativity.html
.

@JayBeavers
Copy link
Collaborator

@robbles, so if I'm following correctly, if I start writing bytes into /tmp/ttysB1, I will receive data on /tmp/ttysA1 and vice versa?

I started a test harness using mocha & chai under ~/test/*, but it requires an echo programmed Arduino to work. Do you think you could get this test to pass using socat instead? This test relies upon list() and pnpids, so it would either need to be modified to open the port directly or you would have to figure out how socat works with list() and modify the port filtering in the test.

To run test test, simply execute 'npm test'.

@robbles
Copy link

robbles commented Jul 23, 2013

@JayBeavers Yes, that's right. I left out that part of the test, sorry. You can just do echo XXX > /tmp/ttysB1 to send data to the paired serial port.

Sure, I'll give it a try. It doesn't look like the virtual ports show up the results from list(), so I'll probably just change it to search for the ones created by socat.

@Bobris
Copy link
Contributor

Bobris commented Nov 4, 2013

Just want to join with same problem. I have application which communicates in parallel with 4 USB serial ports. It works correctly on Windows, it hangs on Raspberry Pi. When I am connecting one by one so not 2 ports communicates in parallel it works correctly also on Raspberry Pi. All latest node.js 0.10.21 and serial port 1.2.3. Will probably need to use workaround with child processes :-(

@voodootikigod
Copy link
Collaborator

Can you provide example code?

On Monday, November 4, 2013, Boris Letocha wrote:

Just want to join with same problem. I have application which communicates
in parallel with 4 USB serial ports. It works correctly on Windows, it
hangs on Raspberry Pi. When I am connecting one by one so not 2 ports
communicates in parallel it works correctly also on Raspberry Pi. All
latest node.js 0.10.21 and serial port 1.2.3. Will probably need to use
workaround with child processes :-(


Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-27735307
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeeklyhttp://robotsweekly.com/

@Bobris
Copy link
Contributor

Bobris commented Nov 5, 2013

It is relatively nontrivial code (https://gist.github.com/Bobris/7325335) and you need that HW to be able to reproduce. On the other hand it definitely looked that problem is worsening with time, even when node process was restated multiple times. So I am not sure that problem is purely in software, could be hardware problem.

@JayBeavers
Copy link
Collaborator

#255 may have fixed this, do you still reproduce with the latest source code?

@Bobris
Copy link
Contributor

Bobris commented Nov 15, 2013

I can confirm that 1.2.5 version of SerialPort fixed this problem and multiple parallel serial connections works correctly on RaspberryPi. Congrats! (Even though I already switched to Intel NUC with my project).

@JayBeavers
Copy link
Collaborator

Works better on the Intel NUC now too :-)

@D1plo1d
Copy link

D1plo1d commented Dec 14, 2013

I'm still having issues using serialport 1.2.5 and node 0.10.20 with 2 serial ports each at a baudrate of 115200.

Data is received intermittently when I connect multiple devices whereas when I connect only 1 there isn't any problem receiving data.

I'm using serialport to control two 3D printers so admittedly I'm going to be sending and receiving more data then the average. Maybe that higher throughput is part of why I'm seeing this? More chances for some race condition to occur?

It seems to work randomly. I tried connecting both printers simultaneously using two instances of another program (pronsole) and they worked so the issue seems to be on node's side of things.

Since I have no idea how to troubleshoot the issue I'm probably going to go the child process route as well.

my code (sorry, mine is also not a trivial project): https://github.com/D1plo1d/construct-daemon/blob/develop/lib/drivers/abstract_serial_driver.coffee

@JayBeavers JayBeavers reopened this Jan 17, 2014
@JayBeavers
Copy link
Collaborator

@D1plo1d, two questions:

  • What is the environment (e.g. OS, version) in which you are seeing the problem?
  • It would be lovely if you could write a simplified test app that reproduces the problem you see. Then someone else can debug that simplified app and come back with a fix that you can test in your more complex environment. For example, when we were seeing memory leaks, I wrote a simple program that sent/received 'hello' in a tight loop that also exhibited the bug and then debugged that problem.

OK, it's really one question and one leading statement :-)

@D1plo1d
Copy link

D1plo1d commented Jan 17, 2014

@JayBeavers

  1. OSX 10.7.5, serialport 1.2.5 and node 0.10.20
  2. I'm honestly not sure how to reliably reproduce it. The problem seems intermittent and randomly so.

@reconbot
Copy link
Member

reconbot commented Apr 2, 2014

I'm going to close this due to age, but if you have any more trouble don't worry about reopening it. We'd love to solve the problem if it's within node-serialport but we'll need to pin it down.

@reconbot reconbot closed this as completed Apr 2, 2014
@happyiphone
Copy link

Found the same problem on my system today. I migrated from lubuntu with 7 ports (controlling different pieces of equipment in an automation system) and then I moved to Windows 8.1 on an intel NUC, after the first attempts to fix my code I realized that if I have 3 port declarations everything works wonderfully, just by adding an extra port declaration the ports (all of them stop working). I have a machine ready to be tested (code and connections, the code will LOOK like it works but in fact it isn't I can see the result of the commands on the different equipment in real time (sound, tvs, etc.) if needed, just let me know and I'll provide access to it.

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

7 participants