question

kavehrahimi-5744 avatar image
0 Votes"
kavehrahimi-5744 asked kavehrahimi-5744 commented

device notification

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

dotnet-runtime
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi ,the event I want write a code for it is usb attach/dettach the input of usb status is iEVENTStatus how can I assign it value for deferent status of usb.
Please help me
Thanks

0 Votes 0 ·

0 Answers