Commit 66c7a36418c8230148198254f0734d84a478e8c2

Authored by lahouass
1 parent 93a37a74

stockage des données dans le fichier xml correspondant

Showing 1 changed file with 16 additions and 0 deletions   Show diff stats
Rpi_to_server.py 0 → 100644
... ... @@ -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
... ...