![]() |
|
[Arduino] Serial Communication Linux |
Ariesnl
Member #2,902
November 2002
![]() |
Hey everyone, Any Ideas ? Thanks ! 1#include <libserial/SerialStream.h>
2#include <iostream>
3
4using namespace LibSerial;
5
6SerialStream g_StreamSerial;
7
8bool g_blClose = false;
9
10int main()
11{
12 g_StreamSerial.Open("/dev/ttyACMO");
13 if (g_StreamSerial.good())
14 {
15 g_StreamSerial.SetBaudRate(BaudRate::BAUD_9600);
16 if (g_StreamSerial.good())
17 {
18 char ch;
19
20 while(!g_blClose)
21 {
22
23 g_StreamSerial >> ch;
24 std::cout << ch;
25 }
26 }
27 else
28 {
29 std::cout << "Could not set baud rate";
30 }
31
32
33 }
34 else
35 {
36 std::cout << "Could not open port";
37 }
38
39 g_StreamSerial.Close();
40 return 0;
41}
Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Dizzy Egg
Member #10,824
March 2009
![]() |
Are you running it with sudo priveliges?
---------------------------------------------------- |
Ariesnl
Member #2,902
November 2002
![]() |
No, but would that be necessary ? Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Peter Hull
Member #1,136
March 2001
|
Maybe try .IsOpen() instead of .good() and see if an error message becomes apparent? edit - also are you opening "/dev/ttyACMO" with a letter "O" or "/dev/ttyACM0" with a zero? I think the latter is correct.
|
Ariesnl
Member #2,902
November 2002
![]() |
Makes no difference, and yes the last char is a zero ;-) Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Peter Hull
Member #1,136
March 2001
|
Dizzy Egg
Member #10,824
March 2009
![]() |
Have you given yourself permission to acces the ports? i.e. sudo usermod -a -G dialout <your username>
---------------------------------------------------- |
Peter Hull
Member #1,136
March 2001
|
Surely if it works from screen and from the Arduino IDE, the permissions are OK?
|
|