Sie sind nicht angemeldet.
Lieber Besucher, herzlich willkommen bei: Aqua Computer Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.
![]() |
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
int fd = 0; unsigned int status = 0; fd = open(serial_device, O_RDWR | O_NOCTTY); if (fd > 0) { ioctl(fd, TIOCMGET , &status); close(fd); if(status==16390)remote_key=0; //keine taster if(status==16646)remote_key=11; //taste 1 & 1 if(status==16710)remote_key=12; //taste 1 & 2 if(status==16678)remote_key=13; //taste 1 & 3 if(status==16774)remote_key=14; //taste 1 & 4 if(status==16710)remote_key=21; //taste 2 & 1 if(status==16454)remote_key=22; //taste 2 & 2 if(status==16486)remote_key=23; //taste 2 & 3 if(status==16582)remote_key=24; //taste 2 & 4 if(status==16678)remote_key=31; //taste 3 & 1 if(status==16486)remote_key=32; //taste 3 & 2 if(status==16422)remote_key=33; //taste 3 & 3 if(status==16550)remote_key=34; //taste 3 & 4 if(status==16774)remote_key=41; //taste 4 & 1 if(status==16582)remote_key=42; //taste 4 & 2 if(status==16550)remote_key=43; //taste 4 & 3 if(status==16518)remote_key=44; //taste 4 & 4 } |
![]() |
Quellcode |
1 2 |
ioctl(fd, TIOCMGET , &status); close(fd); |
![]() |
Quellcode |
1 2 3 4 |
./com: line 7: int: command not found ./com: line 8: unsigned: command not found ./com: line 10: syntax error near unexpected token `(' ./com: line 10: `fd = open(serial_device, 0_RDWR | 0_NOCTTY);' |
![]() |
Quellcode |
1 2 3 4 5 6 7 8 9 |
com.c:7: error: parameter `fd' is initialized com.c:8: error: parameter `status' is initialized com.c:10: error: parse error before "fd" com.c:8: error: declaration for parameter `status' but no such parameter com.c:7: error: declaration for parameter `fd' but no such parameter com.c:10: error: number of arguments doesn't match prototype cc1: error: prototype declaration com.c:10:26: invalid suffix "_RDWR" on integer constant com.c:10:35: invalid suffix "_NOCTTY" on integer constant |
![]() |
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include <stdio.h> #include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #include <errno.h> #include <termio.h> static char serial_device[128] = "/dev/ttyS0"; static int get_remote_key() { int remote_key = 0; int fd = 0; unsigned int status = 0; fd = open(serial_device, O_RDWR | O_NOCTTY); if (fd > 0) { ioctl(fd, TIOCMGET , &status); close(fd); if (status & TIOCM_CD && !(status & TIOCM_DSR || status & TIOCM_CTS || status & TIOCM_RI)) remote_key = 1; else if (status & TIOCM_DSR && !(status & TIOCM_CD || status & TIOCM_CTS || status & TIOCM_RI)) remote_key = 2; else if (status & TIOCM_CTS && !(status & TIOCM_CD || status & TIOCM_DSR || status & TIOCM_RI)) remote_key = 3; else if (status & TIOCM_RI && !(status & TIOCM_CD || status & TIOCM_DSR || status & TIOCM_CTS)) remote_key = 4; } else remote_key = -1; return remote_key; } int main() { printf("Hallo zu hurras kleinem Tasterchen-Prograemmchen\n"); for(;;) { usleep(3000); printf("%d\n",get_remote_key()); } printf("bye\n"); return 0; } |
-