459cc2df |
1 | /* Simple program to load paper tape over serial port. Does that twice and compares. */ |
2 | |
437b3ba8 |
3 | #include <stdio.h> |
4 | #include <termios.h> |
5 | #include <sys/types.h> |
6 | #include <sys/stat.h> |
7 | #include <fcntl.h> |
8 | #include <signal.h> |
9 | #include <stdlib.h> |
10 | |
459cc2df |
11 | |
437b3ba8 |
12 | struct termios orgstate; |
13 | struct termios workstate; |
14 | |
15 | #define PORT_FILE "/dev/ttyS0" |
16 | #define BUFFER_SIZE 1000000 |
17 | |
18 | char * buffer; |
19 | int sp, ep, count, portfd; |
20 | |
21 | void sighandler(int sig){ |
22 | sp=0; |
23 | ep=count-1; |
24 | close (portfd); |
25 | // fprintf(stderr,"%i %i\n", sp, ep); |
26 | if (count>0) { |
27 | while(buffer[sp]==0) sp++; |
28 | while(buffer[ep]==0) ep--; |
29 | } |
30 | |
31 | write(1,buffer+sp,ep-sp+1); |
32 | tcdrain(2); |
33 | fprintf(stderr,"Eingelesen: %i\n",ep-sp+1); |
34 | tcsetattr(portfd, TCSANOW, &orgstate); |
35 | close(portfd); |
36 | exit(0); |
37 | } |
38 | |
39 | int main (int argc, char ** argv){ |
40 | |
41 | portfd=open(PORT_FILE, O_RDWR); |
42 | tcgetattr(portfd, &orgstate); |
43 | tcgetattr(portfd, &workstate); |
44 | cfmakeraw(&workstate); |
45 | // workstate.c_oflag=0; |
46 | workstate.c_cflag|=CS8+CREAD+CLOCAL+CRTSCTS+CSTOPB ; |
47 | // workstate.c_lflag=0; |
48 | cfsetspeed(&workstate, B4800); |
49 | tcsetattr(portfd, TCSANOW, &workstate); |
50 | count=0; |
51 | |
52 | signal(SIGINT, sighandler); |
53 | buffer=(char *) malloc(BUFFER_SIZE); |
54 | Content-type: text/html
gitweb.hachti.de Git - h316.git/blame - pc-tools/src-filters/load.c
500 - Internal Server Error
Malformed UTF-8 character (fatal) at (eval 5) line 1, <$fd> line 129.