![]() |
i2c
1.4.2
RoadNarrows Robotics I2C Package
|
Write bytes to a device on the I2C Bus. More...
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <libgen.h>
#include <unistd.h>
#include "rnr/rnrconfig.h"
#include "rnr/log.h"
#include "rnr/opts.h"
#include "rnr/i2c-dev.h"
#include "rnr/i2c.h"
#include "version.h"
Go to the source code of this file.
Functions | |
static int | execWrite (i2c_t *pI2C, int addr, byte_t writebuf[], int writelen) |
Execute I2C slave device write. More... | |
static int | StrToUnsigned (const char *s, uint_t *pVal) |
Convert string to unsigned integer. More... | |
static int | StrToByte (const char *s, byte_t *pByte) |
Convert string to byte. More... | |
static void | ArgsGet (int argc, char *argv[]) |
Get write bytes from command-line arguments. More... | |
static void | MainInit (int argc, char *argv[], i2c_t *pI2C) |
Command initialization. More... | |
int | main (int argc, char *argv[]) |
i2cwrite main() More... | |
Variables | |
static char * | Argv0 |
command name | |
static int | OptVerbose = 0 |
verbose option | |
static char * | OptDevName = "/dev/i2c/0" |
i2c bus device option | |
static int | OptDevFd = -1 |
opened i2c buse device fd option | |
static int | OptI2CAddr = -1 |
slave i2c device address | |
static byte_t | ArgWriteBuf [1024] |
write buffer argument | |
static int | ArgWriteLen = 0 |
write byte count arguement | |
static OptsPgmInfo_T | I2CWritePgmInfo |
Program Information. More... | |
static OptsInfo_T | I2CWriteOptsInfo [] |
Command Line Options Information. | |
Write bytes to a device on the I2C Bus.
Definition in file i2cwrite.c.
|
static |
Get write bytes from command-line arguments.
argc | Command-line argument count. |
argv | Command-line arguments. |
Definition at line 267 of file i2cwrite.c.
References Argv0, ArgWriteBuf, ArgWriteLen, and StrToByte().
Referenced by MainInit().
|
static |
Execute I2C slave device write.
pI2C | Pointer to I2C handle. |
addr | Slave device address. |
writebuf | Buffer to write. |
writelen | Number of write bytes. |
Definition at line 166 of file i2cwrite.c.
References Argv0, i2c_write(), and OptVerbose.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
i2cwrite main()
argc | Count of command-line options and arguments. |
argv | Array of command-line options and arguments. |
Definition at line 366 of file i2cwrite.c.
References ArgWriteBuf, ArgWriteLen, execWrite(), MainInit(), and OptI2CAddr.
|
static |
Command initialization.
argc | Command-line argument count. |
argv | Command-line arguments. |
pI2C | Pointer to I2C handle. |
Definition at line 303 of file i2cwrite.c.
References i2c_struct::addr, ArgsGet(), Argv0, i2c_struct::fd, I2C_ADDR_DEV_HIGH, I2C_ADDR_DEV_LOW, i2c_open(), I2CWriteOptsInfo, I2CWritePgmInfo, OptDevFd, OptDevName, OptI2CAddr, OptVerbose, and PkgInfo.
Referenced by main().
|
static |
Convert string to byte.
s | String. | |
[out] | pByte | Pointer to converted value. |
Definition at line 240 of file i2cwrite.c.
References StrToUnsigned().
Referenced by ArgsGet().
|
static |
Convert string to unsigned integer.
s | String. | |
[out] | pVal | Pointer to converted value. |
Definition at line 205 of file i2cwrite.c.
Referenced by StrToByte().
|
static |
Program Information.
Definition at line 85 of file i2cwrite.c.
Referenced by MainInit().