/** \file
 *
 *  Contains the I2C class declaration.
 *
 *  Copyright (c) 2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *
 */

#ifndef I2C_H_
#define I2C_H_

#include "data/Slate.h"
#include "io/DeviceIOStream.h"

/**
 *  This class allows one to read/write to the i2c bus
 *
 *  \ingroup io
 */
class I2C
{
public:
    /// Constructor
    I2C( const ConfigURI& i2cCfg, const ConfigURI& i2cAddr, bool useHardware, Logger& logger );

    virtual ~I2C();

    // Reads from the device
    bool readBytes( char* bytes, size_t numBytes );

    // Writes to the device
    void writeBytes( char * );
    void writeBytes( char *, size_t numBytes );


private:
    static int ReadAddress( const ConfigURI& addressUri, Logger& logger );

    bool useHardware_;
    DeviceIOStream io_;
    Logger& logger_;
    int address_;
};

#endif /* I2C_H_ */
