int main() { int i,j; double dds[c] = {-1.765,1.765,0,1,4,15e13,1.676e14,-15e-1,0.005,-0.03e13,1234567890,-1234567890,9.999999999999999e22,INFINITY,NAN}; const char *res[c] = { "-1.765","1.765","0.0","1.0","4.0","150000000000000.0","167600000000000.0","-1.5","0.005","-300000000000.0","1234567890.0","-1234567890.0","9.999999999999999e+22","inf","NaN", }; for (i=0;i<c;i++) { for (j=0;j<1;j++) { char *buf; buf = dtostr(dds[i]); fprintf(stderr, "%s%.15g to %s\n", strcmp(res[i],buf)==0 ? "" : "ERRROR: ",dds[i], buf); } } }
int main(void) { type1_vals vals; type1_negotiate(0x00fffff, 0x00fffff, 1, &vals); //*** delay delay(100); do { //*** writing data static unsigned char write_00000_00000[] = "\x73\x0a"; static unsigned int write_00000_00000_len = 2; unsigned char *write_00000 = NULL; unsigned int write_00000_len = 0; write_00000 = append_buf(write_00000, &write_00000_len, write_00000_00000, write_00000_00000_len); if (write_00000_len > 0) { transmit_all(1, write_00000, write_00000_len); } free(write_00000); } while (0); do { //*** writing data static unsigned char write_00001_00000[] = "\x64\x0a"; static unsigned int write_00001_00000_len = 2; unsigned char *write_00001 = NULL; unsigned int write_00001_len = 0; write_00001 = append_buf(write_00001, &write_00001_len, write_00001_00000, write_00001_00000_len); if (write_00001_len > 0) { transmit_all(1, write_00001, write_00001_len); } free(write_00001); } while (0); do { //*** writing data static unsigned char write_00002_00000[] = "\x31\x30\x2e\x30\x0a"; static unsigned int write_00002_00000_len = 5; unsigned char *write_00002 = NULL; unsigned int write_00002_len = 0; write_00002 = append_buf(write_00002, &write_00002_len, write_00002_00000, write_00002_00000_len); if (write_00002_len > 0) { transmit_all(1, write_00002, write_00002_len); } free(write_00002); } while (0); do { //*** writing data static unsigned char write_00003_00000[] = "\x61\x0a"; static unsigned int write_00003_00000_len = 2; unsigned char *write_00003 = NULL; unsigned int write_00003_len = 0; write_00003 = append_buf(write_00003, &write_00003_len, write_00003_00000, write_00003_00000_len); if (write_00003_len > 0) { transmit_all(1, write_00003, write_00003_len); } free(write_00003); } while (0); do { //*** writing data static unsigned char write_00004_00000[] = "\x70\x0a"; static unsigned int write_00004_00000_len = 2; unsigned char *write_00004 = NULL; unsigned int write_00004_len = 0; write_00004 = append_buf(write_00004, &write_00004_len, write_00004_00000, write_00004_00000_len); if (write_00004_len > 0) { transmit_all(1, write_00004, write_00004_len); } free(write_00004); } while (0); do { //*** writing data static unsigned char write_00005_00000[] = "\x64\x0a"; static unsigned int write_00005_00000_len = 2; unsigned char *write_00005 = NULL; unsigned int write_00005_len = 0; write_00005 = append_buf(write_00005, &write_00005_len, write_00005_00000, write_00005_00000_len); if (write_00005_len > 0) { transmit_all(1, write_00005, write_00005_len); } free(write_00005); } while (0); do { //*** writing data static unsigned char write_00006_00000[] = "\x2c"; static unsigned int write_00006_00000_len = 1; static unsigned char write_00006_00003[] = "\x2c\x30\x0a"; static unsigned int write_00006_00003_len = 3; unsigned char *write_00006 = NULL; unsigned int write_00006_len = 0; char dtostr_buf[256]; union { double d; struct { unsigned int lo, hi; } u; } pack; pack.u.hi = 0x41800000; pack.u.lo = vals.regval; dtostr(pack.d, dtostr_buf, sizeof(dtostr_buf)); write_00006 = append_buf(write_00006, &write_00006_len, (unsigned char *)dtostr_buf, cgc_strlen(dtostr_buf)); write_00006 = append_buf(write_00006, &write_00006_len, write_00006_00000, write_00006_00000_len); pack.u.lo = vals.ipval; dtostr(pack.d, dtostr_buf, sizeof(dtostr_buf)); write_00006 = append_buf(write_00006, &write_00006_len, (unsigned char *)dtostr_buf, cgc_strlen(dtostr_buf)); write_00006 = append_buf(write_00006, &write_00006_len, write_00006_00003, write_00006_00003_len); if (write_00006_len > 0) { transmit_all(1, write_00006, write_00006_len); } free(write_00006); } while (0); do { //*** writing data static unsigned char write_00007_00000[] = "\x30\x2c\x30\x2c\x30\x0a"; static unsigned int write_00007_00000_len = 6; unsigned char *write_00007 = NULL; unsigned int write_00007_len = 0; write_00007 = append_buf(write_00007, &write_00007_len, write_00007_00000, write_00007_00000_len); if (write_00007_len > 0) { transmit_all(1, write_00007, write_00007_len); } free(write_00007); } while (0); do { //*** writing data static unsigned char write_00008_00000[] = "\x31\x2c\x31\x2c\x31\x0a"; static unsigned int write_00008_00000_len = 6; unsigned char *write_00008 = NULL; unsigned int write_00008_len = 0; write_00008 = append_buf(write_00008, &write_00008_len, write_00008_00000, write_00008_00000_len); if (write_00008_len > 0) { transmit_all(1, write_00008, write_00008_len); } free(write_00008); } while (0); do { //*** writing data static unsigned char write_00009_00000[] = "\x30\x2c\x30\x2c\x30\x0a"; static unsigned int write_00009_00000_len = 6; unsigned char *write_00009 = NULL; unsigned int write_00009_len = 0; write_00009 = append_buf(write_00009, &write_00009_len, write_00009_00000, write_00009_00000_len); if (write_00009_len > 0) { transmit_all(1, write_00009, write_00009_len); } free(write_00009); } while (0); do { //*** writing data static unsigned char write_00010_00000[] = "\x72\x0a"; static unsigned int write_00010_00000_len = 2; unsigned char *write_00010 = NULL; unsigned int write_00010_len = 0; write_00010 = append_buf(write_00010, &write_00010_len, write_00010_00000, write_00010_00000_len); if (write_00010_len > 0) { transmit_all(1, write_00010, write_00010_len); } free(write_00010); } while (0); do { unsigned char *read_00000; unsigned int read_00000_len; unsigned int read_00000_ptr = 0; //**** delimited cgc_read static unsigned char read_00000_delim[] = "\x0a"; read_00000 = NULL; read_00000_len = 0; int read_00000_res = delimited_read(0, &read_00000, &read_00000_len, read_00000_delim, 1); if (read_00000_res) {} //silence unused variable warning free(read_00000); if (read_00000_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00001; unsigned int read_00001_len; unsigned int read_00001_ptr = 0; //**** delimited cgc_read static unsigned char read_00001_delim[] = "\x0a"; read_00001 = NULL; read_00001_len = 0; int read_00001_res = delimited_read(0, &read_00001, &read_00001_len, read_00001_delim, 1); if (read_00001_res) {} //silence unused variable warning free(read_00001); if (read_00001_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00002; unsigned int read_00002_len; unsigned int read_00002_ptr = 0; //**** delimited cgc_read static unsigned char read_00002_delim[] = "\x0a"; read_00002 = NULL; read_00002_len = 0; int read_00002_res = delimited_read(0, &read_00002, &read_00002_len, read_00002_delim, 1); if (read_00002_res) {} //silence unused variable warning free(read_00002); if (read_00002_ptr) {} //silence unused variable warning if any } while (0); delay(100); do { //*** writing data static unsigned char write_00011_00000[] = "\x71\x0a"; static unsigned int write_00011_00000_len = 2; unsigned char *write_00011 = NULL; unsigned int write_00011_len = 0; write_00011 = append_buf(write_00011, &write_00011_len, write_00011_00000, write_00011_00000_len); if (write_00011_len > 0) { transmit_all(1, write_00011, write_00011_len); } free(write_00011); } while (0); }