serial communication in GPS and mini2440

shine
hey! successfully i got output of simple hello application on mini2440. but
now i have written one GPS code using ttySAC1 but it is showing no data on
mini 2440 but on desktop linux output is ok...
plz tel me the solution???

davef
First I'd look in /dev to see if you have a device node for ttySAC1.  If
not, make one.

shine
THANKS!!! But node is there on my ARM9 Board and desktop Linux.  Now what i
will do???

davef
The next step is to ensure that ttySAC1 has 666 permissions.

I have a line in my startup script:

chmod 666 /dev/ttySAC1

What is the permission on you ttySAC1?

shine
My board is also having same permissions..........

Juergen Beisert
Did you honor the fact that the corresponding ttySAC1 hardware is TTL only?
How did you connect the GPS modem to your ttySAC1 interface?

shine
My GPS module is having both TTL and RS232 Connections....

shine
I am using ttySAC1 with 115200 baud rate. my code for GPS is executing on
desktop linux (ttyS0) but it is not coming on mini 2440, My GPS Module is
having 2 switches one is for TTL AND other is RS232. I m using TTL with
ttySAC1 but it is showing no data...........
why???

davef
How is this data going to be displayed?  What program or application are
you running to process the GPS strings and display whatever you want on the
touchscreen?

Or have you written a Qt application that runs on the desktop, but when
ported to the mini2440 does not run . . . for example?

shine
ya! i hv written this code for the GPS , Only to see original data:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <fcntl.h>      // open() close()
#include <unistd.h>     // read() write()

#include <termios.h>    // set baud rate

#include <fcntl.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>

#define DEVICE_TTYS "/dev/ttySAC1"


#define BAUD_RATE_115200 B115200

#define FUNC_RUN                0
#define FUNC_NOT_RUN            1

#define ORG_GPS    1
#define SEL_GPGGA  2
#define SEL_GPGLL  3
#define SEL_GPGSA  4
#define SEL_GPGSV  5
#define SEL_GPRMC  6
#define SEL_GPVTG  7
#define FUNC_QUIT  8

//------------------------------------- read datas from GPS
-------------------------------------------------
// succese return 1
// error   return 0
int read_GPS_datas(int fd, char *rcv_buf)
{
  int retval;
        fd_set rfds;
        struct timeval tv;

        int ret,pos;

        tv.tv_sec = 1;
        tv.tv_usec = 0;

        pos = 0; // point to rceeive buf

        while (1)
        {
                FD_ZERO(&rfds);
                FD_SET(fd, &rfds);

                retval = select(fd+1 , &rfds, NULL, NULL, &tv);

                if (retval == -1)
                {
                        perror("select()");
                        break;
                }
                else if (retval)
                {// pan duan shi fou hai you shu ju
                        ret = read(fd, rcv_buf+pos, 2048);
                        pos += ret;
                        if (rcv_buf[pos-2] == '\r' && rcv_buf[pos-1] ==
'\n')
                        {
                                FD_ZERO(&rfds);
                                FD_SET(fd, &rfds);

                                retval = select(fd+1 , &rfds, NULL, NULL,
&tv);

                                if (!retval) break;// if no datas, break
                        }
                }
                else
                {
                        printf("No data\n");
                        break;
                }
        }

        return 1;
} // end read_GPS_datas

//------------------------------------- print
---------------------------------------------------------------
void print_prompt(void)
{
        printf ("Select what you want to read:\n");
        printf ("1 : Original GPS datas\n");
        printf ("2 : GPGGA\n");
        printf ("3 : GPGLL\n");
        printf ("4 : GPGSA\n");
        printf ("5 : GPGSV\n");
        printf ("6 : GPRMC\n");
  printf ("7 : GPVTG\n");
  printf ("8 : Quit\n");
        printf (">");
} // end print_prompt

//------------------------------------- FUNCTIONS ABOUT GPS
-------------------------------------------------
//------------------------------------- FUNCTION 1 show all receive signal
----------------------------------
void GPS_original_signal(int fd)
{
  char rcv_buf[2048];

  while (1)
  {
    bzero(rcv_buf,sizeof(rcv_buf));
    {
      if (read_GPS_datas(fd,rcv_buf))
      {
        printf("%s",rcv_buf);
      }
    }
  }
} // end GPS_original_signal

//------------------------------------- FUNCTION 2 resolve GPS GPGGA
information ----------------------------
void GPS_resolve_gpgga(int fd)
{
} // end GPS_resolve_gpgga

//------------------------------------- FUNCTION 3 resolve GPS GPGLL
information ----------------------------
void GPS_resolve_gpgll(int fd)
{
} // end GPS_resolve_gpgll

//------------------------------------- FUNCTION 4 resolve GPS GPGSA
information ----------------------------
void GPS_resolve_gpgsa(int fd)
{
} // end GPS_resolve_gpgsa

//------------------------------------- FUNCTION 5 resolve GPS GPGSV
information ----------------------------
void GPS_resolve_gpgsv(int fd)
{
} // end GPS_resolve_gpgsv

//------------------------------------- FUNCTION 6 resolve GPS GPRMC
information ----------------------------
void GPS_resolve_gprmc(int fd)
{
} // end GPS_resolve_gprmc

//------------------------------------- FUNCTION 7 resolve GPS GPVTG
information ----------------------------
void GPS_resolve_gpvtg(int fd)
{
} // end GPS_resolve_gpvtg

//------------------------------------- Receive GPS Signal
--------------------------------------------------
void func_GPS(int fd)
{
        int flag_func_run;
        int flag_select_func;
        ssize_t ret;

        flag_func_run = FUNC_RUN;

        while (flag_func_run == FUNC_RUN)
        {
                print_prompt();                 // print select functions
                scanf("%d",&flag_select_func);  // user input select
                getchar(); // get ENTER <LF>

                switch(flag_select_func)
                {
      case ORG_GPS  : {GPS_original_signal(fd);  break; }
                        case SEL_GPGGA  : {GPS_resolve_gpgga(fd);  break; }
                        case SEL_GPGLL  : {GPS_resolve_gpgll(fd);  break; }
                        case SEL_GPGSA  : {GPS_resolve_gpgsa(fd);  break; }
                        case SEL_GPGSV  : {GPS_resolve_gpgsv(fd);      
break; }
                        case SEL_GPRMC  : {GPS_resolve_gprmc(fd);      
break; }
      case SEL_GPVTG  : {GPS_resolve_gpvtg(fd);  break; }
                        case FUNC_QUIT          :
                                                {
                                                        flag_func_run =
FUNC_NOT_RUN;
                                                        printf("Quit GPS
function.  byebye\n");
                                                        break;
                                                }
                        default :
                        {
                                printf("please input your select use 1 to
8\n");
                        }
                }

        }
}// end func_GPS

//------------------------------------- init seriel port 
---------------------------------------------------
void init_ttyS(int fd)
{
  struct termios newtio;

  bzero(&newtio, sizeof(newtio));

  newtio.c_lflag &= ~(ECHO | ICANON);

  newtio.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  newtio.c_iflag = IGNPAR;
  newtio.c_oflag = 0;
  newtio.c_oflag &= ~(OPOST);

  newtio.c_cc[VTIME]    = 5;   /* inter-character timer unused */
  newtio.c_cc[VMIN]     = 0;   /* blocking read until 9 chars received */

  tcflush(fd, TCIFLUSH);
  tcsetattr(fd,TCSANOW,&newtio);

}//end init_ttyS


//------------------------------------- main
----------------------------------------------------------------
int main(void)
{
  int fd;

  printf ("\nThis is a test about GPS : receive GPS signal\n\n");

  // open seriel port
        fd = open(DEVICE_TTYS, O_RDONLY);

  if (fd == -1)
        {
                printf("open device %s error\n",DEVICE_TTYS);
        }
        else
        {
                init_ttyS(fd);  // init device
          func_GPS(fd);   // GPS functions

                // close ttyS0
                if (close(fd)!=0) printf("close device %s
error",DEVICE_TTYS);
        }

  return 0;
 
} // end main

shine
Above code i m using only to see the original data coming from GPS

davef
Just a suggestion:

isn't ttySAC1 only meant for communicating with the touchscreen and you
need another tty, i.e. ttyS0 (serial 0 on the row of connectors behind the
RS232 connector for comunications with the GPS unit?

shine
thanks! for ur suggestion but now, i m getting the data on ARM9 Board but
it is showing all zeroes instead of showing some latitude and longitude
value. even it is not showing special characters..........

davef
Do you have access to a DSO (oscilloscope).  Check that you actually get
data coming out of the GPS unit.  What voltage levels does the logic switch
between?

Did you write the code?

shine
Hiiii!! Successfully got the output on mini2440. It is showing GPS original
data, Means continously data is coming,
Now i want to filter for latitude and longitude values. Plz tell me how to
write code for that
???

Basically in the above code, i want the body of the following function:

void GPS_resolve_gpgga(int fd);

davef
What was the magic that got the data coming out of the mini2440?

> Did you write the code?

shine
No... whatever the data GPS is receiving that is only displaying on monitor
of friendlyARM.

For data coming out from friendlyARM I didn't write any code.

davef
You have to write or find an NMEA parser.  For example,

http://www.procyonengineering.com/embedded/avr/avrlib/docs/html/nmea_8c-...

to parse out the specific data you want, ie gpgga

sanjay
hi,
shine i have same problem i am unable to see gps original data on ttySAC0
can you help me

sanjay
hi, 
Shine i wanted to ask you which port (ttySAC0,ttySAC1,ttySAC2) you are used
for to see GPS original data and what is baud rate of both GPS and mini2440

g s ranjit kumar
hi,
i'm having a GPS module....
My GPS module: zymga312-3
is it possible to connect this module to ARM9 board using serial
communication ????
i done these steps ....
installed gpsd tool
i detected my module in /dev/ttyUSB0
i run gpsd as demon
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

cgps -s (no data i got in this window)
xgps    (i got graphical windo but no data)
gpspipe -r (in this step i got data like this....)
GPGSA,A,1,..........
GPRMC,001032.58,.....
GPGGA,000133.58,.....
GPGSV,3,1,1,..........
.........................
is it correct data i'm getting ???
is my module supports for ARM9 board ???
pls give me replay i'm very new to Embedded systems....

srikanth
Hi davef, 

I am using the gps evaluation kit having serial port interface....connected
to the mini2440.

I am working on the gps interface.....
Please Provide the necessary steps to work with.
1.What i need to run in the init.rc file?
2.What are the source code required for implementing gps?
3.Where do in need to add the device node /dev/*** in the source code?
4.How to make it available to the android user space.

Please suggest,
Regards,
Srikanth.

ramesh
Hi All,

I am using the gps interface connected on ttySAC1.On connecting the GPS
module to it's uart (ttySAC1) on mini2440. Any One know how to make it
works.


On browsing, i found that if gps is sending data then through stty, it can
be read. I tried the following commands but none of them work.

chmod 666 /dev/ttySAC1
stty 9600 -F /dev/ttySAC1 
stty -F /dev/ttySAC1 ispeed 9600 && cat < /dev/ttySAC1.

Please point me if something miss.

I also tried it with gpsd, but it is not crosscompiled for arm.Please, tell
how to cross compile it for arm.

Anyone know how to make gps-uart works on mini2440 board.
Please reply, Awaiting for your response.

Thanks.