Hi Sir,
Sorry my PC cannot type Chinese.
This code always has error of System.AccessViolationException protected memroy access.
Could you please help the CH347GetDeviceInfor C# coding?
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi,Pack =0, Size = 545)]// pack 0 for 4 bytes pack. All parameter offset must be aligned to 4x
public struct _DEV_INFOR
{
[FieldOffset(0)]
public byte iIndex; // 当前打开序号
[FieldOffset(1)]
public byte DevicePath; // 设备链接名,用于CreateFile
[FieldOffset(261)]
public byte UsbClass; // 0:CH347_USB_CH341, 2:CH347_USB_HID,3:CH347_USB_VCP
[FieldOffset(262)]
public byte FuncType; // 0:CH347_FUNC_UART,1:CH347_FUNC_SPI_I2C,2:CH347_FUNC_JTAG_I2C
[FieldOffset(264)]
public byte[] DeviceID; // USB\VID_xxxx&PID_xxxx
[FieldOffset(328)]
public byte ChipMode; // 芯片模式,0:Mode0(UART0/1); 1:Mode1(Uart1+SPI+I2C); 2:Mode2(HID Uart1+SPI+I2C) 3:Mode3(Uart1+Jtag+IIC)
[FieldOffset(329)]
public IntPtr DevHandle; // 设备句柄
[FieldOffset(333)]
public UInt16 BulkOutEndpMaxSize; // 上传端点大小
[FieldOffset(335)]
public UInt16 BulkInEndpMaxSize; // 下传端点大小
[FieldOffset(337)]
public byte UsbSpeedType; // USB速度类型,0:FS,1:HS,2:SS
[FieldOffset(338)]
public byte CH347IfNum; // 设备接口号: 0:UART,1:SPI/IIC/JTAG/GPIO
[FieldOffset(339)]
public byte DataUpEndp; // 端点地址
[FieldOffset(340)]
public byte DataDnEndp; // 端点地址
[FieldOffset(344)]
public byte[] ProductString; // USB产品字符串
[FieldOffset(408)]
public byte[] ManufacturerString; // USB厂商字符串
[FieldOffset(472)]
public UInt32 WriteTimeout; // USB写超时
[FieldOffset(476)]
public UInt32 ReadTimeout; // USB读超时
[FieldOffset(480)]
public byte[] FuncDescStr; // 接口功能描述符
[FieldOffset(544)]
public byte FirmwareVer; // 固件版本
}