Compare commits

...

2 Commits

Author SHA1 Message Date
erikkaashoek bc116a4cb0 Updated channel power
5 days ago
Kevin Kettinger a65addbe1e Fix race condition and deadlock in shell command execution
5 days ago

@ -259,16 +259,27 @@ static THD_FUNCTION(Thread1, arg)
}
// STOP_PROFILE
// Run Shell command in sweep thread
if (shell_function) {
operation_requested = OP_NONE; // otherwise commands will be aborted
do {
shell_function(shell_nargs - 1, &shell_args[1]);
shell_function = 0;
if (operation_requested == OP_NONE) // Don't prompt if aborted
shell_printf(VNA_SHELL_PROMPT_STR);
// Resume shell thread
if (!abort_enabled) osalThreadDequeueNextI(&shell_thread, MSG_OK);
} while (shell_function);
vna_shellcmd_t local_func;
chSysLock();
local_func = shell_function;
shell_function = 0;
chSysUnlock();
if (local_func) {
operation_requested = OP_NONE; // otherwise commands will be aborted
local_func(shell_nargs - 1, &shell_args[1]);
if (operation_requested == OP_NONE) // Don't prompt if aborted
shell_printf(VNA_SHELL_PROMPT_STR);
// Resume shell thread
if (!abort_enabled) {
chSysLock();
osalThreadDequeueNextI(&shell_thread, MSG_OK);
chSysUnlock();
}
if (dirty) {
if (MODE_OUTPUT(setting.mode))
draw_menu(); // update screen if in output mode and dirty
@ -1905,6 +1916,28 @@ VNA_SHELL_FUNCTION(cmd_recall)
shell_printf("recall {id}\r\n");
}
VNA_SHELL_FUNCTION(cmd_channel)
{
if (argc == 0) {
for (int c=0;c<3;c++){
shell_printf("channel[%d] : %4.1f\r\n", c+1, channel_power[c]);
}
return;
}
if (argc != 1)
goto usage;
if (argv[0][0] == '?')
goto usage;
int id = my_atoi(argv[0]);
if (id < 1 || id > 3)
goto usage;
id -= 1;
shell_printf("%4.1f\r\n",channel_power[id]);
return;
usage:
shell_printf("channel [1-3]\r\n");
}
const char * const trc_channel_name[TRACES_MAX] = {
[TRACE_ACTUAL] = "MEASURED",
[TRACE_STORED] = "STORED",
@ -2142,6 +2175,8 @@ usage:
shell_printf("marker [n] [%s|{freq}|{index}] [{n}|%s]\r\n", cmd_marker_list, cmd_marker_on_off);
}
VNA_SHELL_FUNCTION(cmd_touchcal)
{
(void)argc;
@ -2481,6 +2516,7 @@ static const VNAShellCommand commands[] =
{"trace" , cmd_trace , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD},
{"trigger" , cmd_trigger , CMD_RUN_IN_LOAD},
{"marker" , cmd_marker , CMD_RUN_IN_LOAD},
{"channel" , cmd_channel , CMD_WAIT_MUTEX },
#ifdef __DRAW_LINE__
{"line" , cmd_line , CMD_RUN_IN_LOAD},
#endif
@ -2841,12 +2877,26 @@ static void VNAShell_executeLine(char *line)
// Skip wait mutex if process UI
if ((cmd_flag & CMD_RUN_IN_UI) && (sweep_mode&SWEEP_UI_MODE)) cmd_flag&=~CMD_WAIT_MUTEX;
if (cmd_flag & CMD_WAIT_MUTEX) {
chSysLock();
shell_function = scp->sc_function;
operation_requested|=OP_CONSOLE; // this will abort current sweep to give priority to the new request
chSysUnlock();
// Wait execute command in sweep thread
if (!abort_enabled && shell_function != 0){
int timeout_count = 0;
msg_t result;
do {
osalThreadEnqueueTimeoutS(&shell_thread, TIME_INFINITE);
result = osalThreadEnqueueTimeoutS(&shell_thread, MS2ST(5000)); // 5 second timeout
if (result == MSG_TIMEOUT) {
timeout_count++;
if (timeout_count > 3) {
shell_printf("Command timeout\r\n");
chSysLock();
shell_function = 0; // clear stuck command
chSysUnlock();
break;
}
}
} while (shell_function);
}
} else {

@ -1680,7 +1680,11 @@ static void cell_draw_marker_info(int x0, int y0)
ypos = 14 - y0;
if (setting.measurement==M_CP ) {
float v = 100.0 * channel_power_watt[c] /(channel_power_watt[0] + channel_power_watt[1] + channel_power_watt[2]);
cell_printf(xpos, ypos, FONT_b"%4.1f%%", v );
if (c == 1)
cell_printf(xpos, ypos, FONT_b"%4.1f%%", v );
else
cell_printf(xpos, ypos, FONT_b"%4.1f%% %4.1fdBc", v, channel_power[c] - channel_power[1] );
#ifdef __LEVEL_METER__
if (c == 1)
plot_printf(level_text, sizeof(level_text), "%4.1f%%", v);

Loading…
Cancel
Save

Powered by TurnKey Linux.