Difference between revisions of "Sample-codes"

From DATAGNSS Wiki
Jump to navigation Jump to search
 
Line 42: Line 42:
     return;
     return;
}
}
</pre>
=== gen_all_cmds ===
<pre>
#define ALLSYNC1    0xF1        /* message sync code 1 */
#define ALLSYNC2    0xD9        /* message sync code 2 */
#define ALLCFG      0x06        /* message cfg-??? */
</pre>
</pre>

Latest revision as of 18:30, 12 October 2024

gen_fixed_ecef

#define ALLSYNC1    0xF1        /* message sync code 1 */
#define ALLSYNC2    0xD9        /* message sync code 2 */
#define ALLCFG      0x06        /* message cfg-??? */

/* set checksum ------------------------------------------------------------------*/
static void setcs(unsigned char *buff, int len)
{
    unsigned char cka=0,ckb=0;
    int i;
    
    for (i=2;i<len-2;i++) {
        cka+=buff[i]; ckb+=cka;
    }
    buff[len-2]=cka;
    buff[len-1]=ckb;
}

extern void gen_cfg_fixedecef_hex(double *xyz,unsigned char *buff)
{
	unsigned char *q=buff;
	
	*q++=ALLSYNC1;
	*q++=ALLSYNC2;
	*q++=ALLCFG;
	*q++=0x14; //cfg_fixedecef
	*q++=0x0C; //payload length,2 bytes
	*q++=0x00;

    int i4;

	for(int i=0;i<3;i++){
	    i4=(int)round(xyz[i]*100);
	    print("float xyz(cm):%d\n",i4);
	    setS4(q,i4);
	    q+=4;
	}

	setcs(buff,20);

    return;
}

gen_all_cmds

#define ALLSYNC1    0xF1        /* message sync code 1 */
#define ALLSYNC2    0xD9        /* message sync code 2 */
#define ALLCFG      0x06        /* message cfg-??? */