Skip to content

Commit

Permalink
Merge pull request #23 from TytanRock/ssh-field-upgrade
Browse files Browse the repository at this point in the history
Added support for SSH-field-upgrade.
  • Loading branch information
TytanRock committed Feb 18, 2021
2 parents f62120e + 07cfc54 commit 5107d7e
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 25 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ jobs:
- name: 'prepare runner'
run: |
dpkg --add-architecture armhf
dpkg --add-architecture armel
dpkg --add-architecture arm64
apt update
apt install -y libcurl4-openssl-dev libgtk-3-dev python3-pip meson build-essential debhelper
apt install -y libgtk-3-dev:armhf libcurl4-openssl-dev:armhf crossbuild-essential-armhf
apt install -y libcurl4-openssl-dev libgtk-3-dev libssh-dev python3-pip meson build-essential debhelper
apt install -y libgtk-3-dev:armhf libcurl4-openssl-dev:armhf libssh-dev:armhf crossbuild-essential-armhf
apt install -y libgtk-3-dev:armel libcurl4-openssl-dev:armel libssh-dev:armel crossbuild-essential-armel
apt install -y libgtk-3-dev:arm64 libcurl4-openssl-dev:arm64 libssh-dev:arm64 crossbuild-essential-arm64
pip3 install ninja
- name: 'build and package native'
run: dpkg-buildpackage
- name: 'build and package armhf'
run: CONFIG_SITE=/etc/dpkg-cross/cross-config.armhf DH_MESON_CROSS_FILE=armhf.ini dpkg-buildpackage -aarmhf -Pcross
- name: 'build and package arm64'
run: CONFIG_SITE=/etc/dpkg-cross/cross-config.arm64 DH_MESON_CROSS_FILE=arm64.ini dpkg-buildpackage -aarm64 -Pcross
- name: 'build and package armel'
run: CONFIG_SITE=/etc/dpkg-cross/cross-config.armel DH_MESON_CROSS_FILE=armel.ini dpkg-buildpackage -aarmel -Pcross
- name: 'move debs back into home'
run: |
ls ..
Expand All @@ -39,18 +47,20 @@ jobs:
path: penguintuner*.deb

verify-install:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Download previous job artifact
uses: actions/download-artifact@v2
with:
name: PenguinTuner_Packages
- name: Install necessary dependencies to run the test
run: sudo apt install xvfb
run: |
sudo apt update
sudo apt install xvfb
- name: Install the package on the clean container
# Ensure we install the amd64 package, not armhf
run: sudo apt install ./penguintuner*amd64.deb
run: sudo apt install -f ./penguintuner*amd64.deb
- name: Run the app for 10 seconds to ensure everything it needs has been installed
run: |
xvfb-run -a penguintuner &
Expand Down
15 changes: 15 additions & 0 deletions arm64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[constants]
arch = 'aarch64-linux-gnu'
[binaries]
c = 'aarch64-linux-gnu-gcc'
strip = 'aarch64-linux-gnu-strip'
pkgconfig = 'aarch64-linux-gnu-pkg-config'
ar = 'aarch64-linux-gnu-ar'
[properties]
host_arch = 'arm64'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'arm64'
endian = 'little'
15 changes: 15 additions & 0 deletions armel.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[constants]
arch = 'arm-linux-gnueabi'
[binaries]
c = 'arm-linux-gnueabi-gcc'
strip = 'arm-linux-gnueabi-strip'
pkgconfig = 'arm-linux-gnueabi-pkg-config'
ar = 'arm-linux-gnueabi-ar'
[properties]
host_arch = 'armel'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armel'
endian = 'little'
8 changes: 7 additions & 1 deletion backend/headers/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ typedef enum _action_type
Get_Firm_status,
}action_type;

typedef enum _upload_style
{
POST,
SSH
}upload_style;

/**
* This is what will be passed between application and backend
* to decide what device to interact with, and to display
Expand Down Expand Up @@ -78,7 +84,7 @@ backend_error blink_device(const can_device_t *device, backend_callback callback
backend_error get_device_snapshot(const can_device_t *device, backend_callback callback);
backend_error factory_default_device(const can_device_t *device, backend_callback callback);

backend_error update_device_firmware(const can_device_t *device, const char *firmware_file, void (*firm_upgrade_callback)(double, int), backend_callback callback);
backend_error update_device_firmware(const can_device_t *device, const char *firmware_file, void (*firm_upgrade_callback)(double, int), backend_callback callback, upload_style style, const char *username, const char *password);

#endif

Binary file modified backend/lib/amd64/libpenguinbackend.so
100755 → 100644
Binary file not shown.
Binary file added backend/lib/arm64/libpenguinbackend.so
Binary file not shown.
Binary file added backend/lib/armel/libpenguinbackend.so
Binary file not shown.
Binary file modified backend/lib/armhf/libpenguinbackend.so
100755 → 100644
Binary file not shown.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Standards-Version: 4.5.1
Homepage: https://penguintuner.tytan.rocks

Package: penguintuner
Architecture: amd64 armhf
Architecture: amd64 armhf armel arm64
Depends: ${shlibs:Depends}
Description: A GUI application to interact with CTRE CAN devices
penguintuner is a windowed application that uses CTRE's diagnostic server
Expand Down
11 changes: 11 additions & 0 deletions include/robot_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@
#define __ROBOT_CONTROLLER_H__

#include <gtk/gtk.h>
#include "backend.h"

void react_btn_run_temporary_diag_server(GtkWidget *widget, gpointer data);

void react_server_ip_change(GtkWidget *widget, gpointer data);

void react_use_post_select(GtkWidget *widget, gpointer data);
void react_use_ssh_select(GtkWidget *widget, gpointer data);

void add_txt_server_ip_entry(GtkEntry *entry);

void add_txt_server_port_entry(GtkEntry *entry);

void add_use_ssh_menuitem(GtkCheckMenuItem *menuitem);
void add_use_post_menuitem(GtkCheckMenuItem *menuitem);
void add_txt_ssh_password_entry(GtkEntry *entry);
void add_txt_ssh_username_entry(GtkEntry *entry);

void add_txt_controller_status_buffer(GtkTextBuffer *buffer);

void get_upload_style_parameters(upload_style *style, char *username, char *password);

#endif
44 changes: 30 additions & 14 deletions src/app_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,22 @@ gint periodic_callback(gpointer data)
/* Update firmware status if we're upgrading */
gtk_level_bar_set_value(_module.firmUpgradeStatus, _module.firmware_upgrading ? _module.firm_upgrade_status : 0);

/* Update Server Version and Status */
char serverVers[50];
get_server_version(serverVers);
char fullVersion[100];
sprintf(fullVersion, "Server Version:\n%s", serverVers);
gtk_label_set_text(_module.serverVersion, fullVersion);

char serverStatus[50];
get_server_status(serverStatus);
char fullStatus[100];
sprintf(fullStatus, "Server Status:\n%s", serverStatus);
gtk_label_set_text(_module.serverStatus, fullStatus);
/* If we're not field-upgrading, then check on the server status */
if(_module.firmware_upgrading == 0)
{
/* Update Server Version and Status */
char serverVers[50];
get_server_version(serverVers);
char fullVersion[100];
sprintf(fullVersion, "Server Version:\n%s", serverVers);
gtk_label_set_text(_module.serverVersion, fullVersion);

char serverStatus[50];
get_server_status(serverStatus);
char fullStatus[100];
sprintf(fullStatus, "Server Status:\n%s", serverStatus);
gtk_label_set_text(_module.serverStatus, fullStatus);
}

return 1;
}
Expand Down Expand Up @@ -147,8 +151,7 @@ void frontend_callback(backend_error err, const backend_action *action)

/**
* This function is called during a firmware upgrade to update the frontend on the status of
* the upgrade. When called, we should lock a mutex, update the firmware upgrade status variable,
* and unlock, so that the periodic callback can pick up the new value
* the upgrade. Just update the values by writing, we don't need to worry about read-modify-write conditions
*/
void frontend_update_firm_status(double status, int stillUpgrading)
{
Expand Down Expand Up @@ -207,6 +210,19 @@ int connect_all_signals()
obj = gtk_builder_get_object(builder, "txt_selected_device");
add_lbl_selected_device((GtkLabel *)obj);

/* Connect the widgets used to switch between POST and SSH */
obj = gtk_builder_get_object(builder, "chckmnu_use_post");
g_signal_connect(obj, "toggled", G_CALLBACK(react_use_post_select), NULL);
add_use_post_menuitem((GtkCheckMenuItem *)obj);
obj = gtk_builder_get_object(builder, "chckmnu_use_ssh");
g_signal_connect(obj, "toggled", G_CALLBACK(react_use_ssh_select), NULL);
add_use_ssh_menuitem((GtkCheckMenuItem *)obj);

obj = gtk_builder_get_object(builder, "txt_ssh_username");
add_txt_ssh_username_entry((GtkEntry *)obj);
obj = gtk_builder_get_object(builder, "txt_ssh_password");
add_txt_ssh_password_entry((GtkEntry *)obj);

/* Connect device stuff to can_devices file */
obj = gtk_builder_get_object(builder, "btn_change_id");
g_signal_connect(obj, "clicked", G_CALLBACK(react_changed_id), NULL);
Expand Down
8 changes: 7 additions & 1 deletion src/can_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "app_callbacks.h"
#include "can_devices.h"
#include "robot_controller.h"
#include <string.h>

static struct
Expand Down Expand Up @@ -110,8 +111,13 @@ void react_changed_id(GtkWidget *widget, gpointer data)
void react_update_firmware(GtkWidget *widget, gpointer data)
{
const char *firmware_file = gtk_file_chooser_get_filename((GtkFileChooser *)_module.btn_firmware_file);
upload_style style;
char ssh_username[100];
char ssh_password[100];

update_device_firmware(&_module.selected_device, firmware_file, frontend_update_firm_status, frontend_callback);
get_upload_style_parameters(&style, ssh_username, ssh_password);

update_device_firmware(&_module.selected_device, firmware_file, frontend_update_firm_status, frontend_callback, style, ssh_username, ssh_password);
}

void react_changed_name(GtkWidget *widget, gpointer data)
Expand Down
60 changes: 60 additions & 0 deletions src/robot_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
static struct {
GtkEntry *server_ip_entry;
GtkEntry *server_port_entry;
GtkEntry *ssh_username_entry;
GtkEntry *ssh_password_entry;

GtkCheckMenuItem *use_post_menuitem;
GtkCheckMenuItem *use_ssh_menuitem;

GtkTextBuffer *controller_status_buffer;
}_module;

Expand All @@ -30,6 +36,26 @@ void add_txt_controller_status_buffer(GtkTextBuffer *buffer)
_module.controller_status_buffer = buffer;
}

void add_txt_ssh_username_entry(GtkEntry *entry)
{
_module.ssh_username_entry = entry;
}

void add_txt_ssh_password_entry(GtkEntry *entry)
{
_module.ssh_password_entry = entry;
}

void add_use_post_menuitem(GtkCheckMenuItem *menuitem)
{
_module.use_post_menuitem = menuitem;
}

void add_use_ssh_menuitem(GtkCheckMenuItem *menuitem)
{
_module.use_ssh_menuitem = menuitem;
}

void react_server_ip_change(GtkWidget *widget, gpointer data)
{
/* Allocate some space to do stringwork */
Expand Down Expand Up @@ -58,3 +84,37 @@ void react_server_ip_change(GtkWidget *widget, gpointer data)
/* And finally call into backend to set the ip */
set_ip(fullIp);
}

void react_use_post_select(GtkWidget *widget, gpointer data)
{
if(gtk_check_menu_item_get_active((GtkCheckMenuItem *)widget))
{
gtk_check_menu_item_set_active(_module.use_post_menuitem, TRUE);
gtk_check_menu_item_set_active(_module.use_ssh_menuitem, FALSE);
}
}

void react_use_ssh_select(GtkWidget *widget, gpointer data)
{
if(gtk_check_menu_item_get_active((GtkCheckMenuItem *)widget))
{
gtk_check_menu_item_set_active(_module.use_ssh_menuitem, TRUE);
gtk_check_menu_item_set_active(_module.use_post_menuitem, FALSE);
}
}

void get_upload_style_parameters(upload_style *style, char *username, char *password)
{
upload_style usedStyle = POST;
if(gtk_check_menu_item_get_active(_module.use_post_menuitem))
{
usedStyle = POST;
}
else if(gtk_check_menu_item_get_active(_module.use_ssh_menuitem))
{
usedStyle = SSH;
}
*style = usedStyle;
strcpy(username, gtk_entry_get_text(_module.ssh_username_entry));
strcpy(password, gtk_entry_get_text(_module.ssh_password_entry));
}
Loading

0 comments on commit 5107d7e

Please sign in to comment.