Difference between revisions of "Sample-codes"
Jump to navigation
Jump to search
(Created page with "=== gen_fixed_ecef === <pre> extern void gen_cfg_fixedecef_hex(double *xyz,unsigned char *buff) { unsigned char *q=buff; //cfg-fixedecef F1 D9 06 14 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 26 34 //F1 D9 06 14 0C 00 2F 5C F7 EE D5 15 C7 1B E2 B2 84 13 8D 85 //-2857788.974 4660320.857 3274636.501 // *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++...") |
|||
Line 1: | Line 1: | ||
=== gen_fixed_ecef === | === gen_fixed_ecef === | ||
<pre> | <pre> | ||
#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) | extern void gen_cfg_fixedecef_hex(double *xyz,unsigned char *buff) | ||
{ | { | ||
unsigned char *q=buff; | unsigned char *q=buff; | ||
*q++=ALLSYNC1; | *q++=ALLSYNC1; | ||
Line 21: | Line 33: | ||
for(int i=0;i<3;i++){ | for(int i=0;i<3;i++){ | ||
i4=(int)round(xyz[i]*100); | i4=(int)round(xyz[i]*100); | ||
print("float xyz(cm):%d\n",i4); | |||
setS4(q,i4); | setS4(q,i4); | ||
q+=4; | q+=4; | ||
Line 27: | Line 39: | ||
setcs(buff,20); | setcs(buff,20); | ||
return; | return; | ||
} | } | ||
</pre> | </pre> |
Revision as of 18:27, 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; }