⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gps_main.c

📁 It is a software to decode information received by a normal GPS like GARMIN, UBLOX if it sends NMEA
💻 C
字号:
#include <termios.h> #include <string.h>                                                        #include <stdio.h>  #include <stdlib.h>                                                         #include <unistd.h>                                                          #include <fcntl.h>                                                           #include <sys/signal.h>                                                      #include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include "garmin_api.h"#include "connect.h"int op=10;char port[30];int baudrate=9600;void CTRL_signal(int sig);int main(){	int fd, tam;	char opcao, opcao2;	char buf[1000];	//signal(SIGINT,CTRL_signal);	//printf("\nIntroduza a porta : ");	//gets(&port[0]);	strcpy(port,"/dev/ttyACM0");		init_port(&fd,&port[0],baudrate);		while(1)	{		if(op==10)		{						read_port(&fd,&buf[0],&tam);			buf[tam]=0;						//strcpy(buf,"$GPRMC,092434,V,4011.1689,N,00825.0256,W,,,290908,004.0,W*6B");			//printf("\n%s",buf);			fflush(stdout);						nmea_in(buf);		}							print(op);		if(op==15)		{			read(0,&opcao,sizeof(opcao));			fflush(stdin);						if(opcao=='e' || opcao == 'E'){				 break;			 }else if(opcao=='p' || opcao == 'P')			{				system("clear");				printf("\nEnter a new port: ");				fflush(stdout);				fflush(stdin);						read(0,port,sizeof(port));				fflush(stdin);				init_port(&fd,&port[0],baudrate);				op=10;			}else if(opcao=='b' || opcao=='B')			{				system("clear");				printf("\nBaudrate %d",baudrate);				printf("\nEnter a new baurade: ");				fflush(stdin);				scanf("%d",&baudrate);				init_port(&fd,&port[0],baudrate);				op=10;							}else if(opcao=='m' || opcao=='M')			{				op=10;			}else if(opcao=='g' || opcao=='G')			{				system("clear");								op=11;					print(op);				fflush(stdout);				while(1)				{					read(0,&opcao,sizeof(opcao));					if(opcao!=10) break;				}								if(opcao=='M' || opcao=='m')				{					op=10;					fflush(stdout);				}else if(opcao=='A' || opcao=='a')				{					//request_GPALM();					op=12;				}else if(opcao=='E' || opcao=='e')				{					op=13;									}							}								}					}	close_port(&fd);		return 0;	}		void CTRL_signal(int sig){	//system("clear");	//printf("\n\t\tMenu");	op=15;		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -