Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/hal/utils/halcmd_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,18 @@ int do_unlinkp_cmd(char *pin)
}

int do_set_debug_cmd(char* level){
int new_level = atoi(level);
if (new_level < 0 || new_level > 5){
halcmd_error("Debug level must be >=0 and <= 5\n");
return -EINVAL;
}
return rtapi_set_msg_level(atoi(level));
int m=0,retval=-EINVAL;
const char *argv[4];
#if defined(RTAPI_USPACE)
argv[m++] = EMC2_BIN_DIR "/rtapi_app";
argv[m++] = "debug";
argv[m++] = level;
argv[m++] = NULL;
retval = hal_systemv(argv);
#else
halcmd_error("debug: not implemented for anything else than uspace\n");
#endif
return retval;
}

int do_source_cmd(char *hal_filename) {
Expand Down
17 changes: 17 additions & 0 deletions src/rtapi/uspace_rtapi_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,21 @@ static int do_unload_cmd(const string& name) {
return 0;
}

static int do_debug_cmd(const string& value) {
try{
int new_level = stoi(value);
if (new_level < 0 || new_level > 5){
rtapi_print_msg(RTAPI_MSG_ERR, "Debug level must be >=0 and <= 5\n");
return -EINVAL;
}
return rtapi_set_msg_level(new_level);
}catch(invalid_argument &e){
//stoi will throw an exception if parsing is not possible
rtapi_print_msg(RTAPI_MSG_ERR, "Debug level is not a number\n");
return -EINVAL;
}
}

struct ReadError : std::exception {};
struct WriteError : std::exception {};

Expand Down Expand Up @@ -403,6 +418,8 @@ static int handle_command(vector<string> args) {
return do_newinst_cmd(args[1], args[2], "");
} else if(args.size() == 4 && args[0] == "newinst") {
return do_newinst_cmd(args[1], args[2], args[3]);
} else if(args.size() == 2 && args[0] == "debug") {
return do_debug_cmd(args[1]);
} else {
rtapi_print_msg(RTAPI_MSG_ERR,
"Unrecognized command starting with %s\n",
Expand Down
Loading