slotUI/SlotCli.py

changeset 86
79fb119cf3c3
parent 85
a637228562a7
child 87
761863c71884
--- a/slotUI/SlotCli.py	Fri Dec 16 00:24:35 2011 +0100
+++ b/slotUI/SlotCli.py	Fri Dec 16 00:41:36 2011 +0100
@@ -12,7 +12,7 @@
 from copy import copy
 import curses
 
-VERSION = "1.4"
+VERSION = "1.5"
 MAXSLOTS = 6
 TERM = {
     "caption": "\033[1;37m\033[1;44m",
@@ -43,9 +43,10 @@
         #Popen(["/usr/bin/mpg123", SOUNDS[what]]).pid
 
 class SlotCli():
-    def __init__(self):
+    def __init__(self, test = None):
         self.box = Blackbox()
-        self.box.connect()
+        if not test:
+            self.box.connect()
         self.slot_dummy = {
             "name": "Unnamed",
             "laps": 0,
@@ -135,8 +136,8 @@
         """
         Send initializing commands for live monitoring
         """
-        self.box.com.query("F1\n") # set fuel logic enabled
-        self.box.com.query("*1\n") # set live fuel info
+        self.box.query("F1\n") # set fuel logic enabled
+        self.box.query("*1\n") # set live fuel info
 
     def monitor(self):
         """
@@ -144,7 +145,7 @@
         Keyboard loop to control it???
         """
         # clear garbage in UART rx buffer
-        while self.box.com.readline() != "": pass
+        while self.box.readline() != "": pass
 
         self.monitor_init()
         self.scr = curses.initscr()
@@ -186,7 +187,7 @@
 
 
             # is there something in the rx buffer?
-            rx = self.box.com.readline()
+            rx = self.box.readline()
             if rx != "":
                 self.scr.addstr(10,0,
                     "Last RX: %19s" % rx, curses.color_pair(2))
@@ -311,7 +312,7 @@
     parser.add_option("--live", dest="live", action="store_true", default=False,
         help="Run Live monitor on console", metavar="[0-5]")
 
-    parser.add_option("--carid", dest="carid",
+    parser.add_option("--slot", dest="carid",
         help="Required for programming a car directly", metavar="[0-5]")
     parser.add_option("--fuel", dest="fuel",
         help="Set maximum CAR fuel level", metavar="[0-15]")
@@ -325,9 +326,11 @@
         help="Controlled SPEED LIMIT (15 = no limit)", metavar="[0-15]")
     parser.add_option("--drive", dest="drive",
         help="Controlled SPEED MINIMUM (0 = disabled)", metavar="[0-15]")
+    parser.add_option("--test", dest="test", action="store_true", default=False,
+        help="", metavar="")
 
     (options, args) = parser.parse_args()
-    cli = SlotCli()
+    cli = SlotCli(options.test)
     # should a CLI function be started?
 
     if options.live:

mercurial