i2c_smbus_write_block_data does not send all bytes?!
Hello folks,
i despair of i2c_smbus_write_block_data. I try to send this few bytes:
5D W 11 02 33 44
but my attached example code sends always:
5D W 11 03 33
I'm perfectly happy if somebody can help me! :-)
King Regards,
Nick
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
int main()
{
int fd;
int adapter_nr = 3; /* probably dynamically determined */
unsigned long addr = 0x5d; /* The I2C address */
char filename[20] = {0};
unsigned int size;
char buf[5] = {0};
int res;
int reg;
unsigned char values[3];
sprintf(filename,"/dev/i2c-%d",adapter_nr);
printf("device file: %s\n",filename);
printf("i2c device Address: 0x%x\n",addr);
fd = open(filename,O_RDWR);
res = ioctl(fd,I2C_SLAVE,addr);
reg = 0x11;
values[0] = 0x33;
values[1] = 0x44;
if ( i2c_smbus_write_block_data(fd, reg, 2, values) < 0) {
perror("Error: ");
}
close(filename);
return 0;
}_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
A message that is not in the archive (sent off-list or not yet received): 247321.99325.qm-SFSZVIN0dfnGRxTy+Q50vsz6deESKz/[email protected]
Hallo Nick,
Quoted 11 lines · Nick Teen
Hello folks,
i despair of
i2c_smbus_write_block_data. I try to send this few bytes:5D W 11 02 33 44
but my attached example code sends always:
5D W 11 03 33
I'm perfectly happy if somebody can help me! :-)
You probably want to use i2c_smbus_write_i2c_block_data instead. With i2c_smbus_write_block_data, the first data byte isn't real data, instead in indicates how many bytes follow until the end of the block. It should result in "5D W 11 33 44" in your case though, not sure why you get "5D W 11 03 33" instead.
Signature · 6 lines
Jean Delvare _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c