first commit
This commit is contained in:
33
i2cs2.py
Executable file
33
i2cs2.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import smbus
|
||||
import time
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
bus = smbus.SMBus(1)
|
||||
address = 0x12
|
||||
|
||||
print "Envoi de la valeur 3 indiquant le debut de la demande"
|
||||
bus.write_byte(address, 3)
|
||||
# Pause de 1 seconde pour laisser le temps au traitement de se faire
|
||||
time.sleep(1)
|
||||
|
||||
data = ""
|
||||
for i in range(0, 200):
|
||||
data += chr(bus.read_byte(address));
|
||||
print data
|
||||
|
||||
datas = data.split("|")
|
||||
i = 0
|
||||
for d in datas:
|
||||
i = i + 1
|
||||
if i <= 7 :
|
||||
print d
|
||||
print "Send subprocess : curl http://localhost:81/json.htm?type=command¶m=udevice&" + d
|
||||
try:
|
||||
subprocess.Popen(["/usr/bin/curl", "http://localhost:81/json.htm?type=command¶m=udevice&" + d ])
|
||||
time.sleep(0.5)
|
||||
except:
|
||||
print "Error occured " + d
|
||||
print "Finish"
|
||||
Reference in New Issue
Block a user