@@ -182,7 +182,7 @@ static const struct cli_print_s cli_print_options[] = {
182182 {" pbar" , " Barometer" , cli_print_bar},
183183 {" palt" , " Altitude estimator" , cli_print_alt},
184184 {" pgps" , " GPS" , cli_print_gps},
185- {" prdr" , " Radar" , cli_print_rdr},
185+ {" prdr" , " Radar" , cli_print_rdr},
186186};
187187
188188
@@ -194,16 +194,27 @@ void Cli::setup() {
194194
195195// returns true if a command was processed (even an invalid one)
196196bool Cli::update () {
197- // process chars from Serial
198- bool rv = false ;
199- while (Serial.available ()) {
200- if (cmd_process_char (Serial.read ())) rv = true ;
201- }
197+ if (mavlink) {
198+ return mavlink->update ();
199+ }else {
200+ // process chars from Serial
201+ bool rv = false ;
202+ while (Serial.available ()) {
203+ uint8_t c = Serial.read ();
204+ if (c == 0xFD || c == 0xFE ) { // mavlink v1,v2 protocol header byte
205+ auto ser = &Serial;
206+ MF_Serial *ser_bus = new MF_SerialPtrWrapper<decltype (ser)>( ser );
207+ mavlink = new RclGizmoMavlink (ser_bus, 115200 , nullptr );
208+ return false ;
209+ }
210+ if (cmd_process_char (c)) rv = true ;
211+ }
202212
203- // handle output for pxxx commands
204- cli_print_loop ();
213+ // handle output for pxxx commands
214+ cli_print_loop ();
205215
206- return rv;
216+ return rv;
217+ }
207218}
208219
209220void Cli::begin () {
0 commit comments