Sample to send /receive serial data from RS232 and send it to 3G


#1

Hello

Where can I get a basic sample getting data from the serial port RS232 and send it over 3G and vice versa?

Typical application from customers will be read MODBUS data from PLC and send it over 3G

I can´t find any sample with this basic function

Thanks

Isabel


#2

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:

  1. https://www.cmrr.umn.edu/~strupp/serial.html#2_5
  2. 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:

  1. 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

  2. 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


#3

Hi Isabel,

I think Raf did a good job of providing some information about serial communication. Can you provide some more detail on what magnitude of data you expect to be sending over the 3G network and whether there is an existing network protocol that you intend to use? With that information, I might be able to give some suggestions.