I have written a code and I want notify device arrival to usb bus. My code does'nt run correct.
This is my code:
Imports System.Runtime.InteropServices
Module Program
Private Declare Function inp Lib "ch341dll.dll" ()
Private Declare Function outp Lib "ch341dll.dll" ()
Function mPCH341_NOTIFY_ROUTINE(iEVENTStatus As Integer) As Integer
Return iEVENTStatus
End Function
Const ch341_DEVICE_ARRIVAL As Integer = 3
Const ch341_DEVICE_REMOVE_PEND As Integer = 1
Const ch341_DEVICE_REMOVE = 0
Function ch341setdevicenotify(iIndex As Integer, iDeviceID As String, mPCH341_NOTIFY_ROUTINE As Integer) As Boolean
Return ch341setdevicenotify
End Function
Function ch341opendevice(iIndex As Integer) As Integer
Return ch341opendevice
End Function
Function ch341writei2c(iIndex As ULong, iDevice As UInteger, iAddr As UInteger, iByte As UInteger) As Integer
Return ch341writei2c
End Function
Sub main()
Dim iEVENTStatus As Integer
Dim iIndex As ULong = 0
Dim iDevice As UInteger = 0
Dim iAddr As UInteger = 0
Dim iByte As UInteger = 290
Dim x As Integer
Dim iDeviceID As String = 'ch341a'
mPCH341_NOTIFY_ROUTINE(iEVENTStatus)
Console.WriteLine(iEVENTStatus)
If ch341setdevicenotify(iIndex, iDeviceID, x) = 3 Then
Console.WriteLine("PORT Connected")
ch341opendevice(iIndex)
ch341writei2c(iIndex, iDevice, iAddr, iByte)
End If
End Sub
End Module
Please help me