Android Question USB Serial data from Silicon Labs Sportident device


Licensed User
Hi I am new to b4a and this forum so please accept my apologies if I don't ask the question correctly or I am doing something very stupid.

I am trying to read and write serial data to a Sportident USB device which uses a Silicon labs driver in Windows. Having read the documentation and many threads I discovered the USB Serial library 2.4 and the example code which I believe should work with Silabs devices and the Sportident box appears in the list of devices using the silabs chip. I have also looked at Documents/TechnicalDocs/AN571.pdf but I don't know whether it is relevant.

I changed the baud rate in the example code to 38400 and I subsequently added some Toast messages. I added an xml filter file to the app's /res/xml folder and set that to read only as recommended and changed the manifest. When I run the app and connect the device it asks which app I want to use. I select the app and the screen shows the Open button. When I click that I get a Could not open port Toast message. The device VID and PIDs are shown correctly. Another app can read the box without problems so the hardware works. Any suggestions?

Modified example code for the Open button. The rest of the code is unchanged.
Sub btnOpen_Click
    If usb1.UsbPresent(1) = usb1.USB_NONE Then    ' Ver_2.4
        Log("Msgbox - no device")
        Msgbox("No USB device or accessory detected!", "Error")
        Log("Msgbox - returned")
    End If
    Log("Checking permission 1")
    If (usb1.HasPermission(1)) Then    ' Ver_2.4
    ToastMessageShow("Has permission",False)
        Msgbox(usb1.DeviceInfo(1), "Device Information 1")    ' Ver_2.4
        Dim dev As Int
        'dev = usb.Open(115200, 1)        ' Ver_2.4
        dev = usb1.Open(38400, 1)        ' Ver_2.4
        If dev <> usb1.USB_NONE Then
            Log("Connected successfully! 1")
            btnOpen.Enabled = False
            btnClose.Enabled = True
            btnSend.Enabled = True           
            astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
            ToastMessageShow("Could not open port",False)
            Log("Error opening USB port 1")
        End If
        usb1.RequestPermission(1)  ' Ver_2.4
    End If
End Sub

The xml filter file set as read only.
<?xml version="1.0" encoding="utf-8"?>
    <!-- 0x10c4 / 0x800a Sportident -->
    <usb-device vendor-id="4292" product-id="32778"/>


Licensed User
Thanks Erel for responding so quickly.
The UsbSerial library doesn't support all chips.
Prolific PL2303 is also supported.
This document
suggests that it is using the CP2102 or 2101.
  1. { USB_DEVICE(0x10B5,0xAC70)},/* Nokia CA-42 USB */
  2. { USB_DEVICE(0x10C4,0x800A)},/* SPORTident BSM7-D-USB main station */
  3. { USB_DEVICE(0x10C4,0x803B)},/* Pololu USB-serial converter */
Am I wrong in thinking that if it uses either of these chips it should be supported? At the moment I am only trying to open the port, not read the data.
Upvote 0


Licensed User
SOLVED After a lot a head scratching, much trial and error and more reading at the forum, I found
SetCustomDevice allows you to specify which driver a device unknown to the library might support and its VendorID and ProductID so allowing the device to be recognised by the library. Note that this does not guarantee that the device will work correctly as it must exactly implement what the specified driver expects

Putting this line before the Open allowed the port to open.

I also saw a reference somewhere that it should be possible to avoid this step by reading the VID and PID which are returned in usb.DeviceInfo(1) but presumably this has not yet been implemented in the library.
Upvote 0