📄 rtcmtoasciiconvertor.c
字号:
void readmessage3(int msglen){
int type3packet[96];
int m;
int n = 10;
int q = 0;
int p;
signed int xcoord;
signed int ycoord;
signed int zcoord;
int j;
for (m = 0; m < msglen; m++){
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
type3packet[q] = bitword[p];
q++;
}
}
xcoord = 0;
ycoord = 0;
zcoord = 0;
for (j = 0; j < 32; j++){
xcoord = xcoord | (type3packet[31 - j] << j);
}
for (j = 0; j < 32; j++){
ycoord = ycoord | (type3packet[63 - j] << j);
}
for (j = 0; j < 32; j++){
zcoord = zcoord | (type3packet[95 - j] << j);
}
if (bool_xyz){
fprintf(mtype3,"%11.2f %11.2f %11.2f ",xcoord*0.01,ycoord*0.01,zcoord*0.01);
}
fprintf(mtype3,"\n");
}
/*****************************************************************************
* READMESSAGE16 *
* *
* This function reads and decodes type 16 message and writes the result to *
* a text file. The input to the function is the length of the message in *
* bytes. LOADWORD is used to read the GPS words. There is no return value *
*****************************************************************************/
void readmessage16(int msglen){
char strmessage[90];
char chr;
int m;
int n = 10;
int q = 0;
int p;
int j;
strmessage[0] = '\0';
for (m = 0; m < msglen; m++){
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 1; p < 4; p++){
chr = 0;
for (j = 0; j < 8; j++){
chr = chr | (bitword[(p*8 - 1) - j] << j);
}
strmessage[q] = chr;
q++;
}
}
strmessage[q] = '\0';
if (bool_msg){
fprintf(mtype16,"%s",strmessage);
}
fprintf(mtype16,"\n");
}
/*****************************************************************************
* READMESSAGE18 *
* *
* This function reads and decodes type 18 message and writes the result to *
* a text file. The input to the function is the length of the message in *
* bytes. LOADWORD is used to read the GPS words. There is no return value *
*****************************************************************************/
void readmessage18(int msglen){
const double phasefactor = 0.00390625;
int extheader[24];
int type18packet[48];
int n = 10;
int j;
int q = 0;
int p;
int m;
unsigned char freq_indicator = 0;
unsigned int gnss_time = 0;
unsigned char multi_message;
unsigned char pc_indicator;
unsigned char gps_glonass;
unsigned char sat_id;
unsigned char data_qual;
unsigned char cum_loss_indicator;
signed int carrier_phase;
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
extheader[p] = bitword[p];
}
for (j = 0; j < 2; j++){
freq_indicator = freq_indicator | (extheader[1 - j] << j);
}
for (j = 0; j < 20; j++){
gnss_time = gnss_time | (extheader[23 - j] << j);
}
if (bool_freq){
fprintf(mtype18,"%d ",freq_indicator);
}
if (bool_gnsstime){
fprintf(mtype18,"%6.0f ",(double)gnss_time);
}
for (m = 0; m < (msglen - 1)/2; m++){
q = 0;
sat_id = 0;
data_qual = 0;
cum_loss_indicator = 0;
carrier_phase = 0;
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
type18packet[q] = bitword[p];
q++;
}
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
type18packet[q] = bitword[p];
q++;
}
multi_message = type18packet[0];
pc_indicator = type18packet[1];
gps_glonass = type18packet[2];
for (j = 0; j < 5; j++){
sat_id = sat_id | (type18packet[7 - j] << j);
}
if (sat_id == 0){
sat_id = 32;
}
for (j = 0; j < 3; j++){
data_qual = data_qual | (type18packet[10 - j] << j);
}
for (j = 0; j < 5; j++){
cum_loss_indicator = cum_loss_indicator | (type18packet[15 - j] << j);
}
for (j = 0; j < 32; j++){
carrier_phase = carrier_phase | (type18packet[47 - j] << j);
}
if (bool_multi){
fprintf(mtype18,"%d ",multi_message);
}
if (bool_pcind){
fprintf(mtype18,"%d ",pc_indicator);
}
if (bool_gpsglo){
fprintf(mtype18,"%d ",gps_glonass);
}
if (bool_prn){
fprintf(mtype18,"%2.0f ",(double)sat_id);
}
if (bool_qual){
fprintf(mtype18,"%d ",data_qual);
}
if (bool_cslip){
fprintf(mtype18,"%2.0f ",(double)cum_loss_indicator);
}
if (bool_phase){
fprintf(mtype18,"%12.3f ",phasefactor*carrier_phase);
}
}
fprintf(mtype18,"\n");
}
/*****************************************************************************
* READMESSAGE19 *
* *
* This function reads and decodes type 19 message and writes the result to *
* a text file. The input to the function is the length of the message in *
* bytes. LOADWORD is used to read the GPS words. There is no return value *
*****************************************************************************/
void readmessage19(int msglen){
const double prfactor = 0.02;
int extheader[24];
int type19packet[48];
int n = 10;
int j;
int q = 0;
int p;
int m;
unsigned char freq_indicator = 0;
unsigned char smoothing = 0;
unsigned int gnss_time = 0;
unsigned char multi_message;
unsigned char pc_indicator;
unsigned char gps_glonass;
unsigned char sat_id;
unsigned char data_qual;
unsigned char mp_error;
unsigned int pseudo_range;
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
extheader[p] = bitword[p];
}
for (j = 0; j < 2; j++){
freq_indicator = freq_indicator | (extheader[1 - j] << j);
}
for (j = 0; j < 2; j++){
smoothing = smoothing | (extheader[3 - j] << j);
}
for (j = 0; j < 20; j++){
gnss_time = gnss_time | (extheader[23 - j] << j);
}
if (bool_freq){
fprintf(mtype19,"%d ",freq_indicator);
}
if (bool_smooth){
fprintf(mtype19,"%d ",smoothing);
}
if (bool_gnsstime){
fprintf(mtype19,"%6.0f ",(double)gnss_time);
}
for (m = 0; m < (msglen - 1)/2; m++){
q = 0;
sat_id = 0;
data_qual = 0;
mp_error = 0;
pseudo_range = 0;
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
type19packet[q] = bitword[p];
q++;
}
loadword(rawbuf[n],rawbuf[n+1],rawbuf[n+2],rawbuf[n+3],rawbuf[n+4]);
n = n + 5;
for (p = 0; p < 24; p++){
type19packet[q] = bitword[p];
q++;
}
multi_message = type19packet[0];
pc_indicator = type19packet[1];
gps_glonass = type19packet[2];
for (j = 0; j < 5; j++){
sat_id = sat_id | (type19packet[7 - j] << j);
}
if (sat_id == 0){
sat_id = 32;
}
for (j = 0; j < 4; j++){
data_qual = data_qual | (type19packet[11 - j] << j);
}
for (j = 0; j < 4; j++){
mp_error = mp_error | (type19packet[15 - j] << j);
}
for (j = 0; j < 32; j++){
pseudo_range = pseudo_range | (type19packet[47 - j] << j);
}
if (bool_multi){
fprintf(mtype19,"%d ",multi_message);
}
if (bool_pcind){
fprintf(mtype19,"%d ",pc_indicator);
}
if (bool_gpsglo){
fprintf(mtype19,"%d ",gps_glonass);
}
if (bool_prn){
fprintf(mtype19,"%2.0f ",(double)sat_id);
}
if (bool_qual){
fprintf(mtype19,"%2.0f ",(double)data_qual);
}
if (bool_mpe){
fprintf(mtype19,"%2.0f ",(double)mp_error);
}
if (bool_pr){
fprintf(mtype19,"%11.2f ",prfactor*pseudo_range);
}
}
fprintf(mtype19,"\n");
}
/*****************************************************************************
* READHEADER *
* *
* This function reads and decodes the two word header information. The *
* output is written to file and from the informtion in the header the *
* correct function is called to decode the rest of the message. This *
* function also uses LOADWORD to read the GPS word *
*****************************************************************************/
void readheader(void){
int j;
int preamble = 0;
int message_type = 0;
int station_id = 0;
int mod_zcount = 0;
int seq_no = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -