Better message tracking.

This commit is contained in:
Tim LaBerge
2012-03-31 18:18:00 -07:00
parent f3dbaf43ec
commit dd1f4408c9
4 changed files with 101 additions and 6 deletions

36
gdigi.c
View File

@@ -220,31 +220,37 @@ MessageID get_message_id(GString *msg)
void push_message(GString *msg) void push_message(GString *msg)
{ {
MessageID msgid = get_message_id(msg);
if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7)) if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7))
g_message("Pushing correct message!"); g_message("Pushing correct message!");
else else
g_warning("Pushing incorrect message!"); g_warning("Pushing incorrect message!");
int x; int x;
for (x = 0; x<msg->len; x++) for (x = 0; x<msg->len; x++) {
if (x && (x % 26) == 0) {
printf("\n");
}
printf("%02x ", (unsigned char)msg->str[x]); printf("%02x ", (unsigned char)msg->str[x]);
printf("\n"); }
if (x % 26) {
printf("\n");
}
g_message("Received %s", get_message_name(msgid));
switch (get_message_id(msg)) { switch (msgid) {
case ACK: case ACK:
g_message("Received ACK");
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
return; return;
case NACK: case NACK:
g_message("Received NACK");
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
return; return;
case RECEIVE_PARAMETER_VALUE: case RECEIVE_PARAMETER_VALUE:
unpack_message(msg); unpack_message(msg);
SettingParam *param = setting_param_new_from_data(&msg->str[8], NULL); SettingParam *param = setting_param_new_from_data(&msg->str[8], NULL);
g_message("Received parameter change ID: %d Position: %d Value: %d", param->id, param->position, param->value); g_message("ID: %d Position: %d Value: %d", param->id, param->position, param->value);
GDK_THREADS_ENTER(); GDK_THREADS_ENTER();
apply_setting_param_to_gui(param); apply_setting_param_to_gui(param);
@@ -400,6 +406,7 @@ void send_message(gint procedure, gchar *data, gint len)
g_string_append_printf(msg, "%c\xF7", g_string_append_printf(msg, "%c\xF7",
calculate_checksum(&msg->str[1], msg->len - 1)); calculate_checksum(&msg->str[1], msg->len - 1));
g_message("Sending message %s len %d", get_message_name(procedure), len);
send_data(msg->str, msg->len); send_data(msg->str, msg->len);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
@@ -626,6 +633,23 @@ SectionID get_genetx_section_id(gint version, gint type)
return -1; return -1;
} }
/**
* \param id Parameter ID
* \param position Parameter position
* \param value Parameter value
*
* Forms SysEx message to request parameter then sends it to device.
**/
void get_option(guint id, guint position)
{
GString *msg = g_string_sized_new(9);
g_message("Requesting parameter id %d position %d", id, position);
g_string_append_printf(msg, "%c%c%c",
((id & 0xFF00) >> 8), (id & 0xFF),
position);
send_message(REQUEST_PARAMETER_VALUE, msg->str, msg->len);
g_string_free(msg, TRUE);
}
/** /**
* \param id Parameter ID * \param id Parameter ID
* \param position Parameter position * \param position Parameter position

View File

@@ -1114,6 +1114,7 @@ void setting_genetx_free(SettingGenetx *genetx);
void setting_param_free(SettingParam *param); void setting_param_free(SettingParam *param);
SectionID get_genetx_section_id(gint version, gint type); SectionID get_genetx_section_id(gint version, gint type);
void set_option(guint id, guint position, guint value); void set_option(guint id, guint position, guint value);
void get_option(guint id, guint position);
void send_object(SectionID section, guint bank, guint index, void send_object(SectionID section, guint bank, guint index,
gchar *name, GString *data); gchar *name, GString *data);
void send_preset_parameters(GList *params); void send_preset_parameters(GList *params);

69
gui.c
View File

@@ -24,6 +24,71 @@
#include "preset.h" #include "preset.h"
#include "gtkknob.h" #include "gtkknob.h"
static gchar* MessageID_names[] = {
[REQUEST_WHO_AM_I] = "REQUEST_WHO_AM_I",
[RECEIVE_WHO_AM_I] = "RECEIVE_WHO_AM_I",
[REQUEST_DEVICE_CONFIGURATION] = "REQUEST_DEVICE_CONFIGURATION",
[RECEIVE_DEVICE_CONFIGURATION] = "RECEIVE_DEVICE_CONFIGURATION",
[REQUEST_GLOBAL_PARAMETERS] = "REQUEST_GLOBAL_PARAMETERS",
[RECEIVE_GLOBAL_PARAMETERS] = "RECEIVE_GLOBAL_PARAMETERS",
[REQUEST_BULK_DUMP] = "REQUEST_BULK_DUMP",
[RECEIVE_BULK_DUMP_START] = "RECEIVE_BULK_DUMP_START",
[RECEIVE_BULK_DUMP_END] = "RECEIVE_BULK_DUMP_END",
[REQUEST_PRESET_NAMES] = "REQUEST_PRESET_NAMES",
[RECEIVE_PRESET_NAMES] = "RECEIVE_PRESET_NAMES",
[REQUEST_PRESET_NAME] = "REQUEST_PRESET_NAME",
[RECEIVE_PRESET_NAME] = "RECEIVE_PRESET_NAME",
[REQUEST_PRESET] = "REQUEST_PRESET",
[RECEIVE_PRESET_START] = "RECEIVE_PRESET_START",
[RECEIVE_PRESET_END] = "RECEIVE_PRESET_END",
[RECEIVE_PRESET_PARAMETERS] = "RECEIVE_PRESET_PARAMETERS",
[LOAD_EDIT_BUFFER_PRESET] = "LOAD_EDIT_BUFFER_PRESET",
[MOVE_PRESET] = "MOVE_PRESET",
[REQUEST_MODIFIER_LINKABLE_LIST] = "REQUEST_MODIFIER_LINKABLE_LIST",
[RECEIVE_MODIFIER_LINKABLE_LIST] = "RECEIVE_MODIFIER_LINKABLE_LIST",
[REQUEST_PARAMETER_VALUE] = "REQUEST_PARAMETER_VALUE",
[RECEIVE_PARAMETER_VALUE] = "RECEIVE_PARAMETER_VALUE",
/* version 1 and later */
[REQUEST_OBJECT_NAMES] = "REQUEST_OBJECT_NAMES",
[RECEIVE_OBJECT_NAMES] = "RECEIVE_OBJECT_NAMES",
[REQUEST_OBJECT_NAME] = "REQUEST_OBJECT_NAME",
[RECEIVE_OBJECT_NAME] = "RECEIVE_OBJECT_NAME",
[REQUEST_OBJECT] = "REQUEST_OBJECT",
[RECEIVE_OBJECT] = "RECEIVE_OBJECT",
[MOVE_OBJECT] = "MOVE_OBJECT",
[DELETE_OBJECT] = "DELETE_OBJECT",
[REQUEST_TABLE] = "REQUEST_TABLE",
[RECEIVE_TABLE] = "RECEIVE_TABLE",
[RECEIVE_DEVICE_NOTIFICATION] = "RECEIVE_DEVICE_NOTIFICATION",
[ACK] = "ACK",
[NACK] = "NACK",
};
const gchar*
get_message_name(MessageID msgid)
{
if (MessageID_names[msgid]) {
return MessageID_names[msgid];
}
return "Unknown";
}
typedef struct { typedef struct {
GObject *widget; GObject *widget;
@@ -1287,6 +1352,10 @@ void gui_create(Device *device)
gtk_widget_show_all(window); gtk_widget_show_all(window);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
/* Not part of the preset, but update from the device. */
get_option(USB_AUDIO_LEVEL, USB_POSITION);
get_option(USB_AUDIO_PLAYBACK_MIX, USB_POSITION);
} }
/** /**

1
gui.h
View File

@@ -29,5 +29,6 @@ void gui_create(Device *device);
void gui_free(); void gui_free();
gboolean unsupported_device_dialog(Device **device); gboolean unsupported_device_dialog(Device **device);
gint select_device_dialog (GList *devices); gint select_device_dialog (GList *devices);
const gchar* get_message_name(MessageID msgid);
#endif /* GDIGI_GUI_H */ #endif /* GDIGI_GUI_H */