-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
continuously writing to serial port returns results -1 with a USB to serial adapter #679
Comments
What returns -1? Our latest beta #733 exposes a bunch more errors that might help debug this problem. It also cleans up a lot of issues for osx and linux. Can you give it a try? |
The second argument passed to the This issue can be reproduced with the program below on a Raspberry Pi 2. To reproduce the error, a relatively large amount of data needs to be sent, 5000 bytes in this case. This results in the write callback being called many times, 2664 times in this case. The write callback should be a completion callback that's only called once. var SerialPort = require('serialport').SerialPort,
uart = new SerialPort('/dev/ttyAMA0', {baudRate: 9600});
uart.once('open', function () {
var count = 0;
uart.write(new Buffer(new Array(5000+1).join('a')), function (err, bytesWritten) {
count += 1;
console.log('count: ' + count + ', bytesWritten: ' + bytesWritten);
});
}); Here's is the typical output of a test run:
|
I have the exact same issue. @reconbot How would you send big data? Could you share an example. |
This is a problem with our write callback. This would cause high overhead On Wed, May 4, 2016, 12:27 PM Martin Guillon notifications@github.com
|
@farfromrefug @fivdi I've got a fix for the callback issue in #808 should save a lot of cpu when sending large amounts of data if you wouldn't mind testing it I'd be very grateful. You can test this branch by changing your package.json to include @ruizeng I don't think we've addressed your issue. The |
@reconbot the branch installs successfully, the write completion callback is now only called once (which is correct,) but the
|
@fivdi yes there is no more 'sent' argument to the write callback |
@reconbot still getting high cpu usage on OSX. I am sending a 2.7mo image. |
@reconbot I have upgraded the package to the newest version and the issue never happens again. Seems like your fix works well. |
@fivdi I've removed the bytes written parameter, it will always be all the bytes |
@reconbot Will the removal of |
Yeah it will Francis Gulotta On Wed, May 18, 2016 at 2:40 PM, Brian Cooke notifications@github.com
|
I'm using a ch430 usb to serial adapter to connect to my MCU through serial port. Below is my environment:
my test code:
And my MCU will also continuously send data to serial port.
The test program works well in a few seconds, but then the write callback 'writeCB' returns results -1 with no error. The MCU receives nothing, either. I have to change my test environment, and the result is here:
pyserial
), and it works perfectly well.CP2102
, it came out the same problem asCH430
So I guess maybe there are bugs in unix/linux environment with usb to serial adapter? I wonder if any one faces the same problem with me.
The text was updated successfully, but these errors were encountered: