求救大神,你們?cè)趺醋龅???/p>

我在VB.NET下編寫(xiě)讀取I2C設(shè)備的程序,發(fā)現(xiàn)CH341StreamI2C函數(shù)不能用,

CH341StreamI2C函數(shù)內(nèi)的緩存的類(lèi)型,設(shè)置結(jié)構(gòu)體/數(shù)組/Object都不行,讀不到函數(shù)/報(bào)錯(cuò)

?

VB下代碼如下

????Type arrRBuffer
??? buf(mMAX_BUFFER_LENGTH - 1) As Byte
????End Type

????Dim iBuff As arrRBuffer
????Dim buffer As arrRBuffer

????If (CH341StreamI2C(mIndex, mWrLen, buffer, mRdLen, iBuff) = False) Then
???? MsgBox "流模式讀寫(xiě)數(shù)據(jù)失??!", vbExclamation, "CH341"

函數(shù)

????Declare Function CH341StreamI2C Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iWriteLength As Long, ByRef iWriteBuffer As Any, ByVal iReadLength As Long, ByRef oReadBuffer As Any) As Boolean
' CH341StreamI2C???? 處理I2C數(shù)據(jù)流,2線接口,時(shí)鐘線為SCL引腳,數(shù)據(jù)線為SDA引腳(準(zhǔn)雙向I/O),速度約56K字節(jié)
' iIndex,??? 指定CH341設(shè)備序號(hào)
' iWriteLength,??? 準(zhǔn)備寫(xiě)出的數(shù)據(jù)字節(jié)數(shù)
' iWriteBuffer,??? 指向一個(gè)緩沖區(qū),放置準(zhǔn)備寫(xiě)出的數(shù)據(jù),首字節(jié)通常是I2C設(shè)備地址及讀寫(xiě)方向位
' iReadLength,???? 準(zhǔn)備讀取的數(shù)據(jù)字節(jié)數(shù)
' oReadBuffer???? 指向一個(gè)緩沖區(qū),返回后是讀入的數(shù)據(jù)

?

仿照VB寫(xiě)VB.NET如下

??????? Public Structure arrRBuffer
??????? Public buf() As Byte
??? ????End Structure

????????Dim iBuff As arrRBuffer
??? ????Dim buffer As arrRBuffer

????????CH341StreamI2C(0, 1, buffer, 2, iBuff)

函數(shù)

??????????? _
??? Public Function CH341StreamI2C(ByVal iIndex As Integer, ByVal iWriteLength As Integer, ByRef iWriteBuffer As arrRBuffer, ByVal iReadLength As Integer, ByRef oReadBuffer As arrRBuffer) As Boolean
??????? ' CH341StreamI2C???? 處理I2C數(shù)據(jù)流,2線接口,時(shí)鐘線為SCL引腳,數(shù)據(jù)線為SDA引腳(準(zhǔn)雙向I/O),速度約56K字節(jié)
??????? ' iIndex,??? 指定CH341設(shè)備序號(hào)
??????? ' iWriteLength,??? 準(zhǔn)備寫(xiě)出的數(shù)據(jù)字節(jié)數(shù)
??????? ' iWriteBuffer,??? 指向一個(gè)緩沖區(qū),放置準(zhǔn)備寫(xiě)出的數(shù)據(jù),首字節(jié)通常是I2C設(shè)備地址及讀寫(xiě)方向位
??????? ' iReadLength,???? 準(zhǔn)備讀取的數(shù)據(jù)字節(jié)數(shù)
??????? ' oReadBuffer???? 指向一個(gè)緩沖區(qū),返回后是讀入的數(shù)據(jù)
??? End Function