IBASE MRS-801-RE User Manual

Page 58

Advertising
background image

50

MRS-801-RE User Manual

#include <unistd.h>

#include <linux/i2c-dev.h>

#include "i2cbusses.h"

#include "util.h"

#include "../version.h"

static void help(void) __attribute__ ((noreturn));

static void help(void)

{

fprintf(stderr,

"Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n"

" I2CBUS is an integer or an I2C bus name\n"

" ADDRESS is an integer (0x03 - 0x77)\n"

" MODE is one of:\n"

" b (read byte data, default)\n"

" w (read word data)\n"

" c (write byte/read byte)\n"

" Append p for SMBus PEC\n");

exit(1);

}

static int check_funcs(int file, int size, int daddress, int pec)

{

unsigned long funcs;

/* check adapter functionality */

if (ioctl(file, I2C_FUNCS, &funcs) < 0) {

fprintf(stderr, "Error: Could not get the adapter "

"functionality matrix: %s\n", strerror(errno));

return -1;

}

switch (size) {

case I2C_SMBUS_BYTE:

if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) {

fprintf(stderr, MISSING_FUNC_FMT, "SMBus receive byte");

return -1;

Advertising