在windows下使用CH341A USB转接模块可以正确与设备交互,我之前使用CH341DLL库,调用相关api
dev->id = device_number; dev->fd = CH341OpenDevice(dev->id); if (dev->fd == INVALID_HANDLE_VALUE) { -----省略 auto ret = CH341SetTimeout(dev->dev_id, 2000, 2000); ----- auto ret = CH341SetStream(dev->id, ULONG(rate)); ---- 然后可以正常进行各种读写操作如 BOOL result = CH341ReadI2C(iIndex, iDevice, iAddr, &oByte);
近期我想将其迁移linux系统,使用CH341PAR驱动,生成ch34x_pis字符设备,通过加载libch347.so进行操作
dev->fd = CH34xOpenDevice(pathname); ret = CH34xSetTimeout(dev->fd, 2000, 2000); ------省略 auto ret = CH34xSetStream(dev->fd, mode); if (ret == false) { std::cout << "I2CConfig error: Failed to set stream mode." << std::endl; return -1; }
我调用类似的api接口实现完全相同逻辑,可以正常调用开启设备和读取设备信息的api,但是在
CH34xSetStream
和其他读取I2C数据的api会返回false
经验有限,暂时排查不出问题
驱动已经加载,usart功能正常,kernel为6.10.x
热门产品 :
CH32L103: 32位PDUSB低功耗单片机