Skip to content

Commit

Permalink
Merge pull request #5 from TytanRock/snapshot
Browse files Browse the repository at this point in the history
Self-Test snapshot and Factory Default
  • Loading branch information
TytanRock committed Aug 22, 2020
2 parents 96697e3 + 5af7a7f commit 8176369
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: configure
run: ./configure
run: ./configure.sh
- name: 'build and package'
run: ./package.sh

Expand Down
6 changes: 6 additions & 0 deletions backend/headers/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ typedef enum _action_type
Set_ID,
Set_Name,
Blink,
Snapshot,
FactoryDefault,
Update_Firmware,
Get_Firm_status,
}action_type;
Expand Down Expand Up @@ -52,6 +54,7 @@ typedef struct _backend_action

int intParam;
void (*functionParam)(double,int);
void *pointerParam;
char stringParam[100];

backend_callback callback;
Expand All @@ -69,6 +72,9 @@ backend_error get_devices(can_device_t *devices, int maxDeviceCount, int *device
backend_error set_device_id(const can_device_t *device, int id, backend_callback callback);
backend_error set_device_name(const can_device_t *device, const char *name, backend_callback callback);
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);

#endif
Expand Down
Binary file modified backend/lib/libPenguin_Backend.so
Binary file not shown.
8 changes: 5 additions & 3 deletions config/MainApp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</row>
</data>
</object>
<object class="GtkTextBuffer" id="txt_device_selftest_snapshot"/>
<object class="GtkListStore" id="txt_ip_address_completion_values">
<columns>
<!-- column-name Default -->
Expand Down Expand Up @@ -613,12 +614,13 @@ with matching type</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkTextView" id="txt_device_selftest_snapshot">
<object class="GtkTextView">
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="buffer">txt_device_selftest_snapshot</property>
</object>
<packing>
<property name="left_attach">0</property>
Expand All @@ -639,8 +641,8 @@ with matching type</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_copy_to_clipboard">
<property name="label" translatable="yes">Copy to Clipboard</property>
<object class="GtkButton" id="btn_factory_default">
<property name="label" translatable="yes">Factory Default</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
Expand Down
1 change: 1 addition & 0 deletions configure → configure.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

sudo apt-get update
sudo apt-get install libcurl4-gnutls-dev libgtk-3-dev

2 changes: 2 additions & 0 deletions native/include/can_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void react_changed_device(GtkWidget *widget, gpointer data);
void react_update_firmware(GtkWidget *widget, gpointer data);
void react_changed_name(GtkWidget *widget, gpointer data);
void react_blink_device(GtkWidget *widget, gpointer data);
void react_snapshot_device(GtkWidget *widget, gpointer data);
void react_default_device(GtkWidget *widget, gpointer data);

#endif

21 changes: 21 additions & 0 deletions native/src/app_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static struct
/* Gtk Widget references that matter */
GtkTreeModel *deviceTreeModel;
GtkLevelBar *firmUpgradeStatus;

GtkTextBuffer *snapshotTxt;
}_module;

int count = 0;
Expand Down Expand Up @@ -99,6 +101,16 @@ void frontend_callback(backend_error err, const backend_action *action)
dev.id = action->intParam;
set_selected_device(dev);
}
break;
}
case Snapshot:
{
/* Get contents of string and copy it to module */
if(err == Ok)
{
gtk_text_buffer_set_text(_module.snapshotTxt, *((char **)action->pointerParam), -1);
}
break;
}
}
}
Expand Down Expand Up @@ -171,6 +183,13 @@ int connect_all_signals()
g_signal_connect(obj, "clicked", G_CALLBACK(react_changed_name), NULL);
obj = gtk_builder_get_object(builder, "btn_blink");
g_signal_connect(obj, "clicked", G_CALLBACK(react_blink_device), NULL);
/* Connect objects from the self-test snapshot page */
obj = gtk_builder_get_object(builder, "btn_blink_clear");
g_signal_connect(obj, "clicked", G_CALLBACK(react_blink_device), NULL);
obj = gtk_builder_get_object(builder, "btn_snapshot");
g_signal_connect(obj, "clicked", G_CALLBACK(react_snapshot_device), NULL);
obj = gtk_builder_get_object(builder, "btn_factory_default");
g_signal_connect(obj, "clicked", G_CALLBACK(react_default_device), NULL);

obj = gtk_builder_get_object(builder, "txt_device_id");
add_txt_change_id((GtkSpinButton *)obj);
Expand All @@ -180,6 +199,8 @@ int connect_all_signals()
_module.firmUpgradeStatus = (GtkLevelBar *)obj;
obj = gtk_builder_get_object(builder, "txt_device_name");
add_txt_device_name((GtkEntry *)obj);
obj = gtk_builder_get_object(builder, "txt_device_selftest_snapshot");
_module.snapshotTxt = (GtkTextBuffer *)obj;

/* Connect server address and port text change to react function */

Expand Down
8 changes: 8 additions & 0 deletions native/src/can_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ void react_blink_device(GtkWidget *widget, gpointer data)
{
blink_device(&_module.selected_device, frontend_callback);
}
void react_snapshot_device(GtkWidget *widget, gpointer data)
{
get_device_snapshot(&_module.selected_device, frontend_callback);
}
void react_default_device(GtkWidget *widget, gpointer data)
{
factory_default_device(&_module.selected_device, frontend_callback);
}

2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_MAJOR 0
VERSION_MINOR 2
VERSION_MINOR 3
VERSION_PATCH 0

0 comments on commit 8176369

Please sign in to comment.