free性丰满hd毛多多,久久综合给合久久狠狠狠97色69 ,欧美成人乱码一区二区三区,国产美女久久久亚洲综合,7777久久亚洲中文字幕

0
問答首頁 最新問題 熱門問題 等待回答標(biāo)簽廣場(chǎng)
我要提問

求指教有關(guān)周立功的usbcan模塊的事情,拜謝了……

周立功usbcan模塊里面有個(gè)vb例程,默認(rèn)的是01 02 03 04 05 06 07 08數(shù)據(jù)的發(fā)送,現(xiàn)在怎樣改程序可以實(shí)現(xiàn)數(shù)據(jù)的實(shí)時(shí)收發(fā)啊,求各路大神不吝賜教??!現(xiàn)在貼出原程序
Dim m_devtype As Long
Dim m_connect As Byte
Dim m_devind As Long
Dim m_cannum As Long



Private Sub Command1_Click()
? ? If m_connect = 0 Then
? ?? ???MsgBox ("請(qǐng)先打開端口")
? ?? ???Exit Sub
? ? End If
? ?
? ? Dim SendType, frameformat, frametype As Byte
? ? Dim ID As Long
? ? Dim data(7) As Byte
? ? Dim frameinfo As VCI_CAN_OBJ
? ? Dim str As String
? ?
? ? SendType = Combo3.ListIndex
? ? frameformat = Combo5.ListIndex
? ? frametype = Combo4.ListIndex
? ? str = "&H"
? ? str = str + Text1.Text
? ? ID = Val(str)
? ? str = Text4.Text
? ? strdata = " "
? ? i = 0
? ? For i = 0 To 7
? ?? ? strdata = Left(str, 2)
? ?? ? If Len(strdata) = 0 Then
? ?? ?? ? Exit For
? ?? ? End If
? ?? ? str = Right(str, Len(str) - 3)
? ?? ? data(i) = Val("&H" + strdata)
? ? Next
? ?
? ? frameinfo.DataLen = i
? ? frameinfo.ExternFlag = frametype
? ? frameinfo.RemoteFlag = frameformat
? ? frameinfo.SendType = SendType
? ? frameinfo.ID = ID
? ? For j = 0 To i - 1
? ?? ???frameinfo.data(j) = data(j)
? ? Next
? ? If VCI_Transmit(m_devtype, m_devind, m_cannum, frameinfo, 1) <> 1 Then
? ?? ???MsgBox ("發(fā)送數(shù)據(jù)失敗")
? ? Else
? ?? ???List1.AddItem "發(fā)送數(shù)據(jù)成功", List1.ListCount
? ? End If

End Sub

Private Sub Command2_Click()
? ? If m_connect = 0 Then
? ?? ???MsgBox ("請(qǐng)先打開端口")
? ?? ???Exit Sub
? ? End If
? ? If VCI_StartCAN(m_devtype, m_devind, m_cannum) <> 1 Then
? ?? ???MsgBox ("啟動(dòng)CAN錯(cuò)誤")
? ? Else
? ?? ???List1.AddItem "啟動(dòng)CAN成功", List1.ListCount
? ? End If
End Sub

Private Sub Command3_Click()
? ? If m_connect = 0 Then
? ?? ???MsgBox ("請(qǐng)先打開端口")
? ?? ???Exit Sub
? ? End If
? ? If VCI_ResetCAN(m_devtype, m_devind, m_cannum) <> 1 Then
? ?? ???MsgBox ("復(fù)位CAN錯(cuò)誤")
? ?Else
? ?? ???List1.AddItem "復(fù)位CAN成功", List1.ListCount
? ? End If

End Sub

Private Sub Command4_Click()
? ? If m_connect = 0 Then
? ?? ???MsgBox ("請(qǐng)先打開端口")
? ?? ???Exit Sub
? ? End If
? ?
? ? Dim i As Long
? ? i = Combo1.ListIndex
? ? If i <> -1 Then
? ?? ???If VCI_SetReference(m_devtype, m_devind, 0, 1, i) <> 1 Then
? ?? ?? ?? ?MsgBox ("更改CAN波特率錯(cuò)誤")
? ?? ???Else
? ?? ?? ?? ?List1.AddItem "更改CAN波特率成功", List1.ListCount
? ?? ???End If
? ? End If

End Sub

Private Sub Command5_Click(index As Integer)
? ? If m_connect = 0 Then
? ?? ???MsgBox ("請(qǐng)先打開端口")
? ?? ???Exit Sub
? ? End If
? ?
? ? Dim i As Long
? ? i = Combo2.ListIndex
? ? If i <> -1 Then
? ?? ???i = i + 1
? ?? ???If VCI_SetReference(m_devtype, m_devind, 0, 3, i) <> 1 Then
? ?? ?? ?? ?MsgBox ("更改232波特率錯(cuò)誤")
? ?? ???Else
? ?? ?? ?? ?List1.AddItem "更改232波特率成功", List1.ListCount
? ?? ???End If
? ? End If

End Sub

Private Sub Connect_Click()
? ? Dim index As Long
? ? Dim cannum As Long
? ? Dim code, mask As Long
? ? Dim Timing0, Timing1, filtertype, Mode As Byte
? ? Dim InitConfig As VCI_INIT_CONFIG
? ?
? ? If m_connect = 1 Then
? ?? ???m_connect = 0
? ?? ???Connect.Caption = "連接"
? ?? ???VCI_CloseDevice m_devtype, m_devind
? ?? ???Exit Sub
? ? End If
? ?? ???
? ? If Combo1.ListIndex <> -1 And Combo2.ListIndex <> -1 Then
? ?? ???index = Combo1.ListIndex
? ?? ???cannum = Combo2.ListIndex
? ?? ???filtertype = Combo6.ListIndex
? ?? ???Mode = Combo7.ListIndex
? ?? ???code = Val("&H" + Text2.Text)
? ?? ???mask = Val("&H" + Text3.Text)
? ?? ???Timing0 = Val("&H" + Text5.Text)
? ?? ???Timing1 = Val("&H" + Text6.Text)
? ?? ???InitConfig.AccCode = code
? ?? ???InitConfig.AccMask = mask
? ?? ???InitConfig.Filter = filtertype
? ?? ???InitConfig.Mode = Mode
? ?? ???InitConfig.Timing0 = Timing0
? ?? ???InitConfig.Timing1 = Timing1
? ?? ???
? ?? ???If VCI_OpenDevice(m_devtype, index, 0) <> 1 Then
? ?? ?? ?? ?MsgBox ("打開設(shè)備錯(cuò)誤")
? ?? ???Else
? ?? ?? ?? ?If VCI_InitCAN(m_devtype, index, cannum, InitConfig) = 1 Then
? ?? ?? ?? ?? ? m_connect = 1
? ?? ?? ?? ?? ? m_devind = index
? ?? ?? ?? ?? ? m_cannum = cannum
? ?? ?? ?? ?? ? Connect.Caption = "斷開"
? ?? ?? ?? ?Else
? ?? ?? ?? ?? ? MsgBox ("初始化CAN錯(cuò)誤")
? ?? ?? ?? ?End If
? ?? ???End If
? ? End If
? ?
End Sub

Private Sub Form_Load()
? ? Timer1.Enabled = True
? ? m_devtype = 4 'USBCAN2類型號(hào)
? ? m_connect = 0
? ? m_cannum = 0
? ? Combo1.ListIndex = 0
? ? Combo2.ListIndex = 0
? ? Combo3.ListIndex = 2
? ? Combo4.ListIndex = 0
? ? Combo5.ListIndex = 0
? ? Combo6.ListIndex = 0
? ? Combo7.ListIndex = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
? ? If m_connect = 1 Then
? ?? ???m_connect = 0
? ?? ???VCI_CloseDevice m_devtype, m_devind
? ? End If
End Sub





Private Sub Timer1_Timer()
? ? 'Timer1.Enabled = False
? ? Dim ErrInfo As VCI_ERR_INFO
? ?
? ? 'If m_connect = 0 Then
? ?? ? ' Timer1.Enabled = True
? ?? ???'Exit sub
? ?' End If

? ? Dim length As Long
? ? Dim frameinfo(49) As VCI_CAN_OBJ
? ? Dim str As String
? ?
? ? length = VCI_Receive(m_devtype, m_devind, m_cannum, frameinfo(0), 50, 10)
? ? If length <= 0 Then
? ?? ???VCI_ReadErrInfo m_devtype, m_devind, m_cannum, ErrInfo '注意:如果沒有讀到數(shù)據(jù)則必須調(diào)用此函數(shù)來讀取出當(dāng)前的錯(cuò)誤碼,
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?'千萬不能省略這一步(即使你可能不想知道錯(cuò)誤碼是什么)
? ?? ???Timer1.Enabled = True
? ?? ???Exit Sub
? ? End If
? ?
? ? For i = 0 To length - 1
? ?? ???str = "接收到數(shù)據(jù)幀:??"
? ?? ???If frameinfo(i).TimeFlag = 0 Then
? ?? ?? ?? ?tmpstr = "時(shí)間標(biāo)識(shí):無??"
? ?? ???Else
? ?? ?? ?? ?tmpstr = "時(shí)間標(biāo)識(shí):0x" + Hex(frameinfo(i).TimeStamp)
? ?? ???End If
? ?? ???str = str + tmpstr
? ?? ???tmpstr = "??幀ID:0x" + Hex(frameinfo(i).ID)
? ?? ???str = str + tmpstr
? ?? ???str = str + "??幀格式:"
? ?? ???If frameinfo(i).RemoteFlag = 0 Then
? ?? ?? ?? ?tmpstr = "數(shù)據(jù)幀 "
? ?? ???Else
? ?? ?? ?? ?tmpstr = "遠(yuǎn)程幀 "
? ?? ???End If
? ?? ???str = str + tmpstr
? ?? ???str = str + "??幀類型:"
? ?? ???If frameinfo(i).ExternFlag = 0 Then
? ?? ?? ?? ?tmpstr = "標(biāo)準(zhǔn)幀 "
? ?? ???Else
? ?? ?? ?? ?tmpstr = "擴(kuò)展幀 "
? ?? ???End If
? ?? ???str = str + tmpstr
? ?? ???List1.AddItem str, List1.ListCount
? ?? ???If frameinfo(i).RemoteFlag = 0 Then
? ?? ?? ?? ?str = "??數(shù)據(jù):"
? ?? ?? ?? ?If frameinfo(i).DataLen > 8 Then
? ?? ?? ?? ?? ? frameinfo(i).DataLen = 8
? ?? ?? ?? ?End If
? ?? ?? ?? ?For j = 0 To frameinfo(i).DataLen - 1
? ?? ?? ?? ?? ? tmpstr = Hex(frameinfo(i).data(j)) + " "
? ?? ?? ?? ?? ? str = str + tmpstr
? ?? ?? ?? ?Next
? ?? ?? ?? ?List1.AddItem str, List1.ListCount
? ?? ???End If
? ? Next
? ? Timer1.Enabled = True
End Sub

調(diào)用模塊如下
'定義需要用到的數(shù)據(jù)結(jié)構(gòu)
Public Type VCI_BOARD_INFO
? ? hw_Version As Integer
? ? fw_Version As Integer
? ? dr_Version As Integer
? ? in_Version As Integer
? ? irq_num As Integer
? ? can_num As Byte
? ? str_Serial_Num(19) As Byte
? ? str_hw_Type(39) As Byte
? ? Reserved(3) As Integer
End Type

Public Type VCI_CAN_OBJ
? ? ID As Long
? ? TimeStamp As Long
? ? TimeFlag As Byte
? ? SendType As Byte
? ? RemoteFlag As Byte
? ? ExternFlag As Byte
? ? DataLen As Byte
? ? data(7) As Byte
? ? Reserved(2) As Byte
End Type

Public Type VCI_CAN_STATUS
? ? ErrInterrupt As Byte
? ? regMode As Byte
? ? regStatus As Byte
? ? regALCapture As Byte
? ? regECCapture As Byte
? ? regEWLimit As Byte
? ? regRECounter As Byte
? ? regTECounter As Byte
? ? Reserved As Long
End Type

Public Type VCI_ERR_INFO
? ? ErrCode As Long
? ? Passive_ErrData(2) As Byte
? ? ArLost_ErrData As Byte
End Type

Public Type VCI_INIT_CONFIG
? ? AccCode As Long
? ? AccMask As Long
? ? Reserved As Long
? ? Filter As Byte
? ? Timing0 As Byte
? ? Timing1 As Byte
? ? Mode As Byte
End Type


Declare Function VCI_OpenDevice Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal Reserved As Long) As Long

Declare Function VCI_CloseDevice Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long) As Long

Declare Function VCI_InitCAN Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByRef InitConfig As VCI_INIT_CONFIG) As Long

Declare Function VCI_ReadBoardInfo Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByRef info As VCI_BOARD_INFO) As Long

Declare Function VCI_ReadErrInfo Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByRef ErrInfo As VCI_ERR_INFO) As Long

Declare Function VCI_ReadCANStatus Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByRef CANStatus As VCI_CAN_STATUS) As Long

Declare Function VCI_GetReference Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByVal RefType As Long, ByRef data As Any) As Long

Declare Function VCI_SetReference Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByVal RefType As Long, ByRef data As Any) As Long

Declare Function VCI_GetReceiveNum Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long) As Long

Declare Function VCI_ClearBuffer Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long) As Long

Declare Function VCI_StartCAN Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long) As Long

Declare Function VCI_ResetCAN Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long) As Long

Declare Function VCI_Transmit Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByRef Send As VCI_CAN_OBJ, ByVal length As Long) As Long

Declare Function VCI_Receive Lib "ControlCAN.dll" (ByVal DeviceType As Long, ByVal DeviceInd As Long, ByVal CANInd As Long, ByRef Receive As VCI_CAN_OBJ, ByVal length As Long, ByVal WaitTime As Long) As Long


提問者:uweujvwerw 地點(diǎn):- 瀏覽次數(shù):188 提問時(shí)間:07-14 07:07
我有更好的答案
提 交
撰寫答案
提 交
1 / 3
1 / 3