summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commandline/i2cset.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/commandline/i2cset.c b/commandline/i2cset.c
index c6333c5..5a3bc4b 100644
--- a/commandline/i2cset.c
+++ b/commandline/i2cset.c
@@ -6,7 +6,7 @@
int main(int argc, char **argv)
{
- int i, address, got_ack;
+ int i, address, cmdbuf, got_ack;
char *conv_err;
i2c_init();
@@ -27,7 +27,12 @@ int main(int argc, char **argv)
got_ack = i2c_tx_byte(address << 1);
for (i = 2; i < argc; i++) {
- i2c_tx_byte(atoi(argv[i]));
+ cmdbuf = strtol(argv[i], &conv_err, 0);
+ if (conv_err && *conv_err) {
+ fprintf(stderr, "write command: conversion error at '%s'", conv_err);
+ return 2;
+ }
+ i2c_tx_byte(cmdbuf);
}
i2c_stop();