我的x64应用程序不能枚举PIC18F4550,但是同一应用程序的x86版本可以。有什么问题吗?
尝试在x86版本中运行它,可以正常工作。
下面提供的Ccode:
Imports HIDLibrary
Imports System.Threading
Public Class USB_Interface
Dim HidDeviceList As HIDLibrary.HidDevice()
Dim HidPIC18 As HidDevice
Public PIC18Detected As Boolean
Public Enum S
Off_Display = 0
On_Display
End Enum
Public Function IsPIC18Detected() As Boolean
'Dim PIC18Detected As Boolean
Try
IsPIC18Detected = False
If Not PIC18Detected Then
' Enumerate the devices with the Vendor Id and Product Id of Microchip PICDEM FSUSB (CreateFile)
HidDeviceList = HidDevices.Enumerate(1121, 33)
If HidDeviceList.Length > 0 Then
' Grab the first device
HidPIC18 = HidDeviceList(0)
PIC18Detected = True
Init_Cntr0()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
Throw
End Try
IsPIC18Detected = PIC18Detected
End Function
Private Sub Init_Cntr0()
SendOutData(1, 10, 0, 0)
End Sub
Public Sub Display_On_Off(ByVal status As S)
If status = S.Off_Display Then
SendOutData(13, 0, 0, 0)
End If
If status = S.On_Display Then
SendOutData(13, 1, 0, 0)
End If
End Sub
Public Function SendOutData(ByVal x1 As Byte, ByVal x2 As Byte, ByVal x3 As Byte, ByVal x4 As Byte) As Byte() ', ByVal x5 As Byte, ByVal x6 As Byte
Try
Dim OutData(HidPIC18.Capabilities.OutputReportByteLength - 1) As Byte
OutData(1) = x1
OutData(2) = x2
OutData(3) = x3
OutData(4) = x4
HidPIC18.Write(OutData, 0)
Return getDataFromPIC()
Catch ex As Exception
MsgBox("USB Communication Failed : Check USB Cable" + vbCrLf + ex.Message)
End Try
End Function
Private Function getDataFromPIC() As Byte()
Dim recieved_Data(3) As Byte
Dim HidPic18Data As HidDeviceData
Try
HidPic18Data = HidPIC18.Read(500) 'Get input report
' HidPic18Data.Data(1) 'Element 2 contains the Acknowledgement
recieved_Data(0) = HidPic18Data.Data(1)
recieved_Data(1) = HidPic18Data.Data(2)
recieved_Data(2) = HidPic18Data.Data(3)
recieved_Data(3) = HidPic18Data.Data(4)
Catch ex As Exception
MsgBox("USB Communication Failed : Check USB Cable" + vbCrLf + ex.Message)
End Try
getDataFromPIC = recieved_Data
End Function
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
预期长度= 7
返回0