boolean handleUDBSockets(void) { uint8_t buffer[BUFLEN]; int32_t bytesRead; int16_t i; boolean didRead = false; // Handle GPS Socket if (gpsSocket) { bytesRead = UDBSocket_read(gpsSocket, buffer, BUFLEN); if (bytesRead < 0) { UDBSocket_close(gpsSocket); gpsSocket = NULL; } else { for (i=0; i<bytesRead; i++) { udb_gps_callback_received_byte(buffer[i]); } if (bytesRead>0) didRead = true; } } // Handle Telemetry Socket if (telemetrySocket) { bytesRead = UDBSocket_read(telemetrySocket, buffer, BUFLEN); if (bytesRead < 0) { UDBSocket_close(telemetrySocket); telemetrySocket = NULL; } else { for (i=0; i<bytesRead; i++) { udb_serial_callback_received_byte(buffer[i]); } if (bytesRead>0) didRead = true; } } // Handle optional Serial RC input Socket if (serialSocket) { bytesRead = UDBSocket_read(serialSocket, buffer, BUFLEN); if (bytesRead < 0) { UDBSocket_close(serialSocket); serialSocket = NULL; } else { if (bytesRead>0) { sil_handle_seial_rc_input(buffer, bytesRead); didRead = true; } } } return didRead; }
void __attribute__((__interrupt__, __no_auto_psv__)) _U2RXInterrupt(void) { _U2RXIF = 0; // clear the interrupt indicate_loading_inter; interrupt_save_set_corcon; while (U2STAbits.URXDA) { uint8_t rxchar = U2RXREG; udb_serial_callback_received_byte(rxchar); } U2STAbits.OERR = 0; interrupt_restore_corcon; }
void __attribute__((__interrupt__,__no_auto_psv__)) _U1RXInterrupt(void) { indicate_loading_inter ; interrupt_save_set_corcon ; _U1RXIF = 0 ; // clear the interrupt while ( U1STAbits.URXDA ) { unsigned char rxchar = U1RXREG ; udb_serial_callback_received_byte(rxchar) ; } U1STAbits.OERR = 0 ; // clear the overrun bit, just in case interrupt_restore_corcon ; return ; }