rendered paste body#include <stdio.h>#include <stdlib.h>#include <string.h>#include "scaler.h"#include "modes.h"char *dec2hex(int dec) { char *hex = " "; sprintf(hex, "%x", dec); return hex;}void sendcommand(FILE* device, int code, int extra) { int i; char extrastr[2]; char cmd[10] = "L "; strcat(cmd, dec2hex(code)); strcat(cmd, dec2hex(~code)); if(extra) { itoa(extra, extrastr, 10); strcat(cmd, " "); strcat(cmd, extrastr); } strcat(cmd, "\x0d"); fprintf(device, cmd);}int main(int argc, char *argv[]) { int devnum; int modenum; int i; int j; char device[5]; char settings[45]; char temp[5]; FILE* scaler; while(1) { do { system("CLS"); printf("Vilken COM-port? 1-4\n"); devnum = fgetc(stdin) - '0'; fgetc(stdin); } while(!(devnum >= 1 && devnum <= 4)); sprintf(device, "com%i:", devnum); sprintf(settings, "mode %s baud=9600 parity=n data=8 stop=1", device); system(settings); if(scaler = fopen(device, "w+")) { while(1) { do { system("CLS"); printf("VP720XL Software for Geekmeet\n\n"); printf("Select mode:\n"); for(i = 0; i < sizeof(Modes) / sizeof(Mode); i++) { printf("\t(%c) %s\n", 'a' + i , Modes[i].name); } modenum = fgetc(stdin) - 'a'; fgetc(stdin); } while(!(modenum >= 0 && modenum <= sizeof(Modes) / sizeof(Mode))); for(j = 0; j <= sizeof(Modes[i].commands)/sizeof(Command); j++) { printf("%i %i", Modes[i].commands[j].cmd, Modes[i].commands[j].extra); system("PAUSE"); /* sendcommand(scaler, Modes[i].commands[j].cmd, Modes[i].commands[j].extra); */ } } } else { printf("Kunde ej öppna %s.\n", device); } }}