This commit is contained in:
Gerolf Ziegenhain 2016-10-04 21:05:21 +02:00
parent 370858ce8e
commit a43019e565

View File

@ -24,10 +24,10 @@
#include "beep.h" #include "beep.h"
#include "util.h" #include "util.h"
//#define RASPI
// http://raspberrypiguide.de/howtos/raspberry-pi-gpio-how-to/ // http://raspberrypiguide.de/howtos/raspberry-pi-gpio-how-to/
#ifdef RASPI #ifdef RASPI
#include <wiringPi.h> #include <wiringPi.h>
#define TX_RASPI_PIN 5
#endif #endif
@ -60,7 +60,9 @@ void inthandler(int sig)
signal(sig, SIG_IGN); signal(sig, SIG_IGN);
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0); send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
close(fd_socket); close(fd_socket);
#ifdef TX_SERIAL
close(fd_serial); close(fd_serial);
#endif
exit(1); exit(1);
} }
@ -78,7 +80,7 @@ void txloop (void)
while(serial_status & TIOCM_DSR) ioctl(fd_serial, TIOCMGET, &serial_status); while(serial_status & TIOCM_DSR) ioctl(fd_serial, TIOCMGET, &serial_status);
#endif #endif
#ifdef RASPI #ifdef RASPI
while(digitalRead(5)==1) while(digitalRead(TX_RASPI_PIN)==1)
{ {
} }
#endif #endif
@ -95,7 +97,7 @@ void txloop (void)
if(serial_status & TIOCM_DSR) break; if(serial_status & TIOCM_DSR) break;
#endif #endif
#ifdef RASPI #ifdef RASPI
if(digitalRead(5)==1) break; if(digitalRead(TX_RASPI_PIN)==1) break;
#endif #endif
tx_timeout = fastclock() - key_release_t1; tx_timeout = fastclock() - key_release_t1;
if(tx_timeout > TX_TIMEOUT) return; if(tx_timeout > TX_TIMEOUT) return;
@ -247,18 +249,18 @@ int main(int argc, char *argv[])
#ifdef TX_SERIAL #ifdef TX_SERIAL
fd_serial = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY); fd_serial = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY);
if(fd_serial == -1) { if(fd_serial == -1) {
fprintf(stderr,"Unable to open serial port %s.\n", serialport); fprintf(stderr,"Unable to open serial port %s.\n", serialport);
} }
#endif #endif
#ifdef RASPI #ifdef RASPI
// Starte die WiringPi-Api (wichtig) if (wiringPiSetup() == -1)
if (wiringPiSetup() == -1) {
return 1; fprintf(stderr,"Unable to setup wiringPi for PIN %d\n", TX_RASPI_PIN);
// Schalte GPIO 24 (=WiringPi Pin 5) auf Eingang exit (1);
pinMode(5, INPUT); }
pinMode(TX_RASPI_PIN, INPUT);
//if (digitalRead(5)==1)
#endif #endif
freeaddrinfo(servinfo); /* all done with this structure */ freeaddrinfo(servinfo); /* all done with this structure */