serial_sep

This commit is contained in:
Gerolf Ziegenhain 2016-10-04 20:58:30 +02:00
parent d6d0679fb5
commit d8815db878

View File

@ -41,7 +41,7 @@ long tx_timer = 0;
/* TX Methods */ /* TX Methods */
#define TX_NONE 0 #define TX_NONE 0
#define TX_SERIAL 1 //#define TX_SERIAL 1
#define TX_KEYBOARD 2 #define TX_KEYBOARD 2
#define TX_RASPI 3 #define TX_RASPI 3
@ -74,7 +74,9 @@ void txloop (void)
(int) ((key_press_t1 - key_release_t1) * -1); (int) ((key_press_t1 - key_release_t1) * -1);
//printf("space: %i\n", tx_data_packet.code[tx_data_packet.n -1]); //printf("space: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
#ifdef TX_SERIAL
while(serial_status & TIOCM_DSR) ioctl(fd_serial, TIOCMGET, &serial_status); while(serial_status & TIOCM_DSR) ioctl(fd_serial, TIOCMGET, &serial_status);
#endif
#ifdef RASPI #ifdef RASPI
while(digitalRead(5)==1) while(digitalRead(5)==1)
{ {
@ -88,8 +90,10 @@ void txloop (void)
//printf("mark: %i\n", tx_data_packet.code[tx_data_packet.n -1]); //printf("mark: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
while(1){ while(1){
#ifdef TX_SERIAL
ioctl(fd_serial, TIOCMGET, &serial_status); ioctl(fd_serial, TIOCMGET, &serial_status);
if(serial_status & TIOCM_DSR) break; if(serial_status & TIOCM_DSR) break;
#endif
#ifdef RASPI #ifdef RASPI
if(digitalRead(5)==1) break; if(digitalRead(5)==1) break;
#endif #endif
@ -241,6 +245,7 @@ int main(int argc, char *argv[])
s, sizeof s); s, sizeof s);
fprintf(stderr, "Connected to %s.\n", s); fprintf(stderr, "Connected to %s.\n", s);
beep_init(); beep_init();
#ifdef TX_SERIAL
if ((strcmp (serialport, "")) != 0) if ((strcmp (serialport, "")) != 0)
tx_method = TX_SERIAL; tx_method = TX_SERIAL;
@ -250,6 +255,7 @@ int main(int argc, char *argv[])
fprintf(stderr,"Unable to open serial port %s.\n", serialport); fprintf(stderr,"Unable to open serial port %s.\n", serialport);
} }
} }
#endif
#ifdef RASPI #ifdef RASPI
// Starte die WiringPi-Api (wichtig) // Starte die WiringPi-Api (wichtig)
@ -336,6 +342,7 @@ tx_method = TX_RASPI;
#endif #endif
tx_data_packet.n = 0; tx_data_packet.n = 0;
} }
#ifdef TX_SERIAL
if (tx_method == TX_SERIAL) { if (tx_method == TX_SERIAL) {
ioctl(fd_serial,TIOCMGET, &serial_status); ioctl(fd_serial,TIOCMGET, &serial_status);
if(serial_status & TIOCM_DSR){ if(serial_status & TIOCM_DSR){
@ -344,6 +351,7 @@ tx_method = TX_RASPI;
message(1); message(1);
} }
} }
#endif
#ifdef RASPI #ifdef RASPI
if (tx_method == TX_RASPI) { if (tx_method == TX_RASPI) {
@ -375,7 +383,9 @@ tx_method = TX_RASPI;
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
buzzer_stop(); buzzer_stop();
exit(0); exit(0);