question

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

OpenDevice function

Hi ,here is my code:
Private Declare Function CH341OpenDevice Lib "CH341DLL.DLL" (ByVal iIndex As Int64) As Integer
Private Declare Function CH341WriteI2C Lib "CH341DLL.DLL" (ByVal iIndex As Int64, ByVal idevice As Integer, ByVal iaddr As Integer, ByVal ibyte As Integer) As UInteger
Private Declare Function CH341ReadI2C Lib "CH341DLL.DLL" (ByVal iIndex As Int64, ByVal idevice As Integer, ByVal iaddr As Integer, ByVal obyte As Integer) As Integer
Private Declare Function CH341CloseDevice Lib "CH341DLL.DLL" (ByVal iIndex As Int64) As Integer
Private Declare Function CH341ResetDevice Lib "CH341DLL.DLL" (ByVal iIndex As Int64) As Integer
Private Declare Function CH341SetStream Lib "CH341DLL.DLL" (iIndex As Int64, iMode As Long) As Integer
Sub main()
MsgBox("ok")
End Sub

 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     Dim iIndex As Long = 0
     Dim iDevice As ULong = &H48
     Dim iAddr As ULong = &H48
     Dim iByte As UInteger = &H91
     Dim closing As Integer
     Dim reading As Integer
     Dim opning As Integer = CH341OpenDevice(iIndex)
     Dim rseting As Integer = CH341ResetDevice(iIndex)
     Dim wrting As UInteger = CH341WriteI2C(iIndex, iDevice, iAddr, iByte)
     'reading = CH341ReadI2C(iIndex, 48, 91, 91)
     closing = CH341CloseDevice(0)
     MsgBox(opning)
     MsgBox(wrting)
     MsgBox(closing)
     MsgBox(iAddr)
 End Sub

End Class
When I run the code the opning value is negative in this condition there is an error. The value of wrting must be also 91H which is in the code mentioned but '0' is displaid. Please help.

dotnet-visual-basic
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.

0 Answers