]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/ATC-Inputs.cxx
Switch from bool to int for more deterministic structure packing.
[flightgear.git] / src / Network / ATC-Inputs.cxx
index 0d11ca64e7ea154e0e8f24d8b7ac274f0d328cc5..d8e6a551e7d60236bcd83f3955d27e7fe7f8479d 100644 (file)
@@ -63,6 +63,7 @@ FGATCInput::FGATCInput( const int _board, const SGPath &_config_file ) :
 
 // Read analog inputs
 static void ATCReadAnalogInputs( int fd, unsigned char *analog_in_bytes ) {
+#if defined( unix ) || defined( __CYGWIN__ )
     // rewind
     lseek( fd, 0, SEEK_SET );
 
@@ -71,11 +72,13 @@ static void ATCReadAnalogInputs( int fd, unsigned char *analog_in_bytes ) {
        SG_LOG( SG_IO, SG_ALERT, "Read failed" );
        exit( -1 );
     }
+#endif
 }
 
 
 // Read status of radio switches and knobs
 static void ATCReadRadios( int fd, unsigned char *switch_data ) {
+#if defined( unix ) || defined( __CYGWIN__ )
     // rewind
     lseek( fd, 0, SEEK_SET );
 
@@ -84,11 +87,13 @@ static void ATCReadRadios( int fd, unsigned char *switch_data ) {
        SG_LOG( SG_IO, SG_ALERT, "Read failed" );
        exit( -1 );
     }
+#endif
 }
 
 
 // Read switch inputs
 static void ATCReadSwitches( int fd, unsigned char *switch_bytes ) {
+#if defined( unix ) || defined( __CYGWIN__ )
     // rewind
     lseek( fd, 0, SEEK_SET );
 
@@ -97,6 +102,7 @@ static void ATCReadSwitches( int fd, unsigned char *switch_bytes ) {
        SG_LOG( SG_IO, SG_ALERT, "Read failed" );
        exit( -1 );
     }
+#endif
 }
 
 
@@ -130,12 +136,14 @@ bool FGATCInput::open() {
     init_config();
 
     SG_LOG( SG_IO, SG_ALERT,
-           "Initializing ATC 610x hardware, please wait ..." );
+           "Initializing ATC input hardware, please wait ..." );
 
-    snprintf( lock_file, 256, "/proc/atc610x/board%d/lock", board );
-    snprintf( analog_in_file, 256, "/proc/atc610x/board%d/analog_in", board );
-    snprintf( radios_file, 256, "/proc/atc610x/board%d/radios", board );
-    snprintf( switches_file, 256, "/proc/atc610x/board%d/switches", board );
+    snprintf( analog_in_file, 256,
+              "/proc/atcflightsim/board%d/analog_in", board );
+    snprintf( radios_file, 256,
+              "/proc/atcflightsim/board%d/radios", board );
+    snprintf( switches_file, 256,
+              "/proc/atcflightsim/board%d/switches", board );
 
 #if defined( unix ) || defined( __CYGWIN__ )
 
@@ -143,15 +151,6 @@ bool FGATCInput::open() {
     // Open the /proc files
     /////////////////////////////////////////////////////////////////////
 
-    lock_fd = ::open( lock_file, O_RDWR );
-    if ( lock_fd == -1 ) {
-       SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
-       char msg[256];
-       snprintf( msg, 256, "Error opening %s", lock_file );
-       perror( msg );
-       exit( -1 );
-    }
-
     analog_in_fd = ::open( analog_in_file, O_RDONLY );
     if ( analog_in_fd == -1 ) {
        SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
@@ -186,7 +185,7 @@ bool FGATCInput::open() {
     /////////////////////////////////////////////////////////////////////
 
     SG_LOG( SG_IO, SG_ALERT,
-           "Done initializing ATC 610x hardware." );
+           "Done initializing ATC input hardware." );
 
     is_open = true;
 
@@ -863,17 +862,12 @@ bool FGATCInput::close() {
 
 #if defined( unix ) || defined( __CYGWIN__ )
 
-    int result;
-
-    result = ::close( lock_fd );
-    if ( result == -1 ) {
-       SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
-       char msg[256];
-       snprintf( msg, 256, "Error closing %s", lock_file );
-       perror( msg );
-       exit( -1 );
+    if ( !is_open ) {
+        return true;
     }
 
+    int result;
+
     result = ::close( analog_in_fd );
     if ( result == -1 ) {
        SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );