On 09/12/2015 17:40, Tim Sander wrote:
>> > If there is no slave at the requested address, i2c_start_transfer will
>> > return 1.
> Ok, that works. Now probably the last problem i see is that i fail to set the 
> data-address of the i2c-device?
> I know the correct offset address for accesses on the bus e.g. 
> i2cget -y 0 0x50 2
> where 2 is an example offset for the access to this device. 
> 
> So any hint how setting the data-address on the i2c bus in qemu works?

If you have a data address, you probably want to use functions like
smbus_read_byte that do the right write-read sequence for you:

    if (i2c_start_transfer(bus, addr, 0)) {
        return -1;
    }
    i2c_send(bus, command);
    i2c_start_transfer(bus, addr, 1);
    data = i2c_recv(bus);
    i2c_nack(bus);
    i2c_end_transfer(bus);

Paolo

Reply via email to