Fixes ipp reading from Micro800 using class instances

This commit is contained in:
Patrick McDonagh
2016-07-15 17:00:22 -05:00
parent d1440a9a36
commit 0f0bbdd061
2 changed files with 4 additions and 6 deletions

View File

@@ -2,13 +2,13 @@
import threading import threading
import time import time
import pickle
from device_base import deviceBase from device_base import deviceBase
import micro800 as u800 import micro800 as u800
addr = '10.20.4.5' addr = '10.20.4.5'
channels = {} channels = {}
class Channel(): class Channel():
def read(self): def read(self):
valData = u800.readMicroTag(self.device_addr, self.tag) valData = u800.readMicroTag(self.device_addr, self.tag)
@@ -54,13 +54,11 @@ class Channel():
self.e300_param = e300_param self.e300_param = e300_param
self.read() self.read()
def write(self, val, handshake=None, handshake_val=None): def write(self, val, handshake=None, handshake_val=None):
if self.writeable: if self.writeable:
h = handshake h = handshake
hval = handshake_val hval = handshake_val
if h == None: if h is None:
if u800.writeMicroTag(self.device_addr, self.tag, val, handshake=self.tag, handshake_val=val): if u800.writeMicroTag(self.device_addr, self.tag, val, handshake=self.tag, handshake_val=val):
self.sendFn(self.name, val, time.time()) self.sendFn(self.name, val, time.time())
self.last_value = val self.last_value = val

View File

@@ -3,14 +3,14 @@ import sys
def readMicroTag(addr, tag): def readMicroTag(addr, tag):
addr = str(addr)
tag = str(tag)
c = u800Driver() c = u800Driver()
if c.open(addr, True): if c.open(addr, True):
try: try:
v = c.read_tag(tag) v = c.read_tag(tag)
# print(v) # print(v)
return v return v
except Exception: except Exception:
err = c.get_status() err = c.get_status()
c.close() c.close()