Skip to content

Commit

Permalink
Bug in original code that add 1 byte to the out buffer.
Browse files Browse the repository at this point in the history
This meant that the first byte was always zero.
Fixed and now works fine.
  • Loading branch information
unknown authored and unknown committed Apr 9, 2012
1 parent c4917e4 commit 94ca87f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jni/axonI2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ JNIEXPORT jint JNICALL Java_axon_test_testJNI_axonI2C_write(JNIEnv *env, jobject
(*env)->GetIntArrayRegion(env, bufArr, 0, len, bufInt);
bufByte[0] = mode;
for (i = 0; i < len; i++)
bufByte[i + 1] = bufInt[i];
bufByte[i] = bufInt[i];

res = ioctl(fileHander, I2C_SLAVE, slaveAddr);
if (res != 0) {
LOGE("I2C: Can't set slave address");
goto err2;
}

if ((j = write(fileHander, bufByte, len + 1)) != len + 1) {
if ((j = write(fileHander, bufByte, len)) != len) {
LOGE("write fail in i2c");
goto err2;
}
Expand Down

0 comments on commit 94ca87f

Please sign in to comment.