From: Jean Delvare <jdelvare@suse.de>
To: Chris Drake <cryptophoto@gmail.com>
Cc: linux-i2c@vger.kernel.org
Subject: Re: i2cget bug report: errors reading words
Date: Tue, 9 Nov 2021 15:36:19 +0100 [thread overview]
Message-ID: <20211109153619.4416e9c3@endymion> (raw)
In-Reply-To: <CAH6gCJBbG4PMtnPLcLWOnPxBsXGPwXC3MivCF0ztujDfC9RNQw@mail.gmail.com>
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
parent reply other threads:[~2021-11-09 14:36 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAH6gCJBbG4PMtnPLcLWOnPxBsXGPwXC3MivCF0ztujDfC9RNQw@mail.gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211109153619.4416e9c3@endymion \
--to=jdelvare@suse.de \
--cc=cryptophoto@gmail.com \
--cc=linux-i2c@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).