I had managed to connect to the usb but there is no response when sending some data to the device. Any advice?
B4X:
Dim usb1 As UsbSerial
Dim usbDev As UsbDevice
Dim manager As UsbManager
Dim devices() As UsbDevice
Dim astreams1 As AsyncStreams
manager.Initialize
devices = manager.GetDevices
usb1.Open(9600)
usbDev = devices(0)
If usb1.UsbPresent = usb1.USB_NONE Then ' Ver_2.4
'Label1.Text = "No device USB NONE"
Return
End If
If (usb1.HasPermission) Then ' Ver_2.4
Log(usb1.DeviceInfo)
'This is very important - ( VendorId, ProductId )
usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x416, 0x5011)
Dim dev As Int
dev = usb1.Open(9600) 'STMicroeletronics
If dev <> usb1.USB_NONE Then
Log("Connected successfully! 1")
'Label1.Text = ""
Log("CONNECTED SUCCESSFULLY!!!")
astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
'This is important
usb1.SetParameters(9600, usb1.DATABITS_8,usb1.STOPBITS_1, usb1.PARITY_NONE)
'Here if you want codce that call print
Dim cmd(3) As Byte
cmd(0) = 0x1b
cmd(1) = 0x21
cmd(2) = 0x10
Try
astreams1.Write(cmd) '"Testing".GetBytes("UTF8"))
astreams1.Write("Testing".GetBytes("UTF8"))
Catch
End Try
Else
Log("Error opening USB port 1")
End If
Else
usb1.RequestPermission ' Ver_2.4
End If