fixed Unicode Problem in Logging Taurus File
This commit is contained in:
@@ -132,7 +132,10 @@ class TAURUS:
|
|||||||
request = []
|
request = []
|
||||||
for line in file.readlines ():
|
for line in file.readlines ():
|
||||||
if len (line) > 2:
|
if len (line) > 2:
|
||||||
self.log ("Line: %s" % line)
|
try:
|
||||||
|
self.log ("Line: %s" % line)
|
||||||
|
except:
|
||||||
|
self.log ("Line: couldn't be decoded")
|
||||||
linetype = line [0]
|
linetype = line [0]
|
||||||
linestatus = line [1]
|
linestatus = line [1]
|
||||||
linedata = line [2:]
|
linedata = line [2:]
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ herdewritefile = TAU_PRC.2
|
|||||||
|
|
||||||
|
|
||||||
[Animal Recognition]
|
[Animal Recognition]
|
||||||
animalrecognition = 0
|
animalrecognition = 1
|
||||||
rfiddev = /dev/serial0
|
rfiddev = /dev/serial0
|
||||||
|
|
||||||
|
|||||||
22
lactor.py
22
lactor.py
@@ -19,6 +19,8 @@ infotype = {0 : 'S-Buffer deleted',
|
|||||||
6 : 'state'
|
6 : 'state'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ganimalnr = 0
|
||||||
|
|
||||||
class CanListener (can.Listener):
|
class CanListener (can.Listener):
|
||||||
def on_message_received (self, msg):
|
def on_message_received (self, msg):
|
||||||
print ("Received Data")
|
print ("Received Data")
|
||||||
@@ -32,6 +34,7 @@ class CanListener (can.Listener):
|
|||||||
self.loglevel = 9
|
self.loglevel = 9
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[arbitration_id', 'data', 'dlc', 'id_type', 'is_error_frame', 'is_extended_id', 'is_remote_frame', 'timestamp']
|
#[arbitration_id', 'data', 'dlc', 'id_type', 'is_error_frame', 'is_extended_id', 'is_remote_frame', 'timestamp']
|
||||||
#<class 'can.message.Message'>
|
#<class 'can.message.Message'>
|
||||||
#Timestamp: 1499861978.530813 ID: 0581 000 DLC: 8 20 20 20 20 30 30 30 30
|
#Timestamp: 1499861978.530813 ID: 0581 000 DLC: 8 20 20 20 20 30 30 30 30
|
||||||
@@ -103,7 +106,7 @@ class CanListener (can.Listener):
|
|||||||
if 'REQ' in str (_data):
|
if 'REQ' in str (_data):
|
||||||
self.log ("Anforderung Tiernummer von Tiererkennung", 3)
|
self.log ("Anforderung Tiernummer von Tiererkennung", 3)
|
||||||
#FixMe AnimalNr from rFID
|
#FixMe AnimalNr from rFID
|
||||||
animalnr = 12
|
animalnr = ganimalnr
|
||||||
#_sendecho = 0
|
#_sendecho = 0
|
||||||
_repdata = bytearray (('REP00%03d' % animalnr).encode ())
|
_repdata = bytearray (('REP00%03d' % animalnr).encode ())
|
||||||
self.waitack [_address] = 1
|
self.waitack [_address] = 1
|
||||||
@@ -188,12 +191,12 @@ class CanListener (can.Listener):
|
|||||||
elif infotype [_info_type] == 'milking time':
|
elif infotype [_info_type] == 'milking time':
|
||||||
if self.dataset [_address]:
|
if self.dataset [_address]:
|
||||||
self.log ("Melkzeit fuer vorhandenen Datensatz im Puffer %s" % self.dataset [_address])
|
self.log ("Melkzeit fuer vorhandenen Datensatz im Puffer %s" % self.dataset [_address])
|
||||||
self.dataset [_address] ['time'] = int (_data)
|
self.dataset [_address] ['time'] = int (_data) / 100 * 60 + int (_data) % 100
|
||||||
animalinfo = self.db_con.getanimal (self.dataset [_address]['animalnr'])
|
animalinfo = self.db_con.getanimal (self.dataset [_address]['animalnr'])
|
||||||
if len (animalinfo):
|
if len (animalinfo):
|
||||||
self.log ("Tier in DB gefunden", 5)
|
self.log ("Tier in DB gefunden", 5)
|
||||||
else:
|
else:
|
||||||
self.log ("Tier %d nicht in DB gefunden - wird autmatisch angelewgt" % (self.dataset [_address]['animalnr']), 1)
|
self.log ("Tier %d nicht in DB gefunden - wird autmatisch angelegt" % (self.dataset [_address]['animalnr']), 1)
|
||||||
#FixMe Check Animal Nr Range + x
|
#FixMe Check Animal Nr Range + x
|
||||||
_animaldata = {'animalnr' : self.dataset [_address]['animalnr'],
|
_animaldata = {'animalnr' : self.dataset [_address]['animalnr'],
|
||||||
'earmark' : '2730000000000000',
|
'earmark' : '2730000000000000',
|
||||||
@@ -293,14 +296,18 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
|
|
||||||
c_animalrecognition = config.get ('Animal Recognition', 'animalrecognition')
|
c_animalrecognition = config.get ('Animal Recognition', 'animalrecognition')
|
||||||
|
c_animalrecognition = 0
|
||||||
if c_animalrecognition:
|
if c_animalrecognition:
|
||||||
|
print ('Animalrecognition configured')
|
||||||
c_rfiddev = config.get ('Animal Recognition', 'rfiddev')
|
c_rfiddev = config.get ('Animal Recognition', 'rfiddev')
|
||||||
|
print (' with device %s' % c_rfiddev)
|
||||||
if not c_rfiddev:
|
if not c_rfiddev:
|
||||||
print ('No RFID Device configured')
|
print ('No RFID Device configured')
|
||||||
sys.exit (0)
|
sys.exit (0)
|
||||||
"""
|
"""
|
||||||
Nedap RFID Reader
|
Nedap RFID Reader
|
||||||
"""
|
"""
|
||||||
|
print ('RFID configured')
|
||||||
rfid = serial.Serial (port = c_rfiddev,\
|
rfid = serial.Serial (port = c_rfiddev,\
|
||||||
baudrate = "9600",\
|
baudrate = "9600",\
|
||||||
bytesize = 8,\
|
bytesize = 8,\
|
||||||
@@ -334,18 +341,21 @@ if __name__ == "__main__":
|
|||||||
d = rfid.read ()
|
d = rfid.read ()
|
||||||
if len (d):
|
if len (d):
|
||||||
try:
|
try:
|
||||||
readbuffer += d.decode("utf-8")
|
b = d.decode("utf-8")
|
||||||
print ('Decode Error')
|
|
||||||
except:
|
except:
|
||||||
readbuffer = readbuffer
|
print ("Decode Error %s" % d)
|
||||||
|
b = ''
|
||||||
|
readbuffer += b
|
||||||
if readbuffer [-2:] == '\r\n':
|
if readbuffer [-2:] == '\r\n':
|
||||||
if online:
|
if online:
|
||||||
data = readbuffer.split (' ')
|
data = readbuffer.split (' ')
|
||||||
if len (data) == 3:
|
if len (data) == 3:
|
||||||
newanimalnr = data [2]
|
newanimalnr = data [2]
|
||||||
|
print ("Tiernummer gelesen %s" % newanimalnr)
|
||||||
if newanimalnr != animalnr:
|
if newanimalnr != animalnr:
|
||||||
print ("Neue Tiernummer %s" % newanimalnr)
|
print ("Neue Tiernummer %s" % newanimalnr)
|
||||||
animalnr = newanimalnr
|
animalnr = newanimalnr
|
||||||
|
ganimalnr = animalnr
|
||||||
|
|
||||||
readbuffer = ''
|
readbuffer = ''
|
||||||
online = 1
|
online = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user