Browse Source

Set the data value mask with -m. The old method is still supported for

compatibility, but is considered deprecated and is no longer documented.


git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5390 7894878c-1315-0410-8ee3-d5d059ff63e0
tags/v3.0.2
Jean Delvare 17 years ago
parent
commit
c797cbaaeb
  1. 1
      CHANGES
  2. 16
      tools/i2cset.8
  3. 22
      tools/i2cset.c

1
CHANGES

@ -22,6 +22,7 @@ SVN
Split the code into several functions for clarity
Add support for short writes (SMBus send byte)
Better error message on missing adapter functionality
Set the data value mask with -m
i2c-stub-from-dump: Add support for partial dumps
Report if only garbage is found in dump file
Behave properly when i2c-stub is already loaded

16
tools/i2cset.8

@ -1,4 +1,4 @@
.TH I2CSET 8 "May 2008"
.TH I2CSET 8 "November 2008"
.SH "NAME"
i2cset \- set I2C registers
@ -6,10 +6,11 @@ i2cset \- set I2C registers
.B i2cset
.RB [ -f ]
.RB [ -y ]
.RB [ "-m mask" ]
.I i2cbus
.I chip-address
.I data-address
.RI [ "value " [ "mode " [ mask ]]]
.RI [ "value " [ "mode" ]]
.br
.B i2cset
.B -V
@ -36,6 +37,12 @@ Disable interactive mode. By default, i2cset will wait for a confirmation
from the user before messing with the I2C bus. When this flag is used, it
will perform the operation directly. This is mainly meant to be used in
scripts.
.TP
.B -m mask
The \fImask\fR parameter, if specified, describes which bits of \fIvalue\fR
will be actually written to \fIdata-address\fR. Bits set to 1 in the mask
are taken from \fIvalue\fR, while bits set to 0 will be read from
\fIdata-address\fR and thus preserved by the operation.
.PP
There are three required options to i2cset. \fIi2cbus\fR indicates the number
or name of the I2C bus to be scanned. This number should correspond to one of
@ -57,11 +64,6 @@ 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).
.PP
The \fImask\fR parameter, if specified, describes which bits of \fIvalue\fR
will be actually written to \fIdata-address\fR. Bits set to 1 in the mask
are taken from \fIvalue\fR, while bits set to 0 will be read from
\fIdata-address\fR and thus preserved by the operation.
.SH WARNING
i2cset can be extremely dangerous if used improperly. It can confuse your

22
tools/i2cset.c

@ -35,7 +35,7 @@ static void help(void) __attribute__ ((noreturn));
static void help(void)
{
fprintf(stderr,
"Usage: i2cset [-f] [-y] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE [MODE [MASK]]]\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"
@ -128,6 +128,7 @@ static int confirm(const char *filename, int address, int size, int daddress,
int main(int argc, char *argv[])
{
char *end;
const char *maskp = NULL;
int res, i2cbus, address, size, file;
int value, daddress, vmask = 0;
char filename[20];
@ -141,6 +142,11 @@ int main(int argc, char *argv[])
case 'V': version = 1; break;
case 'f': force = 1; break;
case 'y': yes = 1; break;
case 'm':
if (2+flags < argc)
maskp = argv[2+flags];
flags++;
break;
default:
fprintf(stderr, "Error: Unsupported option "
"\"%s\"!\n", argv[1+flags]);
@ -195,8 +201,20 @@ int main(int argc, char *argv[])
pec = argv[flags+5][1] == 'p';
}
/* Old method to provide the value mask, deprecated and no longer
documented but still supported for compatibility */
if (argc > flags + 6) {
vmask = strtol(argv[flags+6], &end, 0);
if (maskp) {
fprintf(stderr, "Error: Data value mask provided twice!\n");
help();
}
fprintf(stderr, "Warning: Using deprecated way to set the data value mask!\n");
fprintf(stderr, " Please switch to using -m.\n");
maskp = argv[flags+6];
}
if (maskp && size != I2C_SMBUS_BYTE) {
vmask = strtol(maskp, &end, 0);
if (*end || vmask == 0) {
fprintf(stderr, "Error: Data value mask invalid!\n");
help();

Loading…
Cancel
Save