GPS_UBLOX_passthrough.cpp 712 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * GPS UBlox passthrough sketch
  3. * Code by DIYDrones.com
  4. */
  5. #include <stdlib.h>
  6. #include <AP_Common/AP_Common.h>
  7. #include <AP_HAL/AP_HAL.h>
  8. void setup();
  9. void loop();
  10. const AP_HAL::HAL& hal = AP_HAL::get_HAL();
  11. void setup()
  12. {
  13. // initialise console uart to 38400 baud
  14. hal.console->begin(38400);
  15. // initialise gps uart to 38400 baud
  16. hal.uartB->begin(38400);
  17. }
  18. void loop()
  19. {
  20. // send characters received from the console to the GPS
  21. while (hal.console->available()) {
  22. hal.uartB->write(hal.console->read());
  23. }
  24. // send GPS characters to the console
  25. while (hal.uartB->available()) {
  26. hal.console->write(hal.uartB->read());
  27. }
  28. }
  29. AP_HAL_MAIN();