From 0efc9bf4fc326599858ec7630a6f9aeaece5db23 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 26 Apr 2013 22:42:58 +0900 Subject: Send a idn command to the daemon and print the first line of it before accepting user input --- instr-client.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/instr-client.c b/instr-client.c index 990abc2..4855abc 100644 --- a/instr-client.c +++ b/instr-client.c @@ -175,12 +175,31 @@ int main(int argc, char** argv) g_object_unref(client); return -1; } - g_printf("\r\nWelcome! Avtech Electrosystems Ltd. - Firmware v%s\r\n\r\n",FW_VERSION); - g_print("> "); - //register Pollable sources out = g_io_stream_get_output_stream (G_IO_STREAM (connection)); in = g_io_stream_get_input_stream (G_IO_STREAM (connection)); + + g_printf("\r\nWelcome! Avtech Electrosystems Ltd. - Firmware v%s\r\n",FW_VERSION); + + // send an idn command + const gchar idncmd[] = "*idn?\n"; + g_output_stream_write(out, (void*) &idncmd, sizeof(idncmd), NULL, NULL ); + g_output_stream_flush(out, NULL, NULL ); + gchar ch; + gboolean print = TRUE; + // drain the input stream until the prompt, print out everything until a newline + while (ch != '>') { + g_input_stream_read(in, &ch, 1, NULL, NULL ); + if (ch == '\n') + print = FALSE; + if (print == TRUE) + printf("%c", ch); + } + printf("\r\n\r\n"); + + g_print("> "); + + //register Pollable sources GSource *outSource = NULL; GSource *inSource = g_pollable_input_stream_create_source((struct GPollableInputStream*)in, NULL); outSource = g_pollable_output_stream_create_source((struct GPollableOutputStream*)out, NULL); -- cgit