How to start UART communication on UART1 port ie pin(8,10) on mangOH red using WP7502?


#1

Im new to these fascinating systmes any help would be appreciated.

Im stuck with the requirement of transfering GPS co ordinates via UART port although I did mange to pull the GPS co ordinates I found no precise guidance for using UART port. A sample code for using the UART and how to enable the port on the system would help me a lot. Thank you.


#2

I have an application(attached) to use UART2 to transfer data to TCP server.
Maybe you can take it as reference.
UART_TCP_Demo.docx (101.7 KB)


#3

Hi @jyijyi,

Thanks for making time to reply I did go through the content of your document and it was helpful can you forward me the source code to tranfer data via UART1?

Thanks in advance.


#4

I don’t have it.
But probably you can do the following modification based on the previous document:

  1. AT!MAPUART=17,1
  2. after reboot, probably there will be new port /dev/HS0
  3. in Component.cdef , change to the following:
    [rw] /dev/ttyHS0 /dev/
  4. in UART_TCP_Demo1Component.c, change the port :

fd1=OpenPort("/dev/ttyHS0");


#5

@jyijyi

just to be clear does UART1 stands for the pins 10,8 ? If no whats the port name for pin 10,8 UART


#6

I checked Product technical specification, pin 10 is GPIO2 and pin 8 is UART1_DCD.
Are you using the correct pin?


#7

@jyijyi

This came in when I searched pin diagram in its associated documents also after enering the command ATMAPUART=10,8 I did find this at /dev >> /dev/ttyHSL1

PIN_OUTS


#8

I don’t think you can enter AT!MAPUART=10,8
there is no such option in the AT command user guide.


#9

@jyijyi

Are there any options inorder to utilise pin 8,10 as UART? Since the document shows it as UART port. If not whats the alternative for using UART ?


#10

I believe pin 8 and 10 here are referring to the IOT connector instead of the pin 8 and 10 of WP8 module.


#11

Pin 8,10 are from CN307 of the mangOH red board.


#12

I saw CN307 pin 8 and 10 are connected to U307 FXMA108 and the other side is UART1 RX and UART1 TX.


#13

Hi @jyijyi

I did manage to get /dev/ttyHS0 by using the command “uartMode set 1 app” which pin of CN307 is it connected to?
In addition to this I did manage to run this code >>>

        #include "legato.h"
        #include <termios.h>
        #include <unistd.h>
        int open_uart1 (  char *dev)
        { 
         int     fd;
         fd = open (dev, O_RDWR | O_NOCTTY | O_NDELAY);
         struct termios options;
         // The old way. Let's not change baud settings
         fcntl (fd, F_SETFL, 0);
         // get the parameters
          tcgetattr (fd, &options);
         // Set the baud rates to 115200...
         cfsetispeed(&options, B115200);
         cfsetospeed(&options, B115200);
         // Enable the receiver and set local mode...
         options.c_cflag |= (CLOCAL | CREAD);
         // No parity (8N1):
         options.c_cflag &= ~PARENB;
         options.c_cflag &= ~CSTOPB;
         options.c_cflag &= ~CSIZE;
         options.c_cflag |= CS8;
         // enable hardware flow control (CNEW_RTCCTS)
         // options.c_cflag |= CRTSCTS;
         // if(hw_handshake)
         // Disable the hardware flow control for use with mangOH RED
         options.c_cflag &= ~CRTSCTS;

         // set raw input
           options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
           options.c_iflag &= ~(INLCR | ICRNL | IGNCR);

           // set raw output
          options.c_oflag &= ~OPOST;
          options.c_oflag &= ~OLCUC;
          options.c_oflag &= ~ONLRET;
          options.c_oflag &= ~ONOCR;
          options.c_oflag &= ~OCRNL;

         // Set the new options for the port...
          tcsetattr (fd, TCSANOW, &options);


          return fd;
          }


          void write_uart1 (int fd,char *cmd)
         {
             //	fd_set  rfds;
            //	struct timeval timeout;
         int     wrote = 0;
           	wrote = write (fd, cmd, strlen (cmd));
        	  LE_INFO("wrote  %d ",wrote);
          }

        void read_uart1(void)
       {
      //There was no read option though
        }

        COMPONENT_INIT
       {
           LE_INFO("Hello, world.");
          int serial_fd,i=0;
         int     wrote = 0;
           serial_fd= open_uart1("/dev/ttyHS0");
           while(i<60)
              {
              	write_uart1(serial_fd,"Hello how are you today?\r\n");
            	LE_INFO("Hello how are you today?");

                   //	wrote = write (serial_fd,"Hello how are you today?\r\n", strlen ("Hello how are 
                you today?\r\n"));
		             LE_INFO("wrote  %d ",wrote);
	                 i++;

                   	sleep(1);

                     }

}


#14

didn’t you attach the picture saying pin 8 and 10 of CN307?


#15

@jyijyi

I did but theres no data from that port.


#16

did you disable the hardware flow control inside the application?
You might also try UART2 first to verify your code.


#17

@jyijyi

Im sorry for dragging this long and I really appreciate the time and the effort you put in to answer my querries. I have no knowledge about hardware flow control and methods involved in enabling /disabling them. Can you please elobarate or guide me through this one. Thank you.


#18

seems you already disable the hardware flow control for CTS/RTS pin as I can see
options.c_cflag &= ~CRTSCTS; /* HW flow control off */

What is the current value of AT!MAPUART?

Also I suggest you try on UART2 as the mangOH Red board already have the USB to UART chip and you can connect to PC and see the data in UART2.


#19

@jyijyi

Thanks again for replying

AT!MAPUART?

!MAPUART: 17,16

The current requirement is that I need the usb port for other application hence I should handle UART via this 8,10 pins


#20

I understand you need UART2 for other application. But currently we need to verify your code if it is working. You can disconnect other application first.
But be careful that after settting AT!MAPUART=17,2, there will not more UART2 console. Make sure you can talk to the module via USB ECM port before this.