]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tools/tinyos/java/serial/NativeSerial_linux.cpp
fix a serial bug
[tinyos-2.x.git] / tools / tinyos / java / serial / NativeSerial_linux.cpp
index 7e66a910adf8aa625749d254006f1c7f2a04fbb2..76b1fee3e6b7d7eda94cd73fad4681e8cd09874b 100644 (file)
@@ -348,22 +348,23 @@ note( "waitForEvent begin" );
     fd_set input;
     struct timeval tv;
     m_events_out = 0;
+    int fd = m_fd;
 
     while( m_wait_for_events && (m_fd != -1) && (m_events_out == 0) )
     {
       FD_ZERO( &input );
-      FD_SET( m_fd, &input );
+      FD_SET( fd, &input );
       tv.tv_sec = 0;
       tv.tv_usec = 100*1000; // 1ms is the minimum resolution, at best
 
-      if( select( m_fd+1, &input, NULL, NULL, &tv ) == -1 )
+      if( select( fd+1, &input, NULL, NULL, &tv ) == -1 )
       {
        if( errno == EINTR )
          break;
        errno_wrap( true, "waitForEvent.select" );
       }
 
-      if( FD_ISSET( m_fd, &input ) )
+      if( FD_ISSET( fd, &input ) )
        m_events_out |= DATA_AVAILABLE;
     }