Declare Function CH341WriteRead Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iWriteLength As Long, ByRef iWriteBuffer As Any, ByVal iReadStep As Long, ByVal iReadTimes As Long, ByRef oReadLength As Long, ByRef oReadBuffer As Any) As Boolean ' CH341WriteRead 執(zhí)行數(shù)據(jù)流命令,先輸出再輸入 ' iIndex, 指定CH341設(shè)備序號 ' iWriteLength, 寫長度,準(zhǔn)備寫出的長度 ' iWriteBuffer, 指向一個(gè)緩沖區(qū),放置準(zhǔn)備寫出的數(shù)據(jù) ' iReadStep, 準(zhǔn)備讀取的單個(gè)塊的長度, 準(zhǔn)備讀取的總長度為(iReadStep*iReadTimes) ' iReadTimes, 準(zhǔn)備讀取的次數(shù) ' oReadLength, 指向長度單元,返回后為實(shí)際讀取的長度 ' oReadBuffer 指向一個(gè)足夠大的緩沖區(qū),用于保存讀取的數(shù)據(jù)
這個(gè)函數(shù)怎么在VB中實(shí)現(xiàn)?
Type mBuf mBuff(mCH341_PACKET_LENGTH) As Byte End Type'在.bas文件中定義
Private Sub Command2_Click()’按鈕事件
Dim mBuffer As mBuf Dim mLength, mInLen As Long mBuffer.mBuff(0) = mCH341A_CMD_I2C_STREAM mBuffer.mBuff(1) = mCH341A_CMD_I2C_STM_OUT mBuffer.mBuff(2) = 20 mBuffer.mBuff(3) = mCH341A_CMD_I2C_STM_END mLength = 4 mInLen = 0
If (mOpen = True) Then If (CH341WriteRead(0, mLength, mBuffer, 32, 1, mInLen, mBuffer)) Then MsgBox "寫數(shù)據(jù)成功!", vbExclamation, "CH341" Else: MsgBox "寫數(shù)據(jù)失?。?, vbExclamation, "CH341" End If Else MsgBox "設(shè)備未打開!", vbExclamation, "CH341PAR" End If
End Sub
實(shí)現(xiàn)這個(gè)函數(shù)時(shí),程序直接卡死掉?。?!求解?。?!