File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -134,25 +134,29 @@ IGN_async_status IGNITECH::read_async (ignitech_t& ignitech_data ) {
134134 static size_t total_read = 0 ;
135135 static size_t packet_size = IGNITECH_PACKET_SIZE_V88;
136136
137- if ( time (NULL ) > reset_last_read + reset_timeout ) {
138- // No response for timeout, reset
137+ errno = 0 ; // Reset upon entry
138+
139+ if ( file_descriptor < 0 ) {
140+ // Bad file descriptor, reset
139141 if ( DEBUG_IGNITECH ) {
140- perror ( " IGNITECH::read_async: No response from controller within timeout . Resetting." );
142+ perror ( " IGNITECH::read_async: Device not open . Resetting." );
141143 }
142- // TODO it hasn't proved necessary, but it may be a good idea to close the port and reopen
143- reset_last_read = time (NULL );
144144 reset ();
145145 total_read = 0 ;
146146 found_header = false ;
147147 sent_header = false ;
148148 buf[0 ] = 0 ;
149149 }
150150
151- if ( file_descriptor < 0 ) {
152- // Bad file descriptor , reset
151+ if ( time ( NULL ) > reset_last_read + reset_timeout ) {
152+ // No response for timeout , reset
153153 if ( DEBUG_IGNITECH ) {
154- perror ( " IGNITECH::read_async: Device not open . Resetting." );
154+ perror ( " IGNITECH::read_async: No response from controller within timeout . Resetting." );
155155 }
156+ // TODO it hasn't proved necessary, but it may be a good idea to close the port and reopen
157+ reset_last_read = time (NULL );
158+ close (file_descriptor);
159+ file_descriptor = -1 ;
156160 reset ();
157161 total_read = 0 ;
158162 found_header = false ;
You can’t perform that action at this time.
0 commit comments