add ps command and fix performance on samecore ump
This commit is contained in:
parent
e979d98a33
commit
be08ca06be
@ -1437,4 +1437,6 @@ errors sdhc SDHCD_ERR_ {
|
|||||||
errors shelly SHELLY_ERR_ {
|
errors shelly SHELLY_ERR_ {
|
||||||
failure BUFFER_OVERFLOW "Buffer limits reached",
|
failure BUFFER_OVERFLOW "Buffer limits reached",
|
||||||
failure WRITE "String write failed",
|
failure WRITE "String write failed",
|
||||||
|
failure SPAWN_RPC "Spawn RPC failed",
|
||||||
|
failure PS_RPC "ps RPC failed",
|
||||||
};
|
};
|
||||||
@ -287,6 +287,7 @@ static void ump_worker_schedule(struct ump_worker_context *worker_context) {
|
|||||||
// this is supposed to be called single threaded and only upon event trigger
|
// this is supposed to be called single threaded and only upon event trigger
|
||||||
// hence this cannot be a reregister and thus not fail
|
// hence this cannot be a reregister and thus not fail
|
||||||
assert(err_is_ok(err));
|
assert(err_is_ok(err));
|
||||||
|
thread_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -81,20 +81,20 @@ static void handle_lpuart_interrupt(void * arg) {
|
|||||||
global_state->buf[global_state->buffer_i] = '\0';
|
global_state->buf[global_state->buffer_i] = '\0';
|
||||||
global_state->buffer_i += 1;
|
global_state->buffer_i += 1;
|
||||||
|
|
||||||
err = shelly_write_str("\n\xd");
|
err = shelly_write_str("\n\r");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
||||||
|
|
||||||
err = handle_shelly_cmd(global_state->buf, global_state->buffer_i);
|
err = handle_shelly_cmd(global_state->buf, global_state->buffer_i);
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while running command");
|
if (err_is_fail(err)) DEBUG_ERR(err, "while running command");
|
||||||
|
|
||||||
shelly_reset_buffer();
|
shelly_reset_buffer();
|
||||||
|
|
||||||
err = shelly_write_str("\n\xd>");
|
err = shelly_write_str("\n\r>");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
||||||
} else {
|
} else {
|
||||||
err = shelly_buffer_append(input_char);
|
err = shelly_buffer_append(input_char);
|
||||||
if (err_is_fail(err)) {
|
if (err_is_fail(err)) {
|
||||||
err = shelly_write_str("shelly buffer full! resetting...\n");
|
err = shelly_write_str("shelly buffer full! resetting...\n\r");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,6 +147,8 @@ static void handle_client_request(void *arg, size_t header_size, void *header_bu
|
|||||||
assert(local_state);
|
assert(local_state);
|
||||||
assert(global_state);
|
assert(global_state);
|
||||||
|
|
||||||
|
// SHELLY_DEBUG("[handle_client_request] client_id=%d\n", local_state->client_id);
|
||||||
|
|
||||||
struct shelly_header * header = (struct shelly_header *) header_buf;
|
struct shelly_header * header = (struct shelly_header *) header_buf;
|
||||||
|
|
||||||
if (header->type == SHELLY_MSG_GETCHAR) {
|
if (header->type == SHELLY_MSG_GETCHAR) {
|
||||||
@ -272,7 +274,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
SHELLY_DEBUG("registered as shelly server\n");
|
SHELLY_DEBUG("registered as shelly server\n");
|
||||||
|
|
||||||
err = shelly_write_str("welcome to Shelly(TM)(TM)!\n");
|
err = shelly_write_str("Welcome to Shelly(TM)(TM)!\n\r");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write welcome message");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write welcome message");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@ -28,25 +28,32 @@ static errval_t shelly_cmd_run(char * line) {
|
|||||||
domainid_t pid;
|
domainid_t pid;
|
||||||
struct aos_rpc * rpc = aos_rpc_get_process_channel();
|
struct aos_rpc * rpc = aos_rpc_get_process_channel();
|
||||||
err = aos_rpc_process_spawn(rpc, line, 0, &pid);
|
err = aos_rpc_process_spawn(rpc, line, 0, &pid);
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "Failed to spawn process");
|
if (err == SPAWN_ERR_FIND_MODULE) {
|
||||||
SHELLY_DEBUG("[shelly_cmd_run] spawned process\n");
|
err = shelly_write_str("[run]:couldn't find module:\n\r");
|
||||||
|
if (err_is_fail(err)) return err;
|
||||||
|
err = shelly_write_str(line);
|
||||||
|
if (err_is_fail(err)) return err;
|
||||||
|
err = shelly_write_str("\n\r");
|
||||||
|
if (err_is_fail(err)) return err;
|
||||||
|
} else if (err_is_fail(err)) return err_push(err, SHELLY_ERR_SPAWN_RPC);
|
||||||
|
|
||||||
// // get process name
|
return SYS_ERR_OK;
|
||||||
// char *name;
|
}
|
||||||
// err = aos_rpc_process_get_name(rpc, pid, &name);
|
|
||||||
// if (err_is_fail(err)) USER_PANIC_ERR(err, "Failed to get process name");
|
|
||||||
// printf("Process Name: %s\n", name);
|
|
||||||
|
|
||||||
// // get all PIDs
|
static errval_t shelly_cmd_ps(char * line) {
|
||||||
// domainid_t *pids;
|
errval_t err;
|
||||||
// size_t pid_count;
|
|
||||||
// err = aos_rpc_process_get_all_pids(rpc, &pids, &pid_count);
|
|
||||||
// if (err_is_fail(err)) USER_PANIC_ERR(err, "Failed to get all PIDs");
|
|
||||||
// printf("PIDs:\n");
|
|
||||||
// for(size_t i = 0; i < pid_count; ++i) {
|
|
||||||
// printf(" %lu\n", pids[i]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
domainid_t *pids;
|
||||||
|
size_t pid_count;
|
||||||
|
struct aos_rpc * rpc = aos_rpc_get_process_channel();
|
||||||
|
err = aos_rpc_process_get_all_pids(rpc, &pids, &pid_count);
|
||||||
|
if (err_is_fail(err)) return err_push(err, SHELLY_ERR_PS_RPC);
|
||||||
|
shelly_write_str("PIDs:\n\r");
|
||||||
|
char buf[256];
|
||||||
|
for(size_t i = 0; i < pid_count; ++i) {
|
||||||
|
snprintf(buf, 256, " %lu\n\r", pids[i]);
|
||||||
|
shelly_write_str(buf);
|
||||||
|
}
|
||||||
return SYS_ERR_OK;
|
return SYS_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,9 +73,11 @@ static errval_t handle_shelly_cmd(char* line, size_t len) {
|
|||||||
return shelly_cmd_echo(remaining_line);
|
return shelly_cmd_echo(remaining_line);
|
||||||
} else if (strcmp(cmd, "run") == 0) {
|
} else if (strcmp(cmd, "run") == 0) {
|
||||||
return shelly_cmd_run(remaining_line);
|
return shelly_cmd_run(remaining_line);
|
||||||
|
} else if (strcmp(cmd, "ps") == 0) {
|
||||||
|
return shelly_cmd_ps(remaining_line);
|
||||||
} else {
|
} else {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
snprintf(buf, 256, "unknown command %s\n", cmd);
|
snprintf(buf, 256, "unknown command \"%s\"\n\r", cmd);
|
||||||
shelly_write_str(buf);
|
shelly_write_str(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user