Browse Source

Add support for short writes with PEC.

git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5771 7894878c-1315-0410-8ee3-d5d059ff63e0
tags/v3.0.3
Jean Delvare 16 years ago
parent
commit
2ea4dccae0
  1. 1
      CHANGES
  2. 6
      tools/i2cset.8
  3. 26
      tools/i2cset.c

1
CHANGES

@ -14,6 +14,7 @@ SVN
Decode voltage interface level of DDR SDRAM
decode-xeon: Delete
eepromer: Fix array initialization overrun
i2cset: Add support for short writes with PEC
i2c-stub-from-dump: Use udev settle to speed up initialization
3.0.2 (2008-11-29)

6
tools/i2cset.8

@ -11,7 +11,8 @@ i2cset \- set I2C registers
.I i2cbus
.I chip-address
.I data-address
.RI [ "value " [ "mode" ]]
.RI [ value ]
.RI [ mode ]
.br
.B i2cset
.B -V
@ -73,6 +74,9 @@ respectively. A \fBp\fP can also be appended to the \fImode\fR parameter to
enable PEC. If the \fImode\fR parameter is omitted, i2cset defaults to byte
mode without PEC. The \fIvalue\fR provided must be within range for the
specified data type (0x00-0xFF for bytes, 0x0000-0xFFFF for words).
Another possible mode is \fBc\fP, which doesn't write any value (so-called
short write). You usually don't have to specify this mode, as it is the
default when no value is provided, unless you also want to enable PEC.
.SH WARNING
i2cset can be extremely dangerous if used improperly. It can confuse your

26
tools/i2cset.c

@ -2,7 +2,7 @@
i2cset.c - A user-space program to write an I2C register.
Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2008 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2009 Jean Delvare <khali@linux-fr.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -35,12 +35,13 @@ static void help(void) __attribute__ ((noreturn));
static void help(void)
{
fprintf(stderr,
"Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE [MODE]]\n"
"Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] [MODE]\n"
" I2CBUS is an integer or an I2C bus name\n"
" ADDRESS is an integer (0x03 - 0x77)\n"
" MODE is one of:\n"
" b (byte, default)\n"
" w (word)\n"
" c (byte, no value)\n"
" b (byte data, default)\n"
" w (word data)\n"
" Append p for SMBus PEC\n");
exit(1);
}
@ -180,11 +181,18 @@ int main(int argc, char *argv[])
}
if (argc > flags + 4) {
size = I2C_SMBUS_BYTE_DATA;
value = strtol(argv[flags+4], &end, 0);
if (*end || value < 0) {
fprintf(stderr, "Error: Data value invalid!\n");
help();
if (!strcmp(argv[flags+4], "c")
|| !strcmp(argv[flags+4], "cp")) {
size = I2C_SMBUS_BYTE;
value = -1;
pec = argv[flags+4][1] == 'p';
} else {
size = I2C_SMBUS_BYTE_DATA;
value = strtol(argv[flags+4], &end, 0);
if (*end || value < 0) {
fprintf(stderr, "Error: Data value invalid!\n");
help();
}
}
} else {
size = I2C_SMBUS_BYTE;

Loading…
Cancel
Save