I am porting an app to an epic. The is written in C++ and uses one or more serial ports to talk to other devices. Is there a preferred/recommended way to access the serial ports (GRV-CSERI-4 card)?
I don’t have an EPIC serial module on hand just this minute (let me see if I can find one), but I am just wondering about that device name… /dev/ttySerSys0
Is that what an ‘ls’ of the /dev/ directory shows as its name?
(In other words, I am assuming you have a shell license installed on your EPIC and I am wondering what the Linux device name is for the serial ports on the module).
Ah, but that’s the fun part… they are…
The first 4 slots on EPIC have a USB bus under them. That’s why you have to put the serial module in the first 4 slots only.
Hmm, not off the top of my head no…
Did you try the ttySerMod0.0? I wonder what its linked to (blue means its a sym link).
I honestly expected the ttyUSB0 to work since its the baseline that everything else is built off.
Ok, so here are some things that the software engineers said to try that really should show the way forward…
Firstly; stty -F /dev/ttySerMod0.0
This tries to open the file handle and read its configuration so if there is a permissions problem or the filename is wrong, it’ll tell you.
For best results, this should be done as the user that is going to run your C++ code.
If you don’t know who your C++ user is, I am a little lost, you should really know what user your code is running as.
If you are logged into shell as someone else, then sudo su username will let you log in as the user that will be running the C++ code (swap out ‘username’ for the C++ user of course).
From that then we can continue…
The key is the error code that you mention, the -1.
When open returns -1, it sets errno with the cause of the failure. Which is exactly what @philip was correctly asking about.
The errno variable and strerror() function can then be used to find out more about the error. For example, if you compile and execute the following file, test.c, on your PR1 you should get:
So it’s likely you are trying to run your program as the default shell access user, which is not a member of the dialout group and therefore doesn’t have permission to access the serial ports.
If this is the case, then you need to either:
use sudo to run your program
add the shell access user to the dialout group
run the program in the context of a user that is a member of the dialout group (e.g dev)