From 2a8794d0b694b0509c03d82c64c30559fa78239e Mon Sep 17 00:00:00 2001
From: Mark Tearle <mark@tearle.com>
Date: Sat, 14 Mar 2015 22:52:06 +0800
Subject: [PATCH] Bind to alternative port if not root

---
 TODO           | 9 +++++----
 virtualcoke.py | 5 ++++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/TODO b/TODO
index e84841c..c7dbebc 100644
--- a/TODO
+++ b/TODO
@@ -4,8 +4,9 @@ DONE Front panel buttons
 DONE Front panel out of drinks lamps 
 DONE Hidden slot buttons
 DONE Hidden other buttons
-DONE Coin Return Button
+DONE Hook up modbus
+DONE Test against dispense
+DONE Modbus alternative port
 
-Hook up modbus
-Test against dispense
-Write up documentation
+     Coin Return Button
+     Write up documentation
diff --git a/virtualcoke.py b/virtualcoke.py
index dea1004..9d41bb3 100755
--- a/virtualcoke.py
+++ b/virtualcoke.py
@@ -356,6 +356,9 @@ if __name__ == "__main__":
     context = modbus_setup(App)
 
     reactor.registerNpyscreenApp(App)
-    StartModbusAsyncServer(context)
+    try:
+    	StartModbusAsyncServer(context)
+    except:
+    	StartModbusAsyncServer(context, address=("", 1502))
     reactor.run()
 
-- 
GitLab