Show
Ignore:
Timestamp:
11/20/08 09:22:18 (5 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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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");