From 49fd261e3169abf11b8adb76cc7304910e6e9ce9 Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm <philipp@uvos.xyz> Date: Fri, 3 Nov 2023 13:20:26 +0100 Subject: [PATCH] add support for reseting the usb bus --- coincellhell.c | 5 +++++ coincellhell/coincellhell.h | 1 + main.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/coincellhell.c b/coincellhell.c index 20801ce..d60867e 100644 --- a/coincellhell.c +++ b/coincellhell.c @@ -317,6 +317,11 @@ int coincellhell_set_periodic_recal(struct coincellhell* hell, bool recal) return ret; } +void coincellhell_reset_bus(struct coincellhell* hell) +{ + usbshm_reset(hell->priv); +} + void coincellhell_disconnect(struct coincellhell* hell) { if(!hell || !hell->priv) diff --git a/coincellhell/coincellhell.h b/coincellhell/coincellhell.h index f073f1a..1de0866 100644 --- a/coincellhell/coincellhell.h +++ b/coincellhell/coincellhell.h @@ -178,6 +178,7 @@ uint32_t coincellhell_get_seconds(struct coincellhell* hell); const uint8_t* coincellhell_get_fw_git_revision(struct coincellhell* hell); int coincellhell_enable_watchdog(struct coincellhell* hell); int coincellhell_set_periodic_recal(struct coincellhell* hell, bool recal); +void coincellhell_reset_bus(struct coincellhell* hell); #ifdef __cplusplus } diff --git a/main.c b/main.c index 916b647..1298524 100644 --- a/main.c +++ b/main.c @@ -52,6 +52,7 @@ static void print_commands(void) puts("git\t\t\t | get the git revision of the firmware on the device"); puts("watchdog\t\t\t | enables the on device command watchdog"); puts("recal [BOOLEAN]\t\t | enables or disables periodic recal"); + puts("reset\t\t\t | reset the usb bus of this device"); } static int convert_string_to_heater_id(const char* str) @@ -367,6 +368,11 @@ static int process_commands(char** commands, size_t command_count, struct coince if(ret < 0) puts("could not enable watchdog"); } + else if(strcmp(commands[0], "reset") == 0) + { + coincellhell_reset_bus(hell); + ret = 0; + } else { printf("%s is not a valid command!", commands[0]); -- GitLab