📄 test.c
字号:
#include "COM.H"
#include <stdio.h>
#include <math.h>
long int com1Count=0;
long int com1Rx_len =0;
int ReceiveDone=0;
FILE *fp=NULL;
unsigned char time[]="000000";
union unionSend
{
unsigned char Sendstring[58];
struct structSend
{
unsigned short int head;// 帧头0xffff 2
float Lat;// 纬度 4
float Lgt;// 4
float Hlg;// 高度 4
float Yaw;// 4
float Pitch;// 4
float Roll;// 4
float wx;//x角速度 4
float wy;// 4
float wz;// 4
float wax;// x角加速度 4
float way;// 4
float waz;// 4
unsigned char GPStime[6];// 时间hhmmss // 6
unsigned int CheckValue;// 两字节校验 // 2
}s1;
}Sendunion;
void save(void)
{
fprintf(fp,"%10.6f %10.6f %10.6f",Sendunion.s1.Lat,Sendunion.s1.Lgt,Sendunion.s1.Hlg);
fprintf(fp,"%10.6f %10.6f %10.6f",Sendunion.s1.Yaw,Sendunion.s1.Pitch,Sendunion.s1.Roll);
fprintf(fp,"%10.6f %10.6f %10.6f",Sendunion.s1.wx,Sendunion.s1.wy,Sendunion.s1.wz);
fprintf(fp,"%10.6f %10.6f %10.6f\n",Sendunion.s1.wax,Sendunion.s1.way,Sendunion.s1.waz);
}
void disp()
{
gotoxy(10,8);
printf("Rx_count:%ld Rx_len:%ld",com1Count,com1Rx_len);
gotoxy(10,10);
printf("GPS_Time:%s",time);
gotoxy(10,12);
printf("Pos:%10.6f %10.6f %10.6f",Sendunion.s1.Lat,Sendunion.s1.Lgt,Sendunion.s1.Hlg);
gotoxy(10,14);
printf("ATT:%10.6f %10.6f %10.6f",Sendunion.s1.Yaw,Sendunion.s1.Pitch,Sendunion.s1.Roll);
gotoxy(10,16);
printf("W:%10.6f %10.6f %10.6f",Sendunion.s1.wx,Sendunion.s1.wy,Sendunion.s1.wz);
gotoxy(10,18);
printf("Wa:%10.6f %10.6f %10.6f",Sendunion.s1.wax,Sendunion.s1.way,Sendunion.s1.waz);
}
void main(void)
{
unsigned char key=0;
clrscr();
gotoxy(70,25); printf("Quit !");
if((fp = fopen("RXdata.txt","w+"))==NULL)
{
printf("File not opened!");
return;
}
outportb(0x20,0x20); //clear interrupt ask
OpenCOM(COM1, BAUD_115200, PARITY_NO|STOP_BIT1|DATA_BIT8, INT_MSK_TX|INT_MSK_RX);
while (key!='Q'&&key!='q')
{
if(kbhit())
key=getch();
if(ReceiveDone)
{
ReceiveDone=0;
memcpy(time,Sendunion.s1.GPStime, 6*sizeof(char));
save();
disp();
}
}
CloseCOM(COM1) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -