437b3ba8 |
1 | #include <stdio.h> |
2 | #include <termios.h> |
3 | #include <sys/types.h> |
4 | #include <sys/stat.h> |
5 | #include <fcntl.h> |
6 | #include <signal.h> |
7 | #include <stdlib.h> |
8 | |
9 | struct termios orgstate; |
10 | struct termios workstate; |
11 | |
12 | #define PORT_FILE "/dev/ttyS0" |
13 | #define BUFFER_SIZE 1000000 |
14 | |
15 | char * buffer; |
16 | int sp, ep, count, portfd; |
17 | |
18 | void sighandler(int sig){ |
19 | sp=0; |
20 | ep=count-1; |
21 | close (portfd); |
22 | // fprintf(stderr,"%i %i\n", sp, ep); |
23 | if (count>0) { |
24 | while(buffer[sp]==0) sp++; |
25 | while(buffer[ep]==0) ep--; |
26 | } |
27 | |
28 | write(1,buffer+sp,ep-sp+1); |
29 | tcdrain(2); |
30 | fprintf(stderr,"Eingelesen: %i\n",ep-sp+1); |
31 | tcsetattr(portfd, TCSANOW, &orgstate); |
32 | close(portfd); |
33 | exit(0); |
34 | } |
35 | |
36 | int main (int argc, char ** argv){ |
37 | |
38 | portfd=open(PORT_FILE, O_RDWR); |
39 | tcgetattr(portfd, &orgstate); |
40 | tcgetattr(portfd, &workstate); |
41 | cfmakeraw(&workstate); |
42 | // workstate.c_oflag=0; |
43 | workstate.c_cflag|=CS8+CREAD+CLOCAL+CRTSCTS+CSTOPB ; |
44 | // workstate.c_lflag=0; |
45 | cfsetspeed(&workstate, B4800); |
46 | tcsetattr(portfd, TCSANOW, &workstate); |
47 | count=0; |
48 | |
49 | signal(SIGINT, sighandler); |
50 | buffer=(char *) malloc(BUFFER_SIZE); |
51 | 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 112.