I have been trying to use the MCP23017 along with my beaglebone.. I have however not received my devices yet, but I have started to get my program ready... I am programming the GPIO pins now.. Here I have tried to read and write the pins using i2c commands as follows: for write--
a=('i2cset', '-y', '0', '0x20', '0x14', '0x01')
subprocess.call(a, shell=True)
similarly using i2cget for reading.. However when I try to run it , it give me a notification on my screen saying
Usage: i2cset [-f] [-y I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03- 0x77)
Do I get this notification only because I don't have my device connected yet? Or is it a problem because of using the subprocess module?
Any help is appreciated,
Namita.
Assuming that you've tried the command in your shell and it worked. If you set shell=True
in subprocess.call()
, it's recommended to use a string instead of a sequence (a tuple in your case) as the first argument.
If you use shell=True
and pass a sequence as the first argument, the arguments from the second onwards will be treated as the parameters for the shell itself.
Please refer to this answer for more details: https://stackoverflow.com/a/15109975/870658
You can rewrite as below
cmd = 'i2cset -y 0 0x20 0x14 0x01'
subprocess.call(cmd, shell=True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.