File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -241,12 +241,18 @@ int do_unlinkp_cmd(char *pin)
241241}
242242
243243int do_set_debug_cmd (char * level){
244- int new_level = atoi (level);
245- if (new_level < 0 || new_level > 5 ){
246- halcmd_error (" Debug level must be >=0 and <= 5\n " );
247- return -EINVAL;
248- }
249- return rtapi_set_msg_level (atoi (level));
244+ int m=0 ,retval=-EINVAL;
245+ const char *argv[4 ];
246+ #if defined(RTAPI_USPACE)
247+ argv[m++] = EMC2_BIN_DIR " /rtapi_app" ;
248+ argv[m++] = " debug" ;
249+ argv[m++] = level;
250+ argv[m++] = NULL ;
251+ retval = hal_systemv (argv);
252+ #else
253+ halcmd_error (" debug: not implemented for anything else than uspace\n " );
254+ #endif
255+ return retval;
250256}
251257
252258int do_source_cmd (char *hal_filename) {
Original file line number Diff line number Diff line change @@ -329,6 +329,21 @@ static int do_unload_cmd(const string& name) {
329329 return 0 ;
330330}
331331
332+ static int do_debug_cmd (const string& value) {
333+ try {
334+ int new_level = stoi (value);
335+ if (new_level < 0 || new_level > 5 ){
336+ rtapi_print_msg (RTAPI_MSG_ERR, " Debug level must be >=0 and <= 5\n " );
337+ return -EINVAL;
338+ }
339+ return rtapi_set_msg_level (new_level);
340+ }catch (invalid_argument &e){
341+ // stoi will throw an exception if parsing is not possible
342+ rtapi_print_msg (RTAPI_MSG_ERR, " Debug level is not a number\n " );
343+ return -EINVAL;
344+ }
345+ }
346+
332347struct ReadError : std::exception {};
333348struct WriteError : std::exception {};
334349
@@ -403,6 +418,8 @@ static int handle_command(vector<string> args) {
403418 return do_newinst_cmd (args[1 ], args[2 ], " " );
404419 } else if (args.size () == 4 && args[0 ] == " newinst" ) {
405420 return do_newinst_cmd (args[1 ], args[2 ], args[3 ]);
421+ } else if (args.size () == 2 && args[0 ] == " debug" ) {
422+ return do_debug_cmd (args[1 ]);
406423 } else {
407424 rtapi_print_msg (RTAPI_MSG_ERR,
408425 " Unrecognized command starting with %s\n " ,
You can’t perform that action at this time.
0 commit comments