     if (count == sizeof(data)) {
       cout << PSTR("device = ") << hex << addr 
 	   << PSTR(":group = ") << (addr >> 3) << '.' << (addr & 0x07);
-      str_P name = lookup(addr);
+      str_P name = lookup(addr, &dev);
       if (name != NULL) cout << ':' << name;
       cout << endl;
     }

const char at24cxx[]  __PROGMEM = "AT24CXX, Serial EEPROM";
const char bmp085[]   __PROGMEM = "BMP085, Digital Pressure Sensor";
const char ds1307[]   __PROGMEM = "DS1307, Real-Time Clock";
const char hmc5883l[] __PROGMEM = "HMC5883L, 3-Axis Digital Compass";
const char pcf8574[]  __PROGMEM = "PCF8574, Remote 8-bit I/O Expander";
const char pcf8574a[] __PROGMEM = "PCF8574A, Remote 8-bit I/O Expander";
const char pcf8591[]  __PROGMEM = "PCF8591, 8-bit A/D and D/A Converter";
const char l3g4200d[] __PROGMEM = "L3G4200D, 3-Axis Digital Gyroscope";

/**
 * Device table in program memory.
 */
const tab_t dev[] __PROGMEM = {
  { 0x53, 0xff, adxl345  },
  { 0x50, 0xf8, at24cxx  },
  { 0x77, 0xff, bmp085   },
  { 0x68, 0xff, ds1307   },
  { 0x1e, 0xff, hmc5883l },
  { 0x20, 0xf8, pcf8574  },
  { 0x70, 0xf8, pcf8574a },
  { 0x48, 0xf8, pcf8591  },
  { 0x68, 0xfe, l3g4200d },
};

/**
 * Lookup up device given bus address. Return name string in program memory 
 * if successful otherwise NULL.
 * @param[in] addr device bus address (with possible sub-address).
 * @return program memory string pointer or NULL.
 */
str_P 
lookup(uint8_t addr)
{
  for (uint8_t i = 0; i < membersof(dev); i++)
    if (pgm_read_byte(&dev[i].addr) == (addr & pgm_read_byte(&dev[i].mask)))
      return ((str_P) pgm_read_word(&dev[i].name));
  return (NULL);
}


struct tab_t {
  uint8_t addr;
  uint8_t mask;
  uint8_t subaddr;
  uint8_t id;
  str_P name;
};

