@@ -223,7 +223,7 @@ bool UM980::updateOnce()
223223 return (false );
224224}
225225
226- // Mode
226+ // Mode commands
227227// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
228228
229229// Directly set a mode: setMode("ROVER");
@@ -302,7 +302,7 @@ bool UM980::setModeRoverMow()
302302 // be supported on UM980.
303303}
304304
305- // Config
305+ // Config commands
306306// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
307307
308308// Configure a given COM port to a given baud
@@ -354,7 +354,7 @@ bool UM980::configurePPS(const char *configString)
354354 return (sendCommand (command));
355355}
356356
357- // Mask
357+ // Mask commands
358358// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
359359
360360// Available constellations: GPS, BDS, GLO, GAL, QZSS, IRNSS
@@ -441,7 +441,7 @@ bool UM980::disableSystem(const char *systemName)
441441 return (sendCommand (command));
442442}
443443
444- // Data Output
444+ // Data Output commands
445445// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
446446
447447// Set the output rate of a given message on a given COM port/Use
@@ -503,7 +503,7 @@ bool UM980::setRTCMMessage(const char *sentenceType, float outputRate)
503503 return (sendCommand (command));
504504}
505505
506- // Other
506+ // Other commands
507507// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
508508
509509// Disables all messages on this port
@@ -543,7 +543,8 @@ bool UM980::saveConfiguration()
543543 return (sendCommand (" SAVECONFIG" ));
544544}
545545
546- // Lower level interface functions
546+ // Abstraction of the serial interface
547+ // Useful if we ever need to support SoftwareSerial
547548// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
548549
549550// Enable printfs to various endpoints
@@ -573,8 +574,41 @@ void UM980::debugPrintf(const char *format, ...)
573574 va_end (args2);
574575}
575576
577+ // Discards any characters sitting in RX buffer
578+ void UM980::clearBuffer ()
579+ {
580+ while (serialAvailable ())
581+ serialRead ();
582+ }
576583
577- // Query and send commands
584+ uint16_t UM980::serialAvailable ()
585+ {
586+ if (_hwSerialPort != nullptr )
587+ {
588+ return (_hwSerialPort->available ());
589+ }
590+ return (0 );
591+ }
592+
593+ uint8_t UM980::serialRead ()
594+ {
595+ if (_hwSerialPort != nullptr )
596+ {
597+ return (_hwSerialPort->read ());
598+ }
599+ return (0 );
600+ }
601+
602+ void UM980::serialPrintln (const char *command)
603+ {
604+ if (_hwSerialPort != nullptr )
605+ {
606+ _hwSerialPort->println (command);
607+ }
608+ }
609+
610+
611+ // Query and send functionality
578612// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
579613
580614// Send a command string (ie 'MODE ROVER') to the UM980
@@ -745,44 +779,6 @@ Um980Result UM980::checkCRC(char *response)
745779 return (UM980_RESULT_OK);
746780}
747781
748-
749- // Abstraction of the serial interface
750- // Useful if we ever need to support SoftwareSerial
751- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
752-
753- // Discards any characters sitting in RX buffer
754- void UM980::clearBuffer ()
755- {
756- while (serialAvailable ())
757- serialRead ();
758- }
759-
760- uint16_t UM980::serialAvailable ()
761- {
762- if (_hwSerialPort != nullptr )
763- {
764- return (_hwSerialPort->available ());
765- }
766- return (0 );
767- }
768-
769- uint8_t UM980::serialRead ()
770- {
771- if (_hwSerialPort != nullptr )
772- {
773- return (_hwSerialPort->read ());
774- }
775- return (0 );
776- }
777-
778- void UM980::serialPrintln (const char *command)
779- {
780- if (_hwSerialPort != nullptr )
781- {
782- _hwSerialPort->println (command);
783- }
784- }
785-
786782// Main Unicore handler and RAM inits
787783// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
788784
0 commit comments