/* Program to flash the hacklace */ /* Published under the terms and conditions of the WTFPL 2 */ /* Copyright (c) 2013 by Robert Clausecker */ #include #include #include #include #include #include int main(int argc, char **argv) { int tty, i; FILE *conf; char buffer[80]; struct termios termios; if (argc != 3) { fprintf(stderr,"Usage: %s tty config\n",argv[0]); return EXIT_FAILURE; } tty = open(argv[1],O_WRONLY|O_NOCTTY); if (tty == -1) { perror("Can't open terminal device"); return EXIT_FAILURE; } conf = fopen(argv[2],"r"); if (conf == NULL) { perror("Can't open config file"); return EXIT_FAILURE; } tcgetattr(tty,&termios); cfsetspeed(&termios,B2400); tcsetattr(tty,TCSANOW,&termios); write(tty,"\033HL",3); i = fread(buffer,1,80,conf); while (i) { write(tty,buffer,i); i = fread(buffer,1,80,conf); } write(tty,"\033",1); return EXIT_SUCCESS; }