diff options
author | daniel <danieruru@gmail.com> | 2013-04-26 22:42:58 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-04-26 22:42:58 +0900 |
commit | 0efc9bf4fc326599858ec7630a6f9aeaece5db23 (patch) | |
tree | db324269d276b43d866f80424d9e2a43257edf22 /instr-client.c | |
parent | c6b0a11a9475a408a542f3022a348d07d0e8464f (diff) |
Send a idn command to the daemon and print the first line of it before accepting user input
Diffstat (limited to 'instr-client.c')
-rw-r--r-- | instr-client.c | 25 |
1 files 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); |