diff options
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); |