📄 arm linux gps.txt
字号:
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <commplus.h>
#include <infrared.h>
extern _stklen = 4096u; /* it very useful to reduce memory in HT-1800 */
extern _heaplen = 4096u; /* both stack & heap length must be set */
int main()
{
while(1 == 1)
{
gps();
}
return 0;
}
int gps()
{
char *gpsStr;
int charI;
int akey;
unsigned char cm;
unsigned char p;
unsigned int baudtmp, baud;
int exitloop = 0;
unsigned char ab, st;
unsigned long b;
unsigned char p1;
unsigned char iroldstat;
char str1[] = "$PNMRX103,GGA,1,GSA,0,GSV,0,RMC,0,GLL,0,GSV,0,VTG,0,ZDA,*xx\r\n";
int i;
char tStrArr[254],tlttArr[9],tlgtArr[10];
char *tgga,*tgsa,*trmc,*tltt,*tlgt;
charI = 0;
if (!ComPlsInstalled())
{
if (InstallComPls(0) == 2)
{
cprintf("BIOS Setting for COM1 or COM2 Error!!!!\r\n\n");
return 0;
}
}
//printf("\nBaudRate:");
//scanf("%ld",&b);
//scanf("%c",&akey);
//printf("Port(1/2):");
//scanf("%c",&p1);
//scanf("%c",&akey);
//printf("Input ...");
IRPowerCtrl(0x01);
SetIRMFreq(38000);
SetIROutput(2);
GetCommMode(&cm, &p, &baud);
if (b >= 115200)
baudtmp = 0xFFF0;
else
baudtmp = (int)b;
if (p1 == 2)
{
if (b == 9600)
{
iroldstat = IRPowerCtrl(5);
SetIRMFreq(38000);
}
if (b == 19200)
{
iroldstat = IRPowerCtrl(5);
SetIRMFreq(307680);
}
}
SetCommMode(3, 2-1, 4800);
EnableRx(0);
exitloop = 0;
akey = 0;
for (i=0;i<sizeof(str1);i++)
PutAuxByte(str1[i]);
do
{
if (kbhit())
{
akey = getch();
if (akey != 27)
{
if (!exitloop)
//printf("\n");
exitloop = -1;
//PutAuxByte((char)akey);
//printf("%c",akey);
}
}
if (ExistAuxBGot(&ab, &st))
{
if (ab == 13)
//printf("\n");
exitloop = 0;
tStrArr[charI] = ab;
charI++;
if(charI == 254)
{
gpsStr = &tStrArr[0];
tgga = strstr(gpsStr,"GPGGA");
//printf("gga:%s",tgga);
/*
tlgt = getpart(tgga,",",4);
tltt = getpart(tgga,",",2);
printf("%s\n",tltt);*/
break;
}
}
}while (akey != 27);
SetCommMode(cm, p, baud);
iroldstat = IRPowerCtrl(0);
SetIRMFreq(0);
DisableRx();
//printf("gga:%s",tgga);
tlgt = getpart(tgga,",",4);
printf("lgt:%s\n", tlgt);
//printf("%s",tgga);
tltt = getpart(tgga,",",2);
printf("ltt:%s\n", tltt);
return 0;
}
int getpart(char *SourceStr,char *ConnStr,int PartInt)
{
int PartI = 1;
char *ResultStr,*tempStr,*dropStr;
int OriLen,DropLen;
//PartInt++;
tempStr = SourceStr;
while(PartI <= PartInt)
{
tempStr = strstr(tempStr,ConnStr);
tempStr++;
PartI++;
}
OriLen = strlen(tempStr);
dropStr = strstr(tempStr,ConnStr);
DropLen = strlen(dropStr);
strncpy(ResultStr,tempStr,OriLen - DropLen);
if(dropStr == NULL)//这里防止取到不存在的字符串
{
return(NULL);
}
else
{
return(ResultStr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -