From 47e497e79ccb4c34cd3ed52188e11a8a36d62fa1 Mon Sep 17 00:00:00 2001 From: lahouass Date: Thu, 13 Feb 2020 11:41:37 +0100 Subject: [PATCH] Enregistrement des données reçus dans le fichier xml correspondant --- Rpi_to_xml.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+), 0 deletions(-) create mode 100644 Rpi_to_xml.py diff --git a/Rpi_to_xml.py b/Rpi_to_xml.py new file mode 100644 index 0000000..5653ddc --- /dev/null +++ b/Rpi_to_xml.py @@ -0,0 +1,16 @@ +#!usr/bin/env python + +import serial +from lxml import etree + +xml = etree.parse('111-1.xml') + +ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) +value = ser.readline() + +for parametre in xml.getchildren(): + if 'name' in parametre.attrib and parametre.attrib['name'] == 'data': + parametre.text = value +with open('111-1.xml', 'w') as myFile: + myFile.write(etree.tounicode(xml)) +myFile.close \ No newline at end of file -- libgit2 0.21.2