Commit 47e497e79ccb4c34cd3ed52188e11a8a36d62fa1
1 parent
fa8963a5
Enregistrement des données reçus dans le fichier xml correspondant
Showing
1 changed file
with
16 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,16 @@ |
1 | +#!usr/bin/env python | |
2 | + | |
3 | +import serial | |
4 | +from lxml import etree | |
5 | + | |
6 | +xml = etree.parse('111-1.xml') | |
7 | + | |
8 | +ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) | |
9 | +value = ser.readline() | |
10 | + | |
11 | +for parametre in xml.getchildren(): | |
12 | + if 'name' in parametre.attrib and parametre.attrib['name'] == 'data': | |
13 | + parametre.text = value | |
14 | +with open('111-1.xml', 'w') as myFile: | |
15 | + myFile.write(etree.tounicode(xml)) | |
16 | +myFile.close | |
0 | 17 | \ No newline at end of file | ... | ... |