Index: elec/CrO2/software/Makefile
===================================================================
--- elec/CrO2/software/Makefile	(revision 96bc8fa006ee031749a82a55de9acda94ff8b0c2)
+++ elec/CrO2/software/Makefile	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -23,5 +23,5 @@
 all: $(PROGRAM)
 
-$(PROGRAM): $(PROJECT).o device.o
+$(PROGRAM): $(PROJECT).o device.o poller.o
 	$(CC) -o $(PROGRAM) $^ $(LIBS)
 
Index: elec/CrO2/software/cro2.cpp
===================================================================
--- elec/CrO2/software/cro2.cpp	(revision 96bc8fa006ee031749a82a55de9acda94ff8b0c2)
+++ elec/CrO2/software/cro2.cpp	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -5,4 +5,5 @@
  */
 
+#include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
@@ -15,4 +16,5 @@
 
 #include "device.h"
+#include "poller.h"
 
 /* UI */
@@ -29,4 +31,5 @@
 
 
+Ihandle* motoron;
 void GUI_open(int* argc, char*** argv)
 {
@@ -48,4 +51,9 @@
 	);
 
+	// CONTROL
+	motoron = IupProgressBar();
+	IupSetAttribute(motoron, "RASTERSIZE", "16x16");
+
+	// EXPLORE
 	Ihandle* platformlist = IupList(NULL);
 	IupSetAttribute(platformlist, "EXPAND", "HORIZONTAL");
@@ -59,5 +67,14 @@
 	Ihandle* tabs = IupTabs(
 		IupVbox(
-			IupLabel("Hello World"),
+			IupHbox(
+				IupLabel("Motor"),
+				motoron,
+				NULL
+			),
+			IupHbox(
+				IupToggle("play",NULL),
+				IupToggle("REC",NULL),
+				NULL
+			),
 			NULL
 		),
@@ -89,4 +106,7 @@
 	IupShow(dialog);
 
+	// Run the timer
+	startPolling();
+
 	IupMainLoop();
 
@@ -106,55 +126,64 @@
     }
 
-	Device dev; // Constructor inits communication.
-		// TODO handle thrown exceptions.
+	try {
+		Device& dev = Device::getDevice(); // Constructor inits communication.
 
-    if(strcmp(argv[1], "get") == 0){
-		memset(buffer, 0, 275);
-		nBytes = dev.read(buffer, sizeof(buffer));
-    }else if(strcmp(argv[1], "put") == 0){
+		if(strcmp(argv[1], "get") == 0){
+			memset(buffer, 0, 275);
+			nBytes = dev.read(buffer, sizeof(buffer));
+		}else if(strcmp(argv[1], "put") == 0){
 
-		while (dev.getStatus() & 8)
-			usleep(1000000);
+			// wait for motor on
+			while (dev.getStatus() & 8)
+				usleep(1000000);
 
-		FILE* fptr = fopen(argv[2], "rb");
-		int blockid;
-		uint8_t blktype, blksize;
-		sscanf(argv[3], "%d", &blockid);
+			// load file
+			FILE* fptr = fopen(argv[2], "rb");
+			int blockid;
+			uint8_t blktype, blksize;
+			sscanf(argv[3], "%d", &blockid);
 
-		do
-		{
+			// fast-forward to requested block
 			do
 			{
+				do
+				{
+					fread(&blktype, 1, 1, fptr);
+					if (feof(fptr))
+					{
+						fprintf(stderr, "end of file.\n");
+						fclose(fptr);
+						exit(0);
+					}
+				}
+				while(blktype != 0x5A); // skip sync header
+
 				fread(&blktype, 1, 1, fptr);
-				if (feof(fptr))
+				fread(&blksize, 1, 1, fptr);
+				blksize -= 2;
+				fread(buffer, 1, blksize + 1, fptr);
+				if (blktype == 0)
 				{
-					fprintf(stderr, "end of file.\n");
-					fclose(fptr);
-					exit(0);
+					// new file
+					printf("%.11s\n",buffer);
 				}
 			}
-			while(blktype != 0x5A); // skip sync header
+			while (blockid --);
 
-			fread(&blktype, 1, 1, fptr);
-			fread(&blksize, 1, 1, fptr);
-			blksize -= 2;
-			fread(buffer, 1, blksize + 1, fptr);
-			if (blktype == 0)
-			{
-				// new file
-				printf("%.11s\n",buffer);
-			}
+			fclose(fptr);
+
+			nBytes = dev.write(buffer, blksize, blktype);
+		}else{
+			// TODO print usage
+			exit(2);
 		}
-		while (blockid --);
 
-		fclose(fptr);
-
-		nBytes = dev.write(buffer, blksize, blktype);
-    }else{
-		GUI_open(&argc, &argv);
-    }
-
-	if (nBytes < 0) fprintf(stderr, "USB error %s\n", usb_strerror());
-    return 0;
+		if (nBytes < 0) fprintf(stderr, "USB error %s\n", usb_strerror());
+		return 0;
+	}
+	catch(const char* error)
+	{
+		std::cerr << error << std::endl;
+	}
 }
 
Index: elec/CrO2/software/device.cpp
===================================================================
--- elec/CrO2/software/device.cpp	(revision 96bc8fa006ee031749a82a55de9acda94ff8b0c2)
+++ elec/CrO2/software/device.cpp	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -9,7 +9,6 @@
 #include "device.h"
 
-#include <iostream> // TODO remove
-
 bool Device::initOnce = false;
+Device* Device::instance = NULL;
 
 const uint32_t Device::vid = 0x16C0;
@@ -24,11 +23,25 @@
 #define PSCMD_STATUS   3
 
-/* USB device lookup by VID and PID, then Vendor and Product strings, as we use V-USB shared ID. */
-static int  usbGetStringAscii(usb_dev_handle *dev, int index, int langid, char *buf, int buflen)
+
+// Gets the device instance. Throws an error message if something bad happens.
+Device& Device::getDevice() throw(const char*)
+{
+	if (instance == NULL)
+		instance = new Device();
+
+	return *instance;
+}
+
+
+/* USB device lookup by VID and PID, then Vendor and Product strings, as we use
+ * V-USB shared ID. */
+static int  usbGetStringAscii(usb_dev_handle *dev, int index, int langid,
+	char *buf, int buflen)
 {
 char    buffer[256];
 int     rval, i;
 
-    if((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, langid, buffer, sizeof(buffer), 1000)) < 0)
+    if((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR,
+			(USB_DT_STRING << 8) + index, langid, buffer, sizeof(buffer), 1000)) < 0)
         return rval;
     if(buffer[1] != USB_DT_STRING)
@@ -49,5 +62,5 @@
 }
 
-Device::Device()
+Device::Device() throw(const char*)
 {
 	handle = NULL;
@@ -69,25 +82,22 @@
 				continue;
 
-			// Found device with correct VID and PID. Now try to match the strings
+			// Found device with correct VID and PID. Now try to match the 
+			// vendor and product strings
 			char    string[256];
 			int     len;
-			handle = usb_open(dev); /* we need to open the device in order to query strings */
+			handle = usb_open(dev);
+				/* we need to open the device in order to query strings */
 			if(!handle){
-				std::cerr << "Warning: cannot open USB device: " << usb_strerror() << std::endl;
 				continue;
 			}
 			/* now check whether the names match: */
-			len = usbGetStringAscii(handle, dev->descriptor.iManufacturer, 0x0409, string, sizeof(string));
-			if(len < 0)
-			{
-				std::cerr << "Warning: cannot query manufacturer for device: " << usb_strerror() << std::endl;
-			}
-			else
+			len = usbGetStringAscii(handle, dev->descriptor.iManufacturer,
+				0x0409, string, sizeof(string));
+			if(len >= 0)
 			{
 				if(strcmp(string, vendor) == 0){
-					len = usbGetStringAscii(handle, dev->descriptor.iProduct, 0x0409, string, sizeof(string));
-					if(len < 0){
-						std::cerr << "Warning: cannot query product for device: " << usb_strerror() << std::endl;
-					}else{
+					len = usbGetStringAscii(handle, dev->descriptor.iProduct,
+						0x0409, string, sizeof(string));
+					if(len >= 0){
 						if(strcmp(string, product) == 0)
 							break;
@@ -104,8 +114,6 @@
 	// At this point, either we have found a device and handle is pointing to it,
 	// or we failed and handle is NULL.
-	//
-	// TODO : use exceptions for error handling; instead of fprintf (not useable in GUI mode).
 	if (!handle)
-        std::cerr << "Could not find USB device \"" << product << "\" with vid=0x" << std::hex << vid << " pid=0x" << pid << std::endl;
+		throw "Device not found. Is the USB cable plugged correctly?";
 }
 
@@ -119,5 +127,6 @@
 int Device::read(uint8_t* buffer, size_t max)
 {
-	return usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, PSCMD_GET, 0,0, (char*)buffer, max, 5000);
+	return usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
+		PSCMD_GET, 0,0, (char*)buffer, max, 5000);
 
 }
@@ -127,5 +136,6 @@
 {
 	int rqtype = (size == 0) ? USB_ENDPOINT_IN:USB_ENDPOINT_OUT;
-	return usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | rqtype, PSCMD_PUT, blktype,0 /*checksum*/, (char*)buffer, size, 5000);
+	return usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | rqtype,
+		PSCMD_PUT, blktype,0 /*checksum*/, (char*)buffer, size, 5000);
 
 }
@@ -134,5 +144,6 @@
 {
 	uint8_t status;
-	usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, PSCMD_STATUS, 0,0, (char*)&status, 1, 5000);
+	usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
+		PSCMD_STATUS, 0,0, (char*)&status, 1, 5000);
 		// TODO handle errors (return value)
 	return status;
Index: elec/CrO2/software/device.h
===================================================================
--- elec/CrO2/software/device.h	(revision 96bc8fa006ee031749a82a55de9acda94ff8b0c2)
+++ elec/CrO2/software/device.h	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -14,5 +14,6 @@
 {
 	public:
-		Device(); // Open device and set it up for communication
+		static Device& getDevice() throw(const char*);
+
 		~Device();
 
@@ -22,7 +23,12 @@
 
 	private:
+		Device() throw(const char*); // Open device and set it up for communication
+		Device(const Device& other);
+
+
 		usb_dev_handle* handle;
 
 		static bool initOnce;
+		static Device* instance;
 
 		static const uint32_t vid;
Index: elec/CrO2/software/poller.cpp
===================================================================
--- elec/CrO2/software/poller.cpp	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
+++ elec/CrO2/software/poller.cpp	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -0,0 +1,24 @@
+#include "poller.h"
+
+#include "device.h"
+
+#include <stdint.h>
+
+
+	// Start status poller "thread"
+	int pollStatus(Ihandle* ih)
+	{
+		uint8_t status = Device::getDevice().getStatus();
+		if (status & 8)
+			IupSetAttribute(motoron, "VALUE", "0"); // motor OFF
+		else
+			IupSetAttribute(motoron, "VALUE", "1"); // motor ON
+		return IUP_DEFAULT;
+	}
+
+void startPolling() {
+	Ihandle* timer = IupTimer();
+	IupSetAttribute(timer, "TIME", "300");
+	IupSetCallback(timer, "ACTION_CB", pollStatus);
+	IupSetAttribute(timer, "RUN", "YES");
+}
Index: elec/CrO2/software/poller.h
===================================================================
--- elec/CrO2/software/poller.h	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
+++ elec/CrO2/software/poller.h	(revision 32c7682511a44bdb2ad4bdfc6948421a4892c4d5)
@@ -0,0 +1,5 @@
+#include <iup.h>
+
+void startPolling();
+
+extern Ihandle* motoron;
