int GPS::callback(GPSCallbackType type, void *data1, int data2, void *user) { GPS *gps = (GPS *)user; switch (type) { case GPSCallbackType::readDeviceData: { int num_read = gps->pollOrRead((uint8_t *)data1, data2, *((int *)data1)); if (num_read > 0 && gps->_dump_from_gps_device_fd >= 0) { if (write(gps->_dump_from_gps_device_fd, data1, (size_t)num_read) != (size_t)num_read) { PX4_WARN("gps dump failed"); } } return num_read; } case GPSCallbackType::writeDeviceData: if (gps->_dump_to_gps_device_fd >= 0) { if (write(gps->_dump_to_gps_device_fd, data1, (size_t)data2) != (size_t)data2) { PX4_WARN("gps dump failed"); } } return write(gps->_serial_fd, data1, (size_t)data2); case GPSCallbackType::setBaudrate: return gps->setBaudrate(data2); case GPSCallbackType::gotRTCMMessage: /* not used */ break; case GPSCallbackType::surveyInStatus: /* not used */ break; case GPSCallbackType::setClock: px4_clock_settime(CLOCK_REALTIME, (timespec *)data1); break; } return 0; }
int GPS::callback(GPSCallbackType type, void *data1, int data2, void *user) { GPS *gps = (GPS *)user; switch (type) { case GPSCallbackType::readDeviceData: { int num_read = gps->pollOrRead((uint8_t *)data1, data2, *((int *)data1)); if (num_read > 0) { gps->dumpGpsData((uint8_t *)data1, (size_t)num_read, false); } return num_read; } case GPSCallbackType::writeDeviceData: gps->dumpGpsData((uint8_t *)data1, (size_t)data2, true); return write(gps->_serial_fd, data1, (size_t)data2); case GPSCallbackType::setBaudrate: return gps->setBaudrate(data2); case GPSCallbackType::gotRTCMMessage: /* not used */ break; case GPSCallbackType::surveyInStatus: /* not used */ break; case GPSCallbackType::setClock: px4_clock_settime(CLOCK_REALTIME, (timespec *)data1); break; } return 0; }