int receive(char *s) { int len = 127; //char buf[len]; memset(s, 0, len); int check = ir_receive(s, len); if(check) len = 1 + strlen(s); else len = 0; //memcpy(s, buf, len); return len; }
int main(int argc, char **argv) { unsigned long data[1024]; int datalen = 0; int ret = 0; memmap_ctor(); printf("argc :%d %c\n",argc,argv[1][0]); if (argc >= 2 && argv[1][0] == 'l') { pinMode(P8_3, INPUT); ret = ir_receive(P8_3,data,1024,&datalen); if (!ret) { puts("ERROR!!"); return -1; } ir_save("ir1.dat",data,datalen); return 0; } if (argc >= 2 && argv[1][0] == 's') { pinMode(P8_4, OUTPUT); ret = ir_load("ir1.dat",data,1024,&datalen); if (!ret) { puts("ERROR!!"); return -1; } printf("load %d byte\n",datalen); ret = ir_send(P8_4,data,datalen); if (!ret) { puts("ERROR!!"); return -1; } return 0; } memmap_dtor(); return 0; }