Cy
2013-04-15 21:23:20 UTC
Thanks...
#!/usr/bin/python
import smbus
import time
import subprocess
bus = smbus.SMBus(1)
address = 0x04
pin = 1
pinMode = ""
pinMode += "gpio mode "
pinMode += str(pin)
pinMode += " pwm"
#print pinMode
from subprocess import call
call(pinMode, shell=True)
while True:
data = ""
bashCommand = ""
for i in range(0, 5):
data += chr(bus.read_byte(address));
print data
bashCommand += 'gpio pwm '
bashCommand += str(pin)
bashCommand += ' '
bashCommand += str(data)
call(bashCommand, shell=True)
time.sleep(1)
pi@raspberrypi ~ $ sudo python ./i2cPython2.py
1023
Traceback (most recent call last):
File "./i2cPython2.py", line 33, in
call(bashCommand, shell=True)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings