Hi Isabel,
I don’t believe there are any examples showing basic serial port operations on mangOH just yet, though there are plans to provide this as part of the tutorial series in the near future - see this post.
Regarding serial data, I can recommend these two pages which I found to be a good reference for information on Linux serial port programming:
- https://www.cmrr.umn.edu/~strupp/serial.html#2_5
- http://www.tldp.org/HOWTO/text/Serial-Programming-HOWTO
You can practically copy across the code from examples available on those pages and run them successfully on mangOH with little changes.
There are a few important notes you should be aware of though:
-
You need to make sure the UART is mapped as service 17 for Customer Linux application. See here - http://legato.io/legato-docs/latest/howToCustomizeUART.html
-
Ensure your Legato application has permission to Read and Write to the serial port(s). Add the following to your application’s .adef file and modify to suit your needs.
requires:
{
device:
{
// Get read and write access to the USB Host port.
// I.E. for use with a FTDI USB Serial Device
[rw] /dev/ttyUSB1 /dev/ttyUSB1
// Get read and write access to the UART1 port.
[rw] /dev/ttyHS0 /dev/ttyHS0
}
}
For example, If I had a USB serial device plugged into the USB Host port on mangOH, the application needs permission to read and write to /dev/ttyUSB1. Remove the device(s) you don’t need.
Cheers,
Raf