frank-zago / ch341-i2c-spi-gpio

WinChipHead CH341 linux driver for I2C, SPI and GPIO mode
GNU General Public License v2.0
69 stars 30 forks source link

open i2c device using ioctl is not supported #40

Open axet opened 4 months ago

axet commented 4 months ago

Hello!

I'm trying to setup mlx90640 i2c device using CH341T-V3 usb stick. When device opened via ioctl command I get following:

I2C device tree: '/dev/i2c-7'
Starting...
Configured...0
refresh = 0
Ioctl read i2c error:: Operation not supported

Checking the source code it seems like ioctl call failed:

        ioctl_msg[0].len    =   len;
        ioctl_msg[0].addr   =   device->addr;
        ioctl_msg[0].buf    =   buf;
        ioctl_msg[0].flags  =   flags | I2C_M_RD;

        /* Package to i2c message to operation i2c device */
        ioctl_data.nmsgs    =   1;
        ioctl_data.msgs     =   ioctl_msg;

        ioctl(device->bus, I2C_RDWR, (unsigned long)&ioctl_data) == -1

I'm not sure if drive fully support linux i2c bus commands or not.

Full source:

frank-zago commented 4 months ago

i2c bus drivers do not support ioctl directly; this is done through the i2c core. There could be a parameter that the driver doesn't like though, or a missing option. ???