All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: i2cget bug report: errors reading words
       [not found] <CAH6gCJBbG4PMtnPLcLWOnPxBsXGPwXC3MivCF0ztujDfC9RNQw@mail.gmail.com>
@ 2021-11-09 14:36 ` Jean Delvare
  0 siblings, 0 replies; only message in thread
From: Jean Delvare @ 2021-11-09 14:36 UTC (permalink / raw)
  To: Chris Drake; +Cc: linux-i2c

Hi Chris,

On Tue, 9 Nov 2021 23:14:26 +1000, Chris Drake wrote:
> You forgot that we can read words as well as bytes from the current
> address...

I did not forget anything ;-)

> e.g - bold below:-
> 
> [pi@rpi src]$ i2cset -y 1 0x0D 0x09 0x1D  # set BMP280 continuous measure
> mode
> [pi@rpi src]$ i2cget -y 1 0x0d 0x00 w   # tell it to start reading at reg
> 0, and get the X word
> 0x065b
> [pi@rpi src]$ *i2cget -y 1 0x0d w*   # continue reading (i.e. get the Y
> word)
> Error: Data address invalid!
> Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
>   I2CBUS is an integer or an I2C bus name
>   ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)
>   MODE is one of:
>     b (read byte data, default)
>     w (read word data)
>     c (write byte/read byte)
>     Append p for SMBus PEC
> [pi@rpi src]$ i2cget -y 1 0x0d w # continue reading (i.e. get the Z word)
> Error: Data address invalid! [snip]
> 
> [pi@rpi src]$ *i2cget -y 1 0x0d* # Bug report - happy to read BYTES like
> this, but blows up trying to read words...
> 0x37
> 
> [pi@rpi src]$

There is no SMBus command to read a word without prior addressing, and
that's the reason why i2cget does not support it. i2cget only supports
SMBus-level transactions. Maybe the tool should have been named
"smbusget" to make it clearer...

Try i2ctransfer instead, which operates at I2C level and can do what
you need, assuming your underlying bus master is I2C-capable.

Hope that helps,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-09 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAH6gCJBbG4PMtnPLcLWOnPxBsXGPwXC3MivCF0ztujDfC9RNQw@mail.gmail.com>
2021-11-09 14:36 ` i2cget bug report: errors reading words Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.