Commit 6096b3e0 authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

all prints now in logger

parent a48c5746
......@@ -74,7 +74,7 @@ while (WatchDogCounter > 0):
while ser.inWaiting() > 0:
charSet += ser.read()
while len(charSet) > 0 and charSet[0] != 0x55:
print("Deleted the following bytes, because they do not start with 0x55: (int)", charSet.pop(0))
logger.warning("Deleted the following bytes, because they do not start with 0x55: (int)"+str(charSet.pop(0)) )
if len(charSet) >= 8: # At least Sync-byte, Header (4byte), CRC8H, Data (min 1byte) and CRCD is available
pHeader, pCRCHeader = charSet[1:5], charSet[5]
......@@ -92,15 +92,14 @@ while (WatchDogCounter > 0):
t = time.mktime(t.timetuple()) + t.microsecond / 1E6
pData, pOptData = charSet[6:6+pDataLength], charSet[6 +
pDataLength:6+pDataLength+pOptionalLength]
print("pPaketType", pPaketType, "Data",
pData, "OptData", pOptData)
logger.info("pPaketType: "+str(pPaketType)+" Data: "+str(pData), " OptData: "+str(pOptData))
# list() converts bytearray into array of int
t = datetime.now()
t = time.mktime(t.timetuple()) + t.microsecond / 1E6
client.publish("homie/"+args.mqtt_client_name)+"/enocean-messages", json.dumps(
client.publish("homie/"+args.mqtt_client_name+"/enocean-messages", json.dumps(
{"type": pPaketType, "data": list(pData), "optData": list(pOptData), "time": t}), qos = 1)
else:
print("Data CRC NOT ok")
logger.warning("Data CRC NOT ok")
# Delete the processed data and propare for next paket to receive
charSet=charSet[pDataLength+pOptionalLength+7:]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment