todbot / arduino-serial Goto Github PK
View Code? Open in Web Editor NEWExample C and Java host code to talking to an arduino or other "serial" device
Home Page: http://todbot.com/blog/
License: MIT License
Example C and Java host code to talking to an arduino or other "serial" device
Home Page: http://todbot.com/blog/
License: MIT License
I am using arduino-serial for a cross platform application. It worked successfully on OS X, but when I compile it on Windows 7 with Cygwin and try to connect to the arduino with the command
$ ./arduino-serial -b 115200 -p /dev/ttyS2 -r
I am met with the error "Device disconnected. : Resource temporarily unavailable". I am sure the baud rate is correct and the Arduino is connected to COM3, which I found translates to /dev/ttyS2 for cygwin. The only changes I made to the code itself was encapsulating the '-r' (read from serial) functionality in a while loop so it would continuously print output from serial. Any suggestions?
Sorry to border you here, while you lib works amazingly well, it has a small compilation problem if you compile on a c++ code/compiler. May a suggest to warp the function signatures around a:
extern "C" {
.
.
.
}
Except for that, your library is perfect and really solved my serial communication problems with Arduino, so thank you for that.
PS: without the extern "C", the code will not compile/link, but the proposed solution removes all the problems
Hello,
Flag -q fully minimize output only if it first parameter in cmd-string.
for example:
correct: root@raspberrypi:/home/trash/arduino-serial-master# ./arduino-serial -q -p /dev/ttyACM0 -S extHumidity01 -r
11.00
incorrect root@raspberrypi:/home/trash/arduino-serial-master# ./arduino-serial -p /dev/ttyACM0 -S extHumidity01 -r -q
opened port /dev/ttyACM0
send string:extHumidity01
read string:11.40
Thank you,
Alexander
I have problems reading continuous data stream. I'm not getting the whole line who was send but only a fraction of it, depending on the time the command was send. Is there a workaround/command that only displays the read string params between two newlines?
In some distribution the \n character is substituted with \r character in the input stream beacause the INLCR and ICRNL are not disabled in thetoptions.c_iflag
in theint serialport_init(const char* serialport, int baud)
function.
The correction is to change the line 74 in arduino-serial-lib.c:
toptions.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off s/w flow ctrl
whith this line
toptions.c_iflag &= ~(IXON | IXOFF | IXANY | INLCR | ICRNL); // turn off s/w flow ctrl
how to send large strings (> 63 characters)
I need i2c scanner with esp32 can you help I will pay
There isn't a COPYING or LICENSE file in this repo, so technically, this is not really open source even though it's available for people to see. Would you be willing to release this code under an open source license like MIT, BSD or LGPL so people can legally use and redistribute it?
Is there any way to detect disconnection of device? Right now, I can't see any way library offers this, so there is no way to distinguish between disconnection and timeout. I thought that if( n==-1) return -1; // couldn't read
at line 127 of the library would fire when device is disconnected, but no luck with that - read
returns 0 in that case.
Hi,
I use this lib to do some tasks and this next line give me lot of problems :
arduino-serial/arduino-serial-lib.c
Line 148 in e5958dc
Only because write()
method on my posix system (RPi 3 - Linux 3 - Raspbian 8) is asynchrone and doesn't wait entire writing of string on serial port (seem legit). The reason of flush()
The solution is easy, program should wait entire writing (some milliseconds) :
millisecondsToWait = ceil( totalBytes * protocolBitsLength / baudsSpeed / 1000 )
usleep( millisecondsToWait );
instead of sleep 2;
That give waiting of 6 milliseconds for a MySensors gateway with a speed of 38400 bauds.
Yeah, tested with sniffing our serial port from hardware, without sleep()
I have row of led if I use
screen /dev/tty.usbmodem1411 9600
type my commands either
g, r, f
it works
But if I type
./arduino-serial -b 9600 -p /dev/tty.usbmodem1411 -s g
lights turn green
./arduino-serial -b 9600 -p /dev/tty.usbmodem1411 -s r
Lights do nothing or anything.
Thank you
serialport_read_until() method needs some optimization, in particular these 2 fixes!
char b[1];
change to char b;
int n = read(fd, b, 1);
change to int n = read(fd, &b, 1);
buf[i] = b[0];
change to buf[i] = b;
while( b[0] != until ...
change to while( b != until ...
while( ... && i < buf_max ...
change to while( ... && i+1 < buf_max ...
Unless the documentation says that buf_max should be one less than the size of the buffer (which would be counterintuitive and error-prone)
Also, since i is checked at the end, even with this fix, the code will still store one byte if you pass in buf_max == 0 (but without the fix it will store two bytes). So that's another bug.
https://github.com/netpipe/Arduino-Projects/tree/master/SerialIO/QArduino-serial i have this started too if anyone would like to add it to the repository.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.