Add an option -h to display the help of the tools. This is a common
practice so users may expect it to work.
Based on a preliminary patch from David Kerns.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Use the standard C getopt() function instead of parsing the options
manually. The benefit of this move is that getopt() supports merged
flags (for example -fy instead of -f -y) and does not require options
to come first on the command line. As this is pretty standard by now,
not supporting such possibilities can confuse and disappoint the user.
Based on a preliminary patch from David Kerns.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
The text was updated, but the mode character was forgotten.
Fixes: 789af53 ("i2cget: Add support for SMBus block read")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Users can turn to i2cget for this feature.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
i2cget is a better fit for this mode. Having it in i2cdump requires
special-casing in various places, which makes the code harder to read
and maintain.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Implementing range support for I2C block read (mode i) isn't
particularly difficult so let's just do that.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Considering that we exit immediately if an error happens during a
block read, the code filling the remaining bytes with -1 (so that
they will be displayed as "XX") is effectively dead code, so let's
remove it.
We might want to revisit the whole logic later, as there's in fact
little reason why block read errors would be fatal when all other
read errors are not. But I'd rather remove SMBus block support from
the tool before attempting to clean up the code.
Fixes: 7abc52d779 ("Return the correct error code on I2C block read failure.")
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Now that i2cget supports I2C block read, adding support for SMBus
block read is trivial. This restores the symmetry between i2cset and
i2cget, and paves the road for the removal of SMBus block read
support from i2cdump.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Mention I2C block read support in the i2cget(8) manual page, together
with an example.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
This adds mode 'i' for I2C_SMBUS_I2C_BLOCK_DATA. This is the same mode
letter from i2cdump.
Length is optional and defaults to 32 (maximum).
The intended use is debugging i2c devices with shell commands.
[JD: Fix the build (wrong variable name)
Ensure PEC isn't used in I2C block mode
Don't print the length (doesn't add value and could be mistaken as
an offset
Various cleanups]
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
The bus list (option -l) will be easier to read once sorted, as
typically this will group the buses by driver.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
This reverts commit 34806fc4e7. It was
developed against an experimental kernel. The regular kernel does not
update the new message length to userspace, so the check is always false
positive. We can't change the kernel behaviour because it would break
the ABI. So revert this commit.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Add the current maintainer to the mailing list as the contact points
for bug reports. This ensure that the reports will be read by the
right person.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Short writes used "daddress" for the value, but the masking code did
not expect that, and instead applied the mask to a variable that was
never used.
So change short writes to use "value" for the value, as all other
commands do. Adjust all code paths accordingly.
Reported by David Jedynak.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Emit a warning if the bus master driver in the kernel did not set the
message length correctly with I2C_M_RECV_LEN. This can be determined
from the returned value in the buffer.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
For all manpages installed on my Debian system, add a BUGS section, so
people can easily find whom to contact.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Sometimes I need to add some flags (like -static for the linker), so
allow this for all CFLAGS and LDFLAGS used in this project.
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Jean Delvare <jdelvare@suse.de>
The I2C standard reserves addresses 0x03-0x07. Adapt our tools to that.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
The text describing the address to be used did not reflect the recent
change where some of the functionality of '-f' has been seperated into
'-a'.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
There was a last instance of sprintf which somehow was not converted.
I know it can't fail, but for consistency, let's use snprintf and
check for truncation as we already do in gather_i2c_busses().
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Allow the user select a different strip tool for the build
(same as done with the CC and AR variables).
Contributed by Per Olav Kroka.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
We now have the flag '-a' for all i2c-tools to allow access for all
addresses. This was tied in i2ctransfer to the '-f' flag. Remove it and
keep that feature to '-a' only. This is also more in sync with the other
i2c-tools which use '-f' only to access already busy devices.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Reviewed-by: Peter Rosin <peda@axentia.se>
If the user is sure that the reserved 0x00 - 0x02 and 0x77 - 0x7f ranges
are not needed by its devices, then the "-a" option can be passed for
allowing all theorical addresses to be used. It is then possible to
access devices in this address range.
Signed-off-by: Romain Porte <romain.porte@nokia.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
[wsa: imonr fixes to commit message]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Better build the library before building the tools which link against
it, otherwise parallel builds could run into a race and break.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Acked-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Probably because of a bad rebase, the old and bogus handling (v1) of "force"
slipped into the latest version of the patch (v3). Apply the better
version from v2 which does the error handling correct and makes the code
a lot easier to understand.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
This tool allows to construct and concat multiple I2C messages into one
single transfer. Its aim is to test I2C master controllers, and so there
is no SMBus fallback.
I've been missing such a tool a number of times now, so I finally got
around to writing it myself. As with all I2C tools, it can be dangerous,
but it can also be very useful when developing.
It has been tested with various Renesas I2C IP cores as well as Tegra,
i.MX and AT91.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[wsa: fixed two more typos and ugly linebreak]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
When debugging embedded systems, it is often nice to simply TFTP the
desired i2ctool to the target without the hazzle of dealing with shared
libs. Using -static is overkill, too, so let's add a switch which will
only link functions from libi2c statically.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6289 7894878c-1315-0410-8ee3-d5d059ff63e0
library will host the i2c_smbus_*() inline functions which were
previously in the user-space flavor of <linux/i2c-dev.h>.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6054 7894878c-1315-0410-8ee3-d5d059ff63e0
Get and validate the command/mode parameter for all commands
before reading and evaluating actual data.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5926 7894878c-1315-0410-8ee3-d5d059ff63e0