serial-port
serial-port copied to clipboard
Ubuntu 14.04 freezes when reading from Arduino using serialstream class
Hi, I am using the serial stream class to read from an Arduino over serial port. "/dev/ttyACM0" at 115200 on Ubuntu 14.04.3 LTS on an intel NUC i7. The code works fine but after running for about 15-20 hours all screens freeze on the display. All other processes and services are running fine on the background consuming the expected CPU cycles. I check that using "top ". I modified the serial stream code to read on a while( 1 ) loop without any sleep. I am assuming the class does a async read so I do not need a sleep. Putting a larger sleep gives unexpected latencies. Please advice, it may not be a problem in the code/ boost but if you have any suggestions that may be very helpful. Should I be using the async code example/ class instead ? I could share the code etc if needed.
Also, what kind of license do you have for the code ? It would be great if you could update the github page with that.
- Best cn.
Hi, it's been a while since I've written that code, but the read loop is this https://github.com/fedetft/serial-port/blob/master/6_stream/serialstream.cpp#L148 Try to put a cout or something at line 163, if you get a continuous stream of these cout (not just one or two), that may be the loop consuming your resources. In that case also have a look at https://github.com/fedetft/serial-port/blob/master/6_stream/serialstream.cpp#L148 as this is the callback function called by the run_one() call when something is received.
Hi , So I think you meant the ASIO code which has the callback. I used that and it seemed to solve the problem. What is the kind of license that you have on the code ? Thanks.
Hi, I did not understand how you fixed the problem.
For what concerns the license, as written in the sources, the code is licensed under the Boost Software License, Version 1.0. Which is the same license of the boost libraries.