From 0140955d5e80254a03c9b3ce8b3046b162f65f2f Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Fri, 7 Dec 2012 10:01:40 -0500 Subject: added GPIB/VXI locking skeleton --- globals.c | 4 +++- globals.h | 7 +++++++ instr-daemon.c | 23 ++++++++++++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/globals.c b/globals.c index d63aa2e..90bfb39 100644 --- a/globals.c +++ b/globals.c @@ -13,7 +13,9 @@ GlobalStruct globals = { .Registers.last_relay_driver_settings[1] = -1, .Registers.last_relay_driver_settings[2] = -1, - .Registers.gpib_buffer[0] = 0 + .Registers.gpib_buffer[0] = 0, + + .4882Locks.locked_network_server = NO_SERVER_LOCKED }; diff --git a/globals.h b/globals.h index a4b0745..52a3503 100644 --- a/globals.h +++ b/globals.h @@ -779,6 +779,12 @@ typedef struct { } HWDetectStruct; +#define NO_SERVER_LOCKED -1 +typedef struct { + int command_in_progress; + int locked_network_server; +} LockStruct; + typedef struct { ConstraintsStruct Constraints; ChannelStruct ChannelState[max_channels]; @@ -793,6 +799,7 @@ typedef struct { MenuStatusStruct MenuStatus; RemoteStruct Remote; HWDetectStruct HWDetect; + LockStruct 4882Locks; } GlobalStruct; diff --git a/instr-daemon.c b/instr-daemon.c index ec70f97..2097a6c 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -403,13 +403,26 @@ static gboolean periodic_poll (void) Update_Main_Menu_If_Visible(); - GPIB_check_for_device_clear_signal(); - if (GPIB_check_for_messages(globals.Registers.gpib_buffer)) { - if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) { - Parser_main(globals.Registers.gpib_buffer, 0, GPIB_send_query_response, NULL); + // don't check GPIB interface if a VXI interface is locked, + // or is currently handling a command + + if ((globals.4882Locks.locked_network_server == NO_SERVER_LOCKED) && + (globals.4882Locks.command_in_progress == FALSE)) { + + // tell VXI servers that the 4882 subsystem is busy + globals.4882Locks.command_in_progress = TRUE; + + GPIB_check_for_device_clear_signal(); + if (GPIB_check_for_messages(globals.Registers.gpib_buffer)) { + if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) { + Parser_main(globals.Registers.gpib_buffer, 0, GPIB_send_query_response, NULL); + } } + GPIB_check_for_device_clear_signal(); + + // tell VXI servers that the 4882 subsystem is avilable again + globals.4882Locks.command_in_progress = FALSE; } - GPIB_check_for_device_clear_signal(); Update_Main_Menu_If_Visible(); } -- cgit