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.
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?
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
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);
}
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.
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.