📄 gps_main.c
字号:
/************************************************ * serial communication demo * by Zou jian guo <ah_zou@163.com> * 2003-12-22 **************************************************/#include <stdio.h>#include "../startup/uhal.h"#include "../gps/gps.h"#include "../startup/uart.h"#define FALSE 0#define TRUE 1volatile int STOP=FALSE;GPS_INFO gps_info;int GET_GPS_OK=FALSE;char GPS_BUF[1024];/*--------------------------------------------------------*//*void keyboard(void * data){ int c; for (;;){ if((c=(int)GetKey()) == 15){ STOP=TRUE; break ; } Uart_Printf("key=%d\n",c); }// return NULL;}*//*--------------------------------------------------------*//* modem input handler */void show_gps_info(void * data){ while(1){ if(GET_GPS_OK){ GET_GPS_OK=FALSE; gps_parse(GPS_BUF,&gps_info); show_gps(&gps_info); } OSTimeDly(200);// if(STOP)break; }}/*--------------------------------------------------------*//* modem input handler */void receive(void * data){ int i=0, tmp=0; u8 c; static char buf[1024]; GPS_INFO GPS;// Uart_Printf("read modem\n");// while (STOP==FALSE) { while (1) { tmp = OSReadUart1(&c, 1, 0); /* read from com port */ buf[i++] = c; if(c == '\n'){ buf[i]=0; strcpy(GPS_BUF, buf); i=0; GET_GPS_OK = TRUE; Uart_Printf("%s", GPS_BUF); OSTimeDly(200); }// if(STOP)break; } Uart_Printf("exit from reading modem\n");}/*--------------------------------------------------------*//*int main(int argc,char** argv){ struct termios oldtio,newtio,oldstdtio,newstdtio; struct sigaction sa; int ok; pthread_t th_a, th_b, th_show; void * retval; fd = open(COM2, O_RDWR ); if (fd <0) { perror(COM2); exit(-1); } tcgetattr(0,&oldstdtio); tcgetattr(fd,&oldtio); //save current modem settings tcgetattr(fd,&newstdtio); // get working stdtio // newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;//ctrol flag// newtio.c_iflag = IGNPAR; //*input flag// newtio.c_oflag = 0; //output flag// newtio.c_lflag = 0; newtio.c_cc[VMIN]=1; newtio.c_cc[VTIME]=0; // now clean the modem line and activate the settings for modem // tcflush(fd, TCIFLUSH); tcsetattr(fd,TCSANOW,&newtio);//set attrib // pthread_create(&th_a, NULL, keyboard, 0); pthread_create(&th_b, NULL, receive, 0); pthread_create(&th_show, NULL, show_gps_info, 0); while(!STOP){ Delay(100000); } // // pthread_join(th_a, &retval);// pthread_join(th_b, &retval);// pthread_join(th_show, &retval);// tcsetattr(fd,TCSANOW,&oldtio); // restore old modem setings // tcsetattr(0,TCSANOW,&oldstdtio); // restore old tty setings // close(fd); exit(0); }*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -