summaryrefslogtreecommitdiff
path: root/instr-daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'instr-daemon.c')
-rw-r--r--instr-daemon.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/instr-daemon.c b/instr-daemon.c
index 40a65b2..ee77e82 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -14,7 +14,10 @@
#include <stdlib.h>
#include <ctype.h>
#include <glib.h>
+<<<<<<< HEAD
#include <unistd.h>
+=======
+>>>>>>> b2c2c72d381ab1b32fa5b5fc4e890fef6c2bf1e0
#include <fcntl.h>
#define STDIN_BUF_SIZE 1024
@@ -317,7 +320,19 @@ int main(int argc, char **argv)
static gboolean periodic_poll (void)
{
if (bus_getpin (POWER_FAIL)) {
+<<<<<<< HEAD
//system ("/usr/bin/systemctl poweroff");
+=======
+
+ globals.Flags.shutdown_started = TRUE;
+
+ while (globals.Flags.flash_write_in_progress) {
+ g_usleep(1000);
+ }
+
+ LCD_clear();
+ LCD_write(0,0,"Power failed. Shutdown.");
+>>>>>>> b2c2c72d381ab1b32fa5b5fc4e890fef6c2bf1e0
// use plain old open to avoid any buffering etc
int enablefd = open("/proc/sys/kernel/sysrq", O_SYNC, O_RDWR);
@@ -332,6 +347,11 @@ static gboolean periodic_poll (void)
// sync disks
write(trgfd, "s\n", 2);
+<<<<<<< HEAD
+=======
+ // poweroff
+ system ("/usr/bin/systemctl poweroff -f");
+>>>>>>> b2c2c72d381ab1b32fa5b5fc4e890fef6c2bf1e0
}
Menu_Check_Buttons ();
@@ -342,12 +362,12 @@ static gboolean periodic_poll (void)
// is crashing due to non-functional bus
GPIB_check_for_device_clear_signal();
if (GPIB_check_for_messages(globals.Registers.gpib_buffer)) {
- if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) {
- // FIXME check_for_ctrl_mode_changes();
- Parser_main(globals.Registers.gpib_buffer, 0, NULL, NULL);
- }
- }
- GPIB_check_for_device_clear_signal();
+ if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) {
+ // FIXME check_for_ctrl_mode_changes();
+ Parser_main(globals.Registers.gpib_buffer, 0, NULL, NULL);
+ }
+ }
+ GPIB_check_for_device_clear_signal();
return TRUE;
}