Changeset 2095

Show
Ignore:
Timestamp:
11/26/03 04:45:18 (9 years ago)
Author:
mds
Message:

add 'c' mode for consecutive address byte reads

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/dump/i2cdump.c

    r2065 r2095  
    4848{ 
    4949  fprintf(stderr,"Syntax: i2cdump I2CBUS ADDRESS [MODE] [BANK [BANKREG]]\n"); 
    50   fprintf(stderr,"  MODE is 'b[yte]', 'w[ord]', 's[mbusblock], or 'i[2cblock]' (default b)\n"); 
     50  fprintf(stderr,"  MODE is 'b[yte]', 'w[ord]', 's[mbusblock], 'i[2cblock]',\n"); 
     51  fprintf(stderr,"       or 'c[onsectutive byte address mode]' (default b)\n"); 
    5152  fprintf(stderr,"  Append MODE with 'p' for PEC checking\n"); 
    5253  fprintf(stderr,"  I2CBUS is an integer\n"); 
     
    121122  } else if (!strncmp(argv[3],"s",1)) { 
    122123    size = I2C_SMBUS_BLOCK_DATA; 
     124    pec = argv[3][1] == 'p'; 
     125  } else if (!strncmp(argv[3],"c",1)) { 
     126    size = I2C_SMBUS_BYTE; 
    123127    pec = argv[3][1] == 'p'; 
    124128  } else if (!strcmp(argv[3],"i")) 
     
    221225 
    222226  switch(size) { 
     227     case I2C_SMBUS_BYTE: 
     228#ifdef HAVE_PEC 
     229        if(pec) { 
     230          if (! (funcs & I2C_FUNC_SMBUS_READ_BYTE_PEC)) { 
     231             fprintf(stderr, "Error: Adapter for i2c bus %d", i2cbus); 
     232             fprintf(stderr, " does not have read w/ PEC capability\n"); 
     233             exit(1); 
     234          }        
     235        } else 
     236#endif 
     237        { 
     238          if (! (funcs & I2C_FUNC_SMBUS_READ_BYTE)) { 
     239             fprintf(stderr, "Error: Adapter for i2c bus %d", i2cbus); 
     240             fprintf(stderr, " does not have read capability\n"); 
     241             exit(1); 
     242          }        
     243        } 
     244        break; 
     245 
    223246     case I2C_SMBUS_BYTE_DATA: 
    224247#ifdef HAVE_PEC 
     
    312335          filename,address,size == I2C_SMBUS_BLOCK_DATA ? "smbus block" : 
    313336                           size == I2C_SMBUS_I2C_BLOCK_DATA ? "i2c block" : 
     337                           size == I2C_SMBUS_BYTE ? "byte consecutive read" : 
    314338                           size == I2C_SMBUS_BYTE_DATA ? "byte" : "word"); 
    315339  if(pec) 
     
    363387    } 
    364388 
     389    if(size == I2C_SMBUS_BYTE) { 
     390      res = i2c_smbus_write_byte(file, 0); 
     391      if(res != 0) { 
     392        fprintf(stderr, "Error: Write start address failed, return code %d\n", res); 
     393        exit(1); 
     394      } 
     395    } 
    365396    printf("     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef\n"); 
    366397    for (i = 0; i < 256; i+=16) { 
     
    368399      for(j = 0; j < 16; j++) { 
    369400        if(size == I2C_SMBUS_BYTE_DATA) { 
    370           res = i2c_smbus_read_byte_data(file,i+j); 
    371           block[i+j] = res; 
     401          block[i+j] = res = i2c_smbus_read_byte_data(file,i+j); 
     402        } else if(size == I2C_SMBUS_BYTE) { 
     403          block[i+j] = res = i2c_smbus_read_byte(file); 
    372404        } else 
    373405          res = block[i+j];