Changeset 5390

Show
Ignore:
Timestamp:
11/20/08 09:22:18 (6 years ago)
Author:
khali
Message:

Set the data value mask with -m. The old method is still supported for
compatibility, but is considered deprecated and is no longer documented.

Location:
i2c-tools/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • i2c-tools/trunk/CHANGES

    r5388 r5390  
    2323          Add support for short writes (SMBus send byte) 
    2424          Better error message on missing adapter functionality 
     25          Set the data value mask with -m 
    2526  i2c-stub-from-dump: Add support for partial dumps 
    2627                      Report if only garbage is found in dump file 
  • i2c-tools/trunk/tools/i2cset.8

    r5237 r5390  
    1 .TH I2CSET 8 "May 2008" 
     1.TH I2CSET 8 "November 2008" 
    22.SH "NAME" 
    33i2cset \- set I2C registers 
     
    77.RB [ -f ] 
    88.RB [ -y ] 
     9.RB [ "-m mask" ] 
    910.I i2cbus 
    1011.I chip-address 
    1112.I data-address 
    12 .RI [ "value " [ "mode " [ mask ]]] 
     13.RI [ "value " [ "mode" ]] 
    1314.br 
    1415.B i2cset 
     
    3738will perform the operation directly. This is mainly meant to be used in 
    3839scripts. 
     40.TP 
     41.B -m mask 
     42The \fImask\fR parameter, if specified, describes which bits of \fIvalue\fR 
     43will be actually written to \fIdata-address\fR. Bits set to 1 in the mask 
     44are taken from \fIvalue\fR, while bits set to 0 will be read from 
     45\fIdata-address\fR and thus preserved by the operation. 
    3946.PP 
    4047There are three required options to i2cset. \fIi2cbus\fR indicates the number 
     
    5865mode without PEC. The \fIvalue\fR provided must be within range for the 
    5966specified data type (0x00-0xFF for bytes, 0x0000-0xFFFF for words). 
    60 .PP 
    61 The \fImask\fR parameter, if specified, describes which bits of \fIvalue\fR 
    62 will be actually written to \fIdata-address\fR. Bits set to 1 in the mask 
    63 are taken from \fIvalue\fR, while bits set to 0 will be read from 
    64 \fIdata-address\fR and thus preserved by the operation. 
    6567 
    6668.SH WARNING 
  • i2c-tools/trunk/tools/i2cset.c

    r5242 r5390  
    3636{ 
    3737        fprintf(stderr, 
    38                 "Usage: i2cset [-f] [-y] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE [MODE [MASK]]]\n" 
     38                "Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE [MODE]]\n" 
    3939                "  I2CBUS is an integer or an I2C bus name\n" 
    4040                "  ADDRESS is an integer (0x03 - 0x77)\n" 
     
    129129{ 
    130130        char *end; 
     131        const char *maskp = NULL; 
    131132        int res, i2cbus, address, size, file; 
    132133        int value, daddress, vmask = 0; 
     
    142143                case 'f': force = 1; break; 
    143144                case 'y': yes = 1; break; 
     145                case 'm': 
     146                        if (2+flags < argc) 
     147                                maskp = argv[2+flags]; 
     148                        flags++; 
     149                        break; 
    144150                default: 
    145151                        fprintf(stderr, "Error: Unsupported option " 
     
    196202        } 
    197203 
     204        /* Old method to provide the value mask, deprecated and no longer 
     205           documented but still supported for compatibility */ 
    198206        if (argc > flags + 6) { 
    199                 vmask = strtol(argv[flags+6], &end, 0); 
     207                if (maskp) { 
     208                        fprintf(stderr, "Error: Data value mask provided twice!\n"); 
     209                        help(); 
     210                } 
     211                fprintf(stderr, "Warning: Using deprecated way to set the data value mask!\n"); 
     212                fprintf(stderr, "         Please switch to using -m.\n"); 
     213                maskp = argv[flags+6]; 
     214        } 
     215 
     216        if (maskp && size != I2C_SMBUS_BYTE) { 
     217                vmask = strtol(maskp, &end, 0); 
    200218                if (*end || vmask == 0) { 
    201219                        fprintf(stderr, "Error: Data value mask invalid!\n");