@@ -62,6 +62,7 @@ void Commander::run(char* user_input){
6262 switch (id){
6363 case CMD_SCAN:
6464 for (int i=0 ; i < call_count; i++){
65+ printMachineReadable (F (" ?" ));
6566 print (call_ids[i]);
6667 print (" :" );
6768 if (call_label[i]) println (call_label[i]);
@@ -79,16 +80,21 @@ void Commander::run(char* user_input){
7980 case VerboseMode::user_friendly:
8081 println (F (" on!" ));
8182 break ;
83+ case VerboseMode::machine_readable:
84+ printlnMachineReadable (F (" machine" ));
85+ break ;
8286 }
8387 break ;
8488 case CMD_DECIMAL:
8589 if (!isSentinel (user_input[1 ])) decimal_places = atoi (&user_input[1 ]);
8690 printVerbose (F (" Decimal:" ));
91+ printMachineReadable (F (" #" ));
8792 println (decimal_places);
8893 break ;
8994 default :
9095 for (int i=0 ; i < call_count; i++){
9196 if (id == call_ids[i]){
97+ printMachineReadable (user_input[0 ]);
9298 call_list[i](&user_input[1 ]);
9399 break ;
94100 }
@@ -100,7 +106,7 @@ void Commander::run(char* user_input){
100106void Commander::motor (FOCMotor* motor, char * user_command) {
101107
102108 // if target setting
103- if (isDigit (user_command[0 ]) || user_command[0 ] == ' -' || user_command[0 ] == ' +' ){
109+ if (isDigit (user_command[0 ]) || user_command[0 ] == ' -' || user_command[0 ] == ' +' || isSentinel (user_command[ 0 ]) ){
104110 target (motor, user_command);
105111 return ;
106112 }
@@ -114,7 +120,10 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
114120 bool GET = isSentinel (user_command[value_index]);
115121 // parse command values
116122 float value = atof (&user_command[value_index]);
117-
123+ printMachineReadable (cmd);
124+ if (sub_cmd >= ' A' && sub_cmd <= ' Z' ) {
125+ printMachineReadable (sub_cmd);
126+ }
118127
119128 // a bit of optimisation of variable memory for Arduino UNO (atmega328)
120129 switch (cmd){
@@ -487,8 +496,11 @@ void Commander::scalar(float* value, char* user_cmd){
487496
488497void Commander::target (FOCMotor* motor, char * user_cmd, char * separator){
489498 // if no values sent
490- if (isSentinel (user_cmd[0 ])) return ;
491-
499+ if (isSentinel (user_cmd[0 ])) {
500+ printlnMachineReadable (motor->target );
501+ return ;
502+ };
503+
492504 float pos, vel, torque;
493505 char * next_value;
494506 switch (motor->controller ){
@@ -633,6 +645,39 @@ void Commander::printVerbose(const char* message){
633645void Commander::printVerbose (const __FlashStringHelper *message){
634646 if (verbose == VerboseMode::user_friendly) print (message);
635647}
648+
649+ void Commander::printMachineReadable (const int number){
650+ if (verbose == VerboseMode::machine_readable) print (number);
651+ }
652+ void Commander::printMachineReadable (const float number){
653+ if (verbose == VerboseMode::machine_readable) print (number);
654+ }
655+ void Commander::printMachineReadable (const char * message){
656+ if (verbose == VerboseMode::machine_readable) print (message);
657+ }
658+ void Commander::printMachineReadable (const __FlashStringHelper *message){
659+ if (verbose == VerboseMode::machine_readable) print (message);
660+ }
661+ void Commander::printMachineReadable (const char message){
662+ if (verbose == VerboseMode::machine_readable) print (message);
663+ }
664+
665+ void Commander::printlnMachineReadable (const int number){
666+ if (verbose == VerboseMode::machine_readable) println (number);
667+ }
668+ void Commander::printlnMachineReadable (const float number){
669+ if (verbose == VerboseMode::machine_readable) println (number);
670+ }
671+ void Commander::printlnMachineReadable (const char * message){
672+ if (verbose == VerboseMode::machine_readable) println (message);
673+ }
674+ void Commander::printlnMachineReadable (const __FlashStringHelper *message){
675+ if (verbose == VerboseMode::machine_readable) println (message);
676+ }
677+ void Commander::printlnMachineReadable (const char message){
678+ if (verbose == VerboseMode::machine_readable) println (message);
679+ }
680+
636681void Commander::printError (){
637682 println (F (" err" ));
638683}
0 commit comments