ajout de la fonction de calcul du checksum

This commit is contained in:
Charlymd 2020-08-26 09:06:42 +02:00
parent a4a6e2fd38
commit 01e61f5eff

View file

@ -73,6 +73,16 @@ def add_measures(measures, time_measure):
client.write_points(points) client.write_points(points)
def calc_checksum(group):
# Calcul le caractere de controle d'une ligne de trame linky
# seule l'etiquette et la donnée de chaque ligne doivent etre envoyés en parametre group
data_unicode = 0
for data in group:
data_unicode += ord(data)
sum_unicode = (data_unicode & 63) + 32
sum = chr(sum_unicode)
return sum
def main(): def main():
with serial.Serial(port='/dev/ttyS0', baudrate=1200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, with serial.Serial(port='/dev/ttyS0', baudrate=1200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,