From 9765aa9bce2d6af2c427556d99f0c10ac0987a28 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 5 Aug 2014 10:44:43 +0100 Subject: [PATCH] i2c_HMC5883.py: add python I2c.read() example Signed-off-by: Brendan Le Foll --- examples/python/i2c_HMC5883.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/python/i2c_HMC5883.py b/examples/python/i2c_HMC5883.py index 0d440de..841f4ac 100644 --- a/examples/python/i2c_HMC5883.py +++ b/examples/python/i2c_HMC5883.py @@ -38,7 +38,16 @@ x.writeReg(HMC5883L_CONF_REG_B, HMC5883L_CONT_MODE) x.address(0x1E) x.write(HMC5883L_DATA_REG) +# this method takes a char* as an input where sizeof(m) defines the read size x.address(0x1E) m = " " print (x.read(m)) print (m) + +x.address(0x1E) +x.write(HMC5883L_DATA_REG) + +# this method simply takes a size_t arg and returns an std::string, however +# it's less efficient +x.address(0x1E) +print (x.read(6))