summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-29 12:02:19 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-29 12:02:19 -0400
commit996f3d52275475f2478f377f12f0ef7571ecc795 (patch)
treeaf2e41489f3d1e6bccd3eb8e06063b2eeb15fc87 /parser.c
parent7c608618ce40421f1281bcdafd5616da7d1d7429 (diff)
added function to test broadcast messages
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/parser.c b/parser.c
index d5be649..1935c1a 100644
--- a/parser.c
+++ b/parser.c
@@ -117,6 +117,7 @@ static int Go_avrq_ampl(gchar** response, int channel, char *parameter,char *uni
static int Go_cal_100(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_cal_interval_101(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_eprom_reset_102(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_broadcast_103(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Parser_id_word(char *id_me, int *channel, int *with_id_code)
{
@@ -350,6 +351,8 @@ static int Parser_id_word(char *id_me, int *channel, int *with_id_code)
id_code = 107;
} else if (!strcmp(id_me,"reset") || !strcmp(id_me,"res")) {
id_code = 108;
+ } else if (!strcmp(id_me,"broadcast") ) { //FIXME
+ id_code = 109;
} else {
id_code = 9999;
}
@@ -474,7 +477,8 @@ static int Parser_find_commands(int commands[], int command_depth)
{23,106,88,93}, /* diag:slew:calib:point - 99 */
{88,107|optional}, /* calibration:all - 100 */
{88,37}, /* calibration:frequency - 101 */
- {23,57,108} /* diag:eprom:reset - 102 */
+ {23,57,108}, /* diag:eprom:reset - 102 */
+ {109} /* broadcast - 103 */
};
@@ -1051,6 +1055,9 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
case 102:
error_num=Go_eprom_reset_102(&response,channel,parameter,units,command_type);
break;
+ case 103:
+ error_num=Go_broadcast_103(&response,channel,parameter,units,command_type);
+ break;
case 9999:
// was only whitespace, ignore
@@ -4178,3 +4185,29 @@ static int Go_cal_interval_101(gchar** response, int channel, char *parameter,ch
}
+static int Go_broadcast_103(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ gchar *broadcast_str = NULL;
+
+ switch (command_type) {
+ case command_withparam:
+ broadcast_str = g_strdup_printf ("broadcast msg: %s\r\n> ", parameter);
+ g_printf ("%s", broadcast_str);
+ g_free (broadcast_str);
+ return OK;
+ break;
+
+ case command_param_units:
+ broadcast_str = g_strdup_printf ("broadcast msg: %s %s\r\n> ", parameter, units);
+ g_printf ("%s", broadcast_str);
+ g_free (broadcast_str);
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+
+ return ThisShouldntHappen;
+}