?? ch_frame.c
字號:
/**************************************
File : CH_FRAME.C
Project : BDTRV20_MCU_V07
Description : 分解DSP輸出的各幀,提取并存儲參數(shù)
Created : 2006.11.7
Last updata :
Author : Sunzehui sunzehui@zzvcom.com
Compile Tool : Keil uVision2
Target Device : SST89V564RD
Circuit Board : BD7700
************************************
Modification History
************************************
Version : v2.0
Date : MM/DD/YYYY
Modifier :
Description :
**********************************
-- Copyright (c)
*************************************/
#include <string.h>
#include "ext_temp.h"
//extern unsigned long asc_to_long(unsigned char *p,bit m);
extern unsigned char asc_to_char(unsigned char a1,unsigned char a2,bit m);
extern unsigned char fromasc(unsigned m);
extern unsigned long tosec(unsigned char hour, unsigned char min, unsigned char sec, unsigned char date, unsigned char mon, unsigned int year);
extern unsigned char *sectodata(unsigned long tod);
extern send_lp_dsp(void);
extern SendDSP(void);
extern send_lla(void);
extern send_ofs(void);
extern wdt(void);
extern ch_frame(void)
{
unsigned char temp,i;//,tmp,b[8];
unsigned char *point;
unsigned long xdata p,tmp,lp_sec_tmp;
wdt();
if (sdata[3]=='Z'&&sdata[4]=='D'&&sdata[5]=='A') //$BDZDA幀
{
//temp=(sdata[7]-0x30)*10;
//hour=temp+(sdata[8]-0x30);//提取小時
hour=asc_to_char(sdata[7],sdata[8],0);
//temp=(sdata[9]-0x30)*10;
//min=temp+(sdata[10]-0x30);//提取分鐘
min=asc_to_char(sdata[9],sdata[10],0);
//temp=(sdata[11]-0x30)*10;
//sec=temp+(sdata[12]-0x30);//提取秒
sec=asc_to_char(sdata[11],sdata[12],0);
//temp=(sdata[17]-0x30)*10;
//day=temp+(sdata[18]-0x30);//提取天
day=asc_to_char(sdata[17],sdata[18],0);
//temp=(sdata[20]-0x30)*10;
//month=temp+(sdata[21]-0x30);//提取月
month=asc_to_char(sdata[20],sdata[21],0);
year=(sdata[23]-0x30)*1000+(sdata[24]-0x30)*100+(sdata[25]-0x30)*10+(sdata[26]-0x30);//提取年
//year=year+100;//only for test 2000
/******************得到秒值************************************************/
if (channel_sta_2&0x40==0x40)
{
p = tosec(hour,min,sec,day,month,year); //BD時間秒值
/*if (UTC_mode_fg==1)//UTC模式
{
if ((cur_lp_sec==0&&fur_lp_sec==0)||(cur_lp_sec!=0&&(fur_lp_sec-cur_lp_sec==1)))//有正閏秒或無閏秒
cur_time_sec=p+UTC_sec;
else
cur_time_sec=p-UTC_sec;
}
else //GPS模式
{*/
tmp=gmth*3600+gmtm*60;
if ((cur_lp_sec==0&&fur_lp_sec==0)||(cur_lp_sec!=0&&(fur_lp_sec-cur_lp_sec==1))) //有正閏秒或無閏秒
{
if (gmts==0x00)//GMT符號為正
cur_time_sec=p+tmp;// //cur_time = (gps0+gmt=bds-13-pp-8*3600)+gmt = bds-pp+gmt-28813
else if(gmts==0xff)//GMT符號為負(fù)
cur_time_sec=p-tmp;//
cur_time_sec-= 28800;
// cur_time_sec = cur_time_sec + UTC_sec;
if (UTC_mode_fg==0) //GPS模式
{
cur_time_sec = cur_time_sec + UTC_sec - 13;
}
}
else if(cur_lp_sec !=0&&(fur_lp_sec-cur_lp_sec==-1))//有負(fù)閏秒
{
if (gmts==0x00)
cur_time_sec=p+tmp;//-UTC_sec; //cur_time = (gps0+gmt=bds-13-pp-8*3600)+gmt = bds-pp+gmt-28813
else if(gmts==0xff)
cur_time_sec=p-tmp;//-UTC_sec;
cur_time_sec -= 28800;
//cur_time_sec = cur_time_sec - UTC_sec;
if (UTC_mode_fg==0) //GPS模式
{
cur_time_sec=cur_time_sec - UTC_sec - 13;
}
}
/******************************************************************/
//重新得到年月日時分秒
/*******************************************************************/
point=sectodata(cur_time_sec);
hour =*point++; //時
min =*point++; //分
sec =*point++; //秒
year=0;
year=*point++;
year=year<<8;
year|=*point++; //年
month=*point++; //月
day=*point; //日
}
}
/****$ B D L P S , 2 0 2 F A 0 A 2 4 C 8 ,235958,30,06,2015*7C
0 1 2 3 4 5 6 7 8 9
*/
else if(sdata[3]=='L'&&sdata[4]=='P'&&sdata[5]=='S')//$BDLPS幀
{
//lps_cnt++;
if (sdata[7]=='0'||sdata[7]=='1'||sdata[7]=='2') //提取BD與UTC的差值
{
UTC_sec = asc_to_char(sdata[8],sdata[9],1);//BD1與UTC相差秒值、當(dāng)前閏秒值整數(shù)部分
for(i=10;i<17;i=i+2)
{
UTC_ns=UTC_ns<<8;
temp=fromasc(sdata[i])<<4;
temp|=fromasc(sdata[i+1]);
UTC_ns|=temp;///////////////...
//UTC_ns=temp|fromasc(sdata[i+1]);
}
}
if (sdata[7]=='0')//無閏秒
{
fur_lp_sec =0;
cur_lp_sec =0;
lp_hour=0; lp_min=0;
lp_sec=0; lp_day=0;
lp_month=0; lp_year=0;
}
else if (sdata[7]=='1'||sdata[7]=='2')//有閏秒狀態(tài)
{
//提取未來閏秒值
if (sdata[7]=='1')
{
cur_lp_sec=UTC_sec; //當(dāng)前閏秒
fur_lp_sec=UTC_sec +1;//未來閏秒
}
else if(sdata[7]=='2')
{
cur_lp_sec=UTC_sec;
fur_lp_sec=UTC_sec -1;
}
//閏秒發(fā)生時
lp_hour =asc_to_char(sdata[19],sdata[20],0);//(sdata[19]-0x30)*10+(sdata[20]-0x300);
//閏秒發(fā)生分
lp_min =asc_to_char(sdata[21],sdata[22],0);//(sdata[21]-0x30)*10+(sdata[22]-0x300);
//閏秒發(fā)生秒
lp_sec =asc_to_char(sdata[23],sdata[24],0);//(sdata[23]-0x30)*10+(sdata[24]-0x300);
//閏秒發(fā)生日
lp_day=asc_to_char(sdata[26],sdata[27],0);
//閏秒發(fā)生月
lp_month=asc_to_char(sdata[29],sdata[30],0);
//閏秒發(fā)生年
lp_year =(sdata[32]-0x30)*1000+(sdata[33]-0x30)*100+(sdata[34]-0x30)*10+sdata[35]-0x30;
if (channel_sta_2&0x40==0x40)
{
p = tosec(lp_hour,lp_min,lp_sec,lp_day,lp_month,lp_year); //BD時間秒值
/* if (UTC_mode_fg==1)//UTC模式
{
if ((cur_lp_sec==0&&fur_lp_sec==0)||(fur_lp_sec-cur_lp_sec==1))//有正閏秒或無閏秒
cur_time_sec=p+UTC_sec;
else
cur_time_sec=p-UTC_sec;
}
else //GPS模式
{*/
tmp=gmth*3600+gmtm*60;
if ((cur_lp_sec==0&&fur_lp_sec==0)||(fur_lp_sec-cur_lp_sec==1)) //有正閏秒或無閏秒
{
if (gmts==0x00)//GMT符號為正
lp_sec_tmp=p+tmp; //cur_time = (gps0+gmt=bds-13-pp-8*3600)+gmt = bds-pp+gmt-28813
else if(gmts==0xff)//GMT符號為負(fù)
lp_sec_tmp=p-tmp;
lp_sec_tmp -=28800;
if (UTC_mode_fg==0)//GPS
{
lp_sec_tmp = lp_sec_tmp + UTC_sec -13;
}
}
else if(cur_lp_sec !=0&&(fur_lp_sec-cur_lp_sec==-1))//有負(fù)閏秒
{
if (gmts==0x00)
lp_sec_tmp=p+tmp; //cur_time = (gps0+gmt=bds-13-pp-8*3600)+gmt = bds-pp+gmt-28813
else if(gmts==0xff)
lp_sec_tmp=p-tmp;
lp_sec_tmp -=28800;
if (UTC_mode_fg==0)
{
cur_time_sec = cur_time_sec - UTC_sec -13;//28813
}
}
// }
/******************************************************************/
//重新得到年月日時分秒
/*******************************************************************/
point=sectodata(lp_sec_tmp);
lp_hour =*point++; //時
lp_min =*point++; //分
lp_sec =*point++; //秒
lp_year=0;
lp_year=*point++;
lp_year=lp_year<<8;
lp_year|=*point++; //年
lp_month=*point++; //月
lp_day=*point; //日
}
}
}
/*$ B D L L A , 3 4 4 4 . 2 6 7 8 8 , N, 11337.35114, E, 119.53*64
*/
else if (sdata[3]=='L'&&sdata[4]=='L'&&sdata[5]=='A')//$BDLLA幀
{
//lla_cnt++;
if (sdata[7]==lat_asc[0]&&sdata[8]==lat_asc[1]&&sdata[9]==lat_asc[2]&&sdata[10]==lat_asc[3]&&//判斷緯度是否相等
sdata[21]==long_asc[0]&&sdata[22]==long_asc[1]&&sdata[23]==long_asc[2]&&sdata[24]==long_asc[3]);//判斷經(jīng)度
else //讀出來的數(shù)與輸入數(shù)不等
send_lla();//重新發(fā)送數(shù)據(jù)
}
/*$ B D S T A , 0 0 0 3 , 1 1 1 D 7 9 0 0 , 0 1 2 2 7 8 0 0 * 3 E<0d><0a>
0 1 2 3 4 5 6 7 8 9 10 11 12 15 19 21 28
*/
else if(sdata[3]=='S'&&sdata[4]=='T'&&sdata[5]=='A')//$BDSTA幀
{
if (sdata[7]=='0'&&sdata[8]=='0'&&sdata[9]=='0'&&sdata[10]=='0')
channel_pps_en =0x00;//兩通道都不正常,PPS不可用
else if(sdata[7]=='0'&&sdata[8]=='0'&&sdata[9]=='0'&&sdata[10]=='1')
channel_pps_en =0x01;//1通道正常,PPS可用
else if(sdata[7]=='0'&&sdata[8]=='0'&&sdata[9]=='0'&&sdata[10]=='2')
channel_pps_en =0x02;//2通道正常,PPS可用
else if (sdata[7]=='0'&&sdata[8]=='0'&&sdata[9]=='0'&&sdata[10]=='3')
channel_pps_en =0x03;//兩通道都正常,PPS可用
//通道接收波束
channel_beam_1 = sdata[12]-0x30;
channel_beam_2 = sdata[21]-0x30;
//通道接收功率
channel_power_1 = fromasc(sdata[13]);
channel_power_1 =channel_power_1<<8;
channel_power_1 |=asc_to_char(sdata[14],sdata[15],1);
channel_power_2 = fromasc(sdata[22]);
channel_power_2 =channel_power_2<<8;
channel_power_2 |=asc_to_char(sdata[23],sdata[24],1);
//通道接收狀態(tài)
channel_sta_1 =asc_to_char(sdata[16],sdata[17],1);
channel_sta_2 =asc_to_char(sdata[25],sdata[26],1);
//通道誤碼數(shù)
channel_err_1 =asc_to_char(sdata[18],sdata[19],1);
channel_err_2 =asc_to_char(sdata[27],sdata[28],1);
}
/* $ B D O F S , F F B 9 F 5 5 2 , 00000000*77
0 1 2 3 4 5 6 7 8 9 10 14
*/
else if (sdata[3]=='O'&&sdata[4]=='F'&&sdata[5]=='S')//$BDOFS幀
{
// ofs_cnt++;
// if (sdata[9]==pps_asc[0]&&sdata[10]==pps_asc[1]&&sdata[11]==pps_asc[2]&&sdata[12]==pps_asc[3]);
// else//輸出數(shù)與輸入數(shù)不等(說明沒有寫入DSP,需重寫)
// send_ofs();//重組BDOFS幀
send_lp_dsp();//發(fā)送$BDLPS到DSP
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -