static void setup(const char* path) { struct option_t option; int r; if (access(path, R_OK) != 0) { fprintf(stderr, "Cannot open %s for read\n", path); exit(EXIT_FAILURE); } if (hw_choose_driver("file") == -1) { fputs("Cannot load file driver (bad plugin path?)\n", stderr); exit(EXIT_FAILURE); } r = curr_driver->open_func("dummy.out"); if (r == 0) { fputs("Cannot open driver\n", stderr); exit(EXIT_FAILURE); } r = curr_driver->init_func(); if (r == 0) { fputs("Cannot init driver\n", stderr); exit(EXIT_FAILURE); } strcpy(option.key, "set-infile"); strncpy(option.value, path, sizeof(option.value)); r = curr_driver->drvctl_func(DRVCTL_SET_OPTION, (void*)&option); if (r != 0) { fputs("Cannot set driver infile.\n", stderr); exit(EXIT_FAILURE); } }
int main(int argc, char **argv) { log_shell_enable(); log_shell_disable(); log_level_set(LOG_NOTICE); progname = strdup("pilight-learn"); struct options_t *options = NULL; lirc_t data; char *socket = strdup("/dev/lirc0"); char *args; int have_device = 0; int use_lirc = USE_LIRC; int gpio_in = GPIO_IN_PIN; int duration = 0; int i = 0; int y = 0; int z = 0; steps_t state = CAPTURE; steps_t pState = WAIT; int recording = 1; int bit = 0; int raw[255]; int pRaw[255]; int code[255]; int onCode[255]; int offCode[255]; int allCode[255]; int unit1Code[255]; int unit2Code[255]; int unit3Code[255]; int binary[255]; int pBinary[255]; int onBinary[255]; int offBinary[255]; int allBinary[255]; int unit1Binary[255]; int unit2Binary[255]; int unit3Binary[255]; int loop = 1; int temp[75]; int footer = 0; int header = 0; int pulse = 0; int onoff[75]; int all[75]; int unit[75]; int rawLength = 0; int binaryLength = 0; memset(onoff,-1,75); memset(all,-1,75); memset(unit,-1,75); options_add(&options, 'H', "help", no_value, 0, NULL); options_add(&options, 'V', "version", no_value, 0, NULL); options_add(&options, 'S', "socket", has_value, 0, "^/dev/([A-Za-z]+)([0-9]+)"); options_add(&options, 'L', "lirc", no_value, 0, NULL); options_add(&options, 'G', "gpio", has_value, 0, "^[0-7]$"); while (1) { int c; c = options_parse(&options, argc, argv, 1, &args); if (c == -1) break; switch (c) { case 'H': printf("Usage: %s [options]\n", progname); printf("\t -H --help\t\tdisplay usage summary\n"); printf("\t -V --version\t\tdisplay version\n"); printf("\t -S --socket=socket\tread from given socket\n"); printf("\t -L --lirc\t\tuse the lirc_rpi kernel module\n"); printf("\t -G --gpio=#\t\tGPIO pin we're directly reading from\n"); return (EXIT_SUCCESS); break; case 'V': printf("%s %s\n", progname, "1.0"); return (EXIT_SUCCESS); break; case 'L': use_lirc = 1; break; case 'G': gpio_in = atoi(optarg); use_lirc = 0; break; case 'S': free(socket); socket = optarg; have_device = 1; break; default: printf("Usage: %s [options]\n", progname); return (EXIT_FAILURE); break; } } if(use_lirc == 1) { hw_choose_driver(NULL); if(strcmp(socket, "/var/lirc/lircd") == 0) { logprintf(LOG_ERR, "refusing to connect to lircd socket"); return EXIT_FAILURE; } if(have_device) hw.device = socket; if(!hw.init_func()) { return EXIT_FAILURE; } } else { if(wiringPiSetup() == -1) return EXIT_FAILURE; if(wiringPiISR(gpio_in, INT_EDGE_BOTH) < 0) { logprintf(LOG_ERR, "unable to register interrupt for pin %d", gpio_in) ; return 1 ; } (void)piHiPri(55); } printf("Please make sure the daemon is not running when using this debugger.\n\n"); while(loop) { switch(state) { case CAPTURE: printf("1. Please send and hold one of the OFF buttons."); break; case ON: /* Store the previous OFF button code */ for(i=0;i<binaryLength;i++) { offBinary[i] = binary[i]; } printf("2. Please send and hold the ON button for the same device\n"); printf(" as for which you send the previous OFF button."); break; case OFF: /* Store the previous ON button code */ for(i=0;i<binaryLength;i++) { onBinary[i] = binary[i]; } for(i=0;i<rawLength;i++) { onCode[i] = code[i]; } z=0; /* Compare the ON and OFF codes and save bit that are different */ for(i=0;i<binaryLength;i++) { if(offBinary[i] != onBinary[i]) { onoff[z++]=i; } } for(i=0;i<rawLength;i++) { offCode[i] = code[i]; } printf("3. Please send and hold (one of the) ALL buttons.\n"); printf(" If you're remote doesn't support turning ON or OFF\n"); printf(" all devices at once, press the same OFF button as in\n"); printf(" the beginning."); break; case ALL: z=0; memset(temp,-1,75); /* Store the ALL code */ for(i=0;i<binaryLength;i++) { allBinary[i] = binary[i]; if(allBinary[i] != onBinary[i]) { temp[z++] = i; } } for(i=0;i<rawLength;i++) { allCode[i] = code[i]; } /* Compare the ALL code to the ON and OFF code and store the differences */ y=0; for(i=0;i<binaryLength;i++) { if(allBinary[i] != offBinary[i]) { all[y++] = i; } } if((unsigned int)z < y) { for(i=0;i<z;i++) { all[z]=temp[z]; } } printf("4. Please send and hold the ON button with the lowest ID."); break; case UNIT1: /* Store the lowest unit code */ for(i=0;i<binaryLength;i++) { unit1Binary[i] = binary[i]; } for(i=0;i<rawLength;i++) { unit1Code[i] = code[i]; } printf("5. Please send and hold the ON button with the second to lowest ID."); break; case UNIT2: /* Store the second to lowest unit code */ for(i=0;i<binaryLength;i++) { unit2Binary[i] = binary[i]; } for(i=0;i<rawLength;i++) { unit2Code[i] = code[i]; } printf("6. Please send and hold the ON button with the highest ID."); break; case PROCESSUNIT: z=0; /* Store the highest unit code and compare the three codes. Store all bit that are different */ for(i=0;i<binaryLength;i++) { unit3Binary[i] = binary[i]; if((unit2Binary[i] != unit1Binary[i]) || (unit1Binary[i] != unit3Binary[i]) || (unit2Binary[i] != unit3Binary[i])) { unit[z++]=i; } } for(i=0;i<rawLength;i++) { unit3Code[i] = code[i]; } state=STOP; break; case WAIT: case STOP: default:; } fflush(stdout); if(state!=WAIT) pState=state; if(state==STOP) loop = 0; else state=WAIT; if(use_lirc == 1) { data = hw.readdata(0); duration = (data & PULSE_MASK); } else { duration = irq_read(gpio_in); } /* If we are recording, keep recording until the next footer has been matched */ if(recording == 1) { if(bit < 255) { raw[bit++] = duration; } else { bit = 0; recording = 0; } } /* First try to catch code that seems to be a footer. If a real footer has been recognized, start using that as the new footer */ if((duration > 5000 && duration < 100000 && footer == 0) || ((footer-(footer*0.1)<duration) && (footer+(footer*0.1)>duration))) { recording = 1; /* Check if we are recording similar codes */ for(i=0;i<(bit-1);i++) { if(!(((pRaw[i]-(pRaw[i]*0.3)) < raw[i]) && ((pRaw[i]+(pRaw[i]*0.3)) > raw[i]))) { y=0; z=0; recording=0; } pRaw[i]=raw[i]; } y++; /* Continue if we have 2 matches */ if(y>2) { /* If we are certain we are recording similar codes. Save the header values and the raw code length */ if(footer>0) { if(header == 0) { header=raw[1]; } if(rawLength == 0) rawLength=bit; } if(rawLength == 0 || rawLength == bit) { /*|| ((((raw[0]-(raw[0]*0.3)) < header[0]) || ((raw[0]+(raw[0]*0.3)) > header[0])) && (((raw[1]-(raw[1]*0.3)) < header[1]) || ((raw[1]+(raw[1]*0.3)) > header[1])) && (((raw[bit-1]-(raw[bit-1]*0.1)) < footer) || ((raw[bit-1]+(raw[bit-1]*0.1)) > footer)))) {*/ /* Try to catch the footer, and the low and high values */ for(i=0;i<bit;i++) { if((i+1)<bit && i > 2 && footer > 0) { if((raw[i]/PULSE_LENGTH) >= 2) { pulse=raw[i]; } } if(duration > 5000 && duration < 100000) footer=raw[i]; } /* If we have gathered all data, stop with the loop */ if(header > 0 && footer > 0 && pulse > 0 && rawLength > 0) { /* Convert the raw code into binary code */ for(i=0;i<rawLength;i++) { if((unsigned int)raw[i] > (pulse-PULSE_LENGTH)) { code[i]=1; } else { code[i]=0; } } for(i=2;i<rawLength; i+=4) { if(code[i+1] == 1) { binary[i/4]=1; } else { binary[i/4]=0; } } if(binaryLength == 0) binaryLength = (int)((float)i/4); /* Check if the subsequent binary code matches to check if the same button was still held */ if(binaryLength == (i/4)) { for(i=0;i<binaryLength;i++) { if(pBinary[i] != binary[i]) { z=1; } } /* If we are capturing a different button continue to the next step */ if(z==1 || state == CAPTURE) { switch(pState) { case CAPTURE: state=ON; break; case ON: state=OFF; break; case OFF: state=ALL; break; case ALL: state=UNIT1; break; case UNIT1: state=UNIT2; break; case UNIT2: state=PROCESSUNIT; break; case PROCESSUNIT: state=STOP; break; case WAIT: case STOP: default:; } printf(" Done.\n\n"); pState=WAIT; } } } } } bit=0; } /* Reset the button repeat counter */ if(z==1) { z=0; for(i=0;i<binaryLength;i++) { pBinary[i]=binary[i]; } } } rmDup(all, onoff); rmDup(unit, onoff); rmDup(all, unit); /* Print everything */ printf("--[RESULTS]--\n"); printf("\n"); if(normalize(header) == normalize(pulse)) { printf("header:\t\t0\n"); } else { printf("header:\t\t%d\n",normalize(header)); } printf("pulse:\t\t%d\n",normalize(pulse)); printf("footer:\t\t%d\n",normalize(footer)); printf("rawLength:\t%d\n",rawLength); printf("binaryLength:\t%d\n",binaryLength); printf("\n"); printf("on-off bit(s):\t"); z=0; while(onoff[z] > -1) { printf("%d ",onoff[z++]); } printf("\n"); printf("all bit(s):\t"); z=0; while(all[z] > -1) { printf("%d ",all[z++]); } printf("\n"); printf("unit bit(s):\t"); z=0; while(unit[z] > -1) { printf("%d ",unit[z++]); } printf("\n\n"); printf("Raw code:\n"); for(i=0;i<rawLength;i++) { printf("%d ",normalize(raw[i])*PULSE_LENGTH); } printf("\n"); printf("Raw simplified:\n"); printf("On:\t"); for(i=0;i<rawLength;i++) { printf("%d",onCode[i]); } printf("\n"); printf("Off:\t"); for(i=0;i<rawLength;i++) { printf("%d",offCode[i]); } printf("\n"); printf("All:\t"); for(i=0;i<rawLength;i++) { printf("%d",allCode[i]); } printf("\n"); printf("Unit 1:\t"); for(i=0;i<rawLength;i++) { printf("%d",unit1Code[i]); } printf("\n"); printf("Unit 2:\t"); for(i=0;i<rawLength;i++) { printf("%d",unit2Code[i]); } printf("\n"); printf("Unit 3:\t"); for(i=0;i<rawLength;i++) { printf("%d",unit3Code[i]); } printf("\n"); printf("Binary code:\n"); printf("On:\t"); for(i=0;i<binaryLength;i++) { printf("%d",onBinary[i]); } printf("\n"); printf("Off:\t"); for(i=0;i<binaryLength;i++) { printf("%d",offBinary[i]); } printf("\n"); printf("All:\t"); for(i=0;i<binaryLength;i++) { printf("%d",allBinary[i]); } printf("\n"); printf("Unit 1:\t"); for(i=0;i<binaryLength;i++) { printf("%d",unit1Binary[i]); } printf("\n"); printf("Unit 2:\t"); for(i=0;i<binaryLength;i++) { printf("%d",unit2Binary[i]); } printf("\n"); printf("Unit 3:\t"); for(i=0;i<binaryLength;i++) { printf("%d",unit3Binary[i]); } printf("\n"); free(socket); free(progname); return (EXIT_SUCCESS); }
int main(int argc, char **argv) { enable_shell_log(); disable_file_log(); set_loglevel(LOG_NOTICE); progname = malloc((10*sizeof(char))+1); progname = strdup("433-debug"); #ifdef USE_LIRC lirc_t data; char *socket = strdup("/dev/lirc0"); int have_device = 0; #else int newDuration; #endif int duration = 0; int i = 0; int y = 0; int recording = 1; int bit = 0; int raw[255]; int pRaw[255]; int code[255]; int binary[255]; int footer = 0; int header = 0; int pulse = 0; int rawLength = 0; int binaryLength = 0; int loop = 1; #ifdef USE_LIRC hw_choose_driver(NULL); #endif addOption(&options, 'H', "help", no_value, 0, NULL); addOption(&options, 'V', "version", no_value, 0, NULL); #ifdef USE_LIRC addOption(&options, 'S', "socket", has_value, 0, "^/dev/([A-Za-z]+)([0-9]+)"); #endif while (1) { int c; c = getOptions(&options, argc, argv, 1); if(c == -1) break; switch (c) { case 'h': printf("Usage: %s [options]\n", progname); printf("\t -H --help\t\tdisplay usage summary\n"); printf("\t -V --version\t\tdisplay version\n"); #ifdef USE_LIRC printf("\t -S --socket=socket\tread from given socket\n"); #endif return (EXIT_SUCCESS); break; case 'v': printf("%s %s\n", progname, "1.0"); return (EXIT_SUCCESS); break; #ifdef USE_LIRC case 'S': socket = optarg; have_device = 1; break; #endif default: printf("Usage: %s [options]\n", progname); return (EXIT_FAILURE); break; } } #ifdef USE_LIRC if(strcmp(socket, "/var/lirc/lircd") == 0) { logprintf(LOG_ERR, "refusing to connect to lircd socket"); return EXIT_FAILURE; } if(have_device) hw.device = socket; if(!hw.init_func()) { return EXIT_FAILURE; } #endif /* End of the original (but stripped) code of mode2 */ #ifndef USE_LIRC if(gpio_request(GPIO_IN_PIN) == 0) { /* Attach an interrupt to the requested pin */ irq_attach(GPIO_IN_PIN, CHANGE); } else { return EXIT_FAILURE; } #endif while(loop) { #ifdef USE_LIRC data = hw.readdata(0); duration = (data & PULSE_MASK); #else unsigned short a = 0; if((newDuration = irq_read()) == 1) { continue; } for(a=0; a<2; a++) { if(a==0) { duration = PULSE_LENGTH; } else { duration = newDuration; if(duration < 750) { duration = PULSE_LENGTH; } } #endif /* If we are recording, keep recording until the next footer has been matched */ if(recording == 1) { if(bit < 255) { raw[bit++] = duration; } else { bit = 0; recording = 0; } } /* First try to catch code that seems to be a footer. If a real footer has been recognized, start using that as the new footer */ if((duration > 5000 && duration < 100000 && footer == 0) || ((footer-(footer*0.1)<duration) && (footer+(footer*0.1)>duration))) { recording = 1; /* Check if we are recording similar codes */ for(i=0; i<(bit-1); i++) { if(!(((pRaw[i]-(pRaw[i]*0.3)) < raw[i]) && ((pRaw[i]+(pRaw[i]*0.3)) > raw[i]))) { y=0; recording=0; } pRaw[i]=raw[i]; } y++; /* Continue if we have 2 matches */ if(y>2) { /* If we are certain we are recording similar codes. Save the header values and the raw code length */ if(footer>0) { if(header == 0) { header=raw[1]; } if(rawLength == 0) rawLength=bit; } /* Try to catch the footer, and the low and high values */ for(i=0; i<bit; i++) { if((i+1)<bit && i > 2 && footer > 0) { if((raw[i]/PULSE_LENGTH) >= 2) { pulse=raw[i]; } } if(duration > 5000 && duration < 100000) { footer=raw[i]; } } /* If we have gathered all data, stop with the loop */ if(header > 0 && footer > 0 && pulse > 0 && rawLength > 0) { loop = 0; } } bit=0; } fflush(stdout); #ifndef USE_LIRC } #endif }; /* Convert the raw code into binary code */ for(i=0; i<rawLength; i++) { if((unsigned int)raw[i] > (pulse-PULSE_LENGTH)) { code[i]=1; } else { code[i]=0; } } for(i=2; i<rawLength; i+=4) { if(code[i+1] == 1) { binary[i/4]=1; } else { binary[i/4]=0; } } binaryLength = (int)((float)i/4); /* Print everything */ printf("--[RESULTS]--\n"); printf("\n"); printf("header:\t\t%d\n",normalize(header)); printf("pulse:\t\t%d\n",normalize(pulse)); printf("footer:\t\t%d\n",normalize(footer)); printf("rawLength:\t%d\n",rawLength); printf("binaryLength:\t%d\n",binaryLength); printf("\n"); printf("Raw code:\n"); for(i=0; i<rawLength; i++) { printf("%d ",normalize(raw[i])*PULSE_LENGTH); } printf("\n"); printf("Binary code:\n"); for(i=0; i<binaryLength; i++) { printf("%d",binary[i]); } printf("\n"); return (EXIT_SUCCESS); }
int main(int argc, char **argv) { fd_set rfds; int xfd, maxfd; int fd; __u32 mode; lirc_t data; lirc_t x1, y1, x2, y2; int result; char textbuffer[80]; int div = 5; int dmode = 0; struct stat s; int use_stdin = 0; int have_device = 0; int use_raw_access = 0; char *device = LIRC_DRIVER_DEVICE; char *geometry = NULL; progname = "xmode2"; hw_choose_driver(NULL); while (1) { int c; static struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"device", required_argument, NULL, 'd'}, {"driver", required_argument, NULL, 'H'}, {"geometry", required_argument, NULL, 'g'}, {"timediv", required_argument, NULL, 't'}, {"mode", no_argument, NULL, 'm'}, {"raw", no_argument, NULL, 'r'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hvd:H:g:t:mr", long_options, NULL); if (c == -1) break; switch (c) { case 'h': printf("Usage: %s [options]\n", progname); printf("\t -h --help\t\tdisplay usage summary\n"); printf("\t -v --version\t\tdisplay version\n"); printf("\t -d --device=device\tread from given device\n"); printf("\t -H --driver=driver\t\tuse given driver\n"); printf("\t -g --geometry=geometry\twindow geometry\n"); printf("\t -t --timediv=value\tms per unit\n"); printf("\t -m --mode\t\tenable alternative display mode\n"); printf("\t -r --raw\t\taccess device directly\n"); return (EXIT_SUCCESS); case 'H': if (hw_choose_driver(optarg) != 0) { fprintf(stderr, "Driver `%s' not supported.\n", optarg); hw_print_drivers(stderr); exit(EXIT_FAILURE); } break; case 'v': printf("%s %s\n", progname, VERSION); return (EXIT_SUCCESS); case 'd': device = optarg; have_device = 1; break; case 'g': geometry = optarg; break; case 't': /* timediv */ div = strtol(optarg, NULL, 10); break; case 'm': dmode = 1; break; case 'r': use_raw_access = 1; break; default: printf("Usage: %s [options]\n", progname); return (EXIT_FAILURE); } } if (optind < argc) { fprintf(stderr, "%s: too many arguments\n", progname); return (EXIT_FAILURE); } if (strcmp(device, LIRCD) == 0) { fprintf(stderr, "%s: refusing to connect to lircd socket\n", progname); return EXIT_FAILURE; } if (!isatty(STDIN_FILENO)) { use_stdin = 1; fd = STDIN_FILENO; } else if (use_raw_access) { fd = open(device, O_RDONLY); if (fd == -1) { fprintf(stderr, "%s: error opening %s\n", progname, device); perror(progname); exit(EXIT_FAILURE); }; if ((fstat(fd, &s) != -1) && (S_ISFIFO(s.st_mode))) { /* can't do ioctls on a pipe */ } else if ((fstat(fd, &s) != -1) && (!S_ISCHR(s.st_mode))) { fprintf(stderr, "%s: %s is not a character device\n", progname, device); fprintf(stderr, "%s: use the -d option to specify the correct device\n", progname); close(fd); exit(EXIT_FAILURE); } else if (ioctl(fd, LIRC_GET_REC_MODE, &mode) == -1) { printf("This program is only intended for receivers supporting the pulse/space layer.\n"); printf("Note that this is no error, but this program " "simply makes no sense for your\n" "receiver.\n"); printf("In order to test your setup run lircd with " "the --nodaemon option and \n" "then check if the remote works with the irw tool.\n"); close(fd); exit(EXIT_FAILURE); } } else { if (have_device) hw.device = device; if (!hw.init_func()) { return EXIT_FAILURE; } fd = hw.fd; /* please compiler */ mode = hw.rec_mode; if (mode != LIRC_MODE_MODE2) { if (strcmp(hw.name, "default") == 0) { printf("Please use the --raw option to access " "the device directly instead through\n" "the abstraction layer.\n"); } else { printf("This program does not work for this hardware yet\n"); } exit(EXIT_FAILURE); } } initscreen(geometry); xfd = XConnectionNumber(d1); maxfd = fd > xfd ? fd : xfd; y1 = 20; x1 = x2 = 0; sprintf(textbuffer, "%d ms/unit", div); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); XFlush(d1); while (1) { while (XPending(d1) > 0) { XNextEvent(d1, &event_return1); switch (event_return1.type) { case KeyPress: if (event_return1.xkey.keycode == XKeysymToKeycode(d1, XStringToKeysym("q"))) { closescreen(); exit(1); } break; case Expose: case ConfigureNotify: switch (event_return1.type) { case Expose: break; case ConfigureNotify: if (w1_w == event_return1.xconfigure.width && w1_h == event_return1.xconfigure.height) { continue; } w1_w = event_return1.xconfigure.width; w1_h = event_return1.xconfigure.height; break; } XClearWindow(d1, w1); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); XFlush(d1); // printf("resize \n"); break; default: ; } } FD_ZERO(&rfds); FD_SET(fd, &rfds); FD_SET(xfd, &rfds); select(maxfd + 1, &rfds, NULL, NULL, NULL); if (FD_ISSET(fd, &rfds)) { if (use_stdin) { static int space = 1; unsigned long scan; if (space) { result = fscanf(stdin, "space %ld\n", &scan); } else { result = fscanf(stdin, "pulse %ld\n", &scan); } if (result == 1) { data = (lirc_t) scan; if (!space) data |= PULSE_BIT; } else { fd = STDOUT_FILENO; } space = !space; } else { result = read(fd, &data, sizeof(data)); } if (result != 0) { // printf("%.8x\t",data); x2 = (data & PULSE_MASK) / (div * 50); if (x2 > 400) { if (!dmode) { y1 += 15; } else { y1++; } x1 = 0; } else { if (x1 == 0) { if (!dmode) XDrawLine(d1, w1, gc2, x1, y1 + 10, x1 + 10, y1 + 10); x1 += 10; if (!dmode) XDrawLine(d1, w1, gc2, x1, y1 + 10, x1, y1); } if (x1 < w1_w) { if (dmode) { if (data & PULSE_BIT) XDrawLine(d1, w1, gc2, x1, y1, x1 + x2, y1); x1 += x2; } else { XDrawLine(d1, w1, gc2, x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1 + x2, ((data & PULSE_BIT) ? y1 : y1 + 10)); x1 += x2; XDrawLine(d1, w1, gc2, x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1, ((data & PULSE_BIT) ? y1 + 10 : y1)); } } } if (y1 > w1_h) { y1 = 20; XClearWindow(d1, w1); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); } } XFlush(d1); } } exit(EXIT_SUCCESS); }