Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <sys/ioctl.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <fcntl.h>
  5.  
  6. int main(int argc, char **argv)
  7. {
  8.     int eingabe = 0;
  9.     int port;
  10.     int i = 0;
  11.  
  12.     port = open ("/dev/ttyUSB0", O_RDWR);
  13.     if (port == -1)
  14.     {
  15.       printf("Port konnte nicht geoeffnet werden! \n");
  16.     }
  17.  
  18.     if (eingabe == 0) i |= TIOCM_DTR; // DTR deaktivieren
  19.     ioctl (port, TIOCMBIC, &i);
  20.  
  21.     ioctl( port, TIOCSBRK, NULL ); // TXD aktivieren
  22.    
  23.     printf("die LED sollte jetzt leuchten \n");
  24.     printf("geben Sie jetzt ne Zahl ein \n");
  25.     scanf("%d", &eingabe); 
  26.     printf("Eingabe ist: %d \n", eingabe);
  27.  
  28.     ioctl( port, TIOCCBRK, NULL ); //TXD deaktivieren
  29.  
  30.     close (port);
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement