Android Question USBSerial 2.40 + USB OTG cable + TTL-232R-5v cable

scarr

Member
Licensed User
Hi all,

OK I have looked and looked hard, I have even tried to sort it myself but this whole USB serial and compatibility is a big subject! so I though maybe just asking is it is possible will save me a lot of time.

Post title says what I have, a cheap china USB OTG cable and a TTL-232R-5v cable, I "error connecting"

My question is "can anyone say if this set-up should or should not work?"

Thanks in advance.
 

scarr

Member
Licensed User
Hi Erel,

it recognises the USB OTG cable and when I plug in the FTDI cable it asks if I want to use my app with this USB device, so I think it is seeing the cable also.

Ideally I don't want to root my phone as I want this app to work on un-rooted phones eventually.

Steve

P.S. This cable uses the FT232R (in datasheet for cable) so again reading up this should work, but it does not :-(

P.P.S. Also I do get the device info in my test app, USB_CLASS_COM, Prod ID 0x20, VendID 0x1519.
 
Last edited:

scarr

Member
Licensed User
B4X:
       If (usb1.HasPermission(1)) Then    ' Ver_2.4
          Msgbox(usb1.DeviceInfo(1), "Device Information 1")    ' Ver_2.4
          Dim dev As Int
          dev = usb1.Open(9600, 1)        ' Ver_2.4
          If dev <> usb1.USB_NONE Then
              Msgbox("Connected","OK")
              btnOpen.Enabled = False
              btnClose.Enabled = True
              btnSend.Enabled = True           
              astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
          Else
              Msgbox("Error connecting","OK")
          End If
I get the msgbox "Error connecting" after the device info box

Steve

P.S.

Thanks for helping over the Christmas period.
 

scarr

Member
Licensed User
Hi Erel,

I have not given up on this, I have got it working but not reliably, about 50% of time I get "error connecting" I have noticed that even if I unplug the cable it still returns usb1.deviceinfo as if the cable is still plugged in!!!

I have exited my app and gone back in, still "deviceinfo", I have added ExitApplication to a exit menu and then used that to close my app, still when I re-launch my app it shows "deviceinfo" without a cable connected.

B4X:
Sub Exit_Click
    usb1.Close
    astreams1.Close
    Activity.Finish
    ExitApplication
End Sub
Any ideas?

Thanks

Steve
 

scarr

Member
Licensed User
Erel,

Yes, it does and its driving me MAD :) OK, maybe another question is "how do you kill USB connections in Android", is there a way of iterating around USB connection killing them? Has anyone else had issues whereby the phone thinks it has a USB connection even if nothing is connected?

Regards

Steve

P.S. I stopped all apps using a app killer, I turned off all comm's devices like Bluetooth and even USB debugging, cleared my apps cache and data, rebooted the phone several times but each time I reload the app it thinks it has a USB device.

P.P.S. As I write this post it makes me think I am not doing something I should do, like iterating through the USB devices looking for the one I want, I didn't see this in the USB example but it makes sense, Erel with your vase knowledge is this what I should be doing?
 

scarr

Member
Licensed User
OK will do (later), but I know what my next question will be, what do I do with them as I iterate through, kill them or check for the one I want? if the answer is check the one I want then the next question is once I find the one I want how do I use the USB Library info in USBSerial is it as simple as using the same device number in the two libraries?

P.S. "Vast knowledge not vase!!!" and thanks for all your help, I don't know how you manage to keep up with everyone asking questions! maybe Erel are the initials of "Eric Rick Emma and Larry" ;-)
 

scarr

Member
Licensed User
Erel,

Sorry to be a pain but I am not that good we USB on android, I think I have written something that will iterate through the devices but what info will help us, the devicename is not much use.

B4X:
Sub Test_Click
   Dim usbdevices() As UsbDevice
   usbdevices = manager.GetDevices
   'Iterate over devices and find the correct one
   For i = 0 To usbdevices.Length - 1
      Dim ud As UsbDevice
      ud = usbdevices(i)
      'Iterate over interfaces
      For a = 0 To ud.InterfaceCount - 1
        Dim inter As UsbInterface
        inter = ud.GetInterface(a)
        device = ud
        interface = inter
        Msgbox(ud.devicename,"test")
      Next
   Next
End Sub
Thanks

Steve
 

scarr

Member
Licensed User
Hi Erel, Yes it does but this is what made me think it was picking something else up, another USB device or something.


Steve
 

scarr

Member
Licensed User
Well I have tried this on two phones and I get identical problem, it is like once you run the app and it see's the cable it remembers it forever! after reboot, uninstall app, disconnect cable!

I will try to get more info but if anyone has ANY ideas please HELP!!!!! :)

Steve
 
Top