How to send and receive data using UART2 (RS232) interface

Hi
I am having mangOH green board (WP8548) with legato Developer studio 5
I want to send and receive some data through UART2 (from RS232 terminal)
Which api need to be used in Developer studio or any sample code for Uart2 communication ?

Hi,
I am using le_tty api for uart communication.
out of these api, first I am using le_tty_open() method and then other api methods to set all baudrate, flow control, parity, stop bits etc.
after that I have used write method to send data and read to receive data.

But my application get stopped at

le_tty_Open(“/dev/ttyHSL1”,O_RDWR);

with error:

LE_FILENAME le_tty_Open() 231 | Error opening serial device ‘/dev/ttyHSL1’: No such file or directory

I have also tried with /dev/ttyAT , but same error.
I have also tried below command on terminal and then executed application, but same error persist.

echo -e “AT!MAPUART=17,1\r” > /dev/ttyAT
reboot

where I am doing wrong ? please suggest me solution

Hi @rups

If you’re running the app as ‘sandboxed’, you will need to request read/write acces to the device in your .adef file.

requires:
{
    device:
    {
        // read and write access to the UART2 port.
        [rw]    /dev/ttyHSL1   /dev/ttyHSL1
    }
}

Alternately, you can try running the app unsandboxed:

sandboxed: false

Cheers,
Raf

HI,
I can able to Transmit and receive data over Uart , i need a sample code to send a file over UART any once can guide me How to transmit a file ove UART

You can use attached lrz binary.
Here is an example to transfer file via UART console:

  1. transfer this lrz binary to /tmp of module by WINSCP
  2. cd /tmp; chmod 777 ./lrz;
  3. ./lrz -X cwe </dev/ttyHSL1 >/dev/ttyHSL1
  4. In tera term, File → Transfer → XMODEM → tick 1K box → choose the file you want to transfer.
  5. the file will be in /tmp with filename “cwe”.

lrz (202.7 KB)

Through C program how can we send a file ???

@Kalai ,

From your question do I understand it correctly that you are looking for a basic C program to read and write to UART 2 in that case you can check the below link for a basic program Serial Port Programming on Linux | xanthium enterprises

For using UART 2 in linux application you will need to configure it with AT!MAPUART=17,2 and then reset the device and use the correct /dev/ttyHS1 port in your C Code.

Hope this helps

you can refer to the source code of lrz and port to your code.

Or you can use system() API to call the lrz binary program.