Android Question USB GPS Dongle

Alhootti

Active Member
Actually i tried more than 3 contentious hours without positive result.
i will attach the file for modification.
 

Attachments

  • USB GPS.rar
    390.9 KB · Views: 54
Upvote 0

Alhootti

Active Member
i have been used felUsbSerial and UsbSerial lab but they not working just giving me details without any proper connection.
Send and Stop buttons are still disabled.

B4X:
Sub Process_Globals
    Dim usb As UsbSerial
    Dim astreams As AsyncStreams
End Sub

Sub Globals

    Dim btnSend, btnOpen, btnClose As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    btnClose.Enabled = False
    btnSend.Enabled = False
End Sub

Sub btnOpen_Click
    If usb.UsbPresent(1) = usb.USB_NONE Then
        MsgboxAsync("Msgbox - no device","No Device")
        Log("No USB device or accessory detected!")
        Log("Msgbox - returned")
        Return
    End If
    Log("Checking permission")
    If (usb.HasPermission(1)) Then
        MsgboxAsync(usb.DeviceInfo(1),"Permission")
        Dim dev As Int
        dev = usb.Open(115200, 1)       
        If dev <> usb.USB_NONE Then
            MsgboxAsync("Connected successfully!","Success")
            btnOpen.Enabled = False
            btnClose.Enabled = True
            btnSend.Enabled = True           
            astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams")
        Else
            MsgboxAsync("Error opening USB port","Bad")
        End If
    Else
        usb.RequestPermission(1)
    End If
End Sub

Sub Astreams_NewData (Buffer() As Byte)
    Log("NewData")
    Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

Sub btnClose_Click
    astreams.Close
    btnOpen.Enabled = True
    btnClose.Enabled = False
    btnSend.Enabled = False   
End Sub

Sub btnSend_Click
    astreams.Write("abcde".GetBytes("UTF8"))
End Sub

Sub btnExit_Click
    ExitApplication
End Sub

Sub AStreams_Error
    MsgboxAsync("Error: " & LastException,"Error Astreams")
    astreams.Close
End Sub
Sub Astreams_Terminated
    MsgboxAsync("Terminated","Error Terminated")
    astreams.Close
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • 2.jpeg
    2.jpeg
    390.8 KB · Views: 62
  • 1.jpeg
    1.jpeg
    64.2 KB · Views: 60
Upvote 0

agraham

Expert
Licensed User
Longtime User
Send and Stop buttons are still disabled.
In that case it looks like usb.Open is returning usb.USB_NONE (0) which means that UsbSerial has not recognised the device. This is probably because it does not recognise at least one of the Driver, Product or Vendor Ids. It looks from your photo that it might be a CDC ACM type device so try this before calling usb.Open.

SetCustomDevice(usb.DRIVER_CDCACM, 0x1A8, 0x3EA)

I'm not familiar with felUsbSerial but looking at the decompiled code it should throw an exception on Initialize if it doesn't recognise the serial device.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I think you are misunderstanding something. That tutorial is not relevant as it uses the internal GPS. Also that message refers to the internal GPS as well. As you have an external dongle you have to do all the work yourself.

As far as I can see your skeleton program above should work. With the external uBlox device you might have to configure it via serial output and then deal with the NMEA sentences it sends once configured. You need the uBlox manual for the device you have.
 
Upvote 0

Alhootti

Active Member
Anyway i need help by my self alone i cant do any thing
this is my GNSS Receiver Photo.
I hope some one give me a hand.
 

Attachments

  • GNSS Reciever.jpeg
    GNSS Reciever.jpeg
    122.9 KB · Views: 56
Upvote 0

jtim3032

Member
Licensed User
Longtime User
Anyway i need help by my self alone i cant do any thing
this is my GNSS Receiver Photo.
I hope some one give me a hand.
Are you using an OTG capable lead from your phone to the GPS dongle? If not, the dongle will not be getting any power. This may also be true when connecting to your TV Box as the box may not operate in "master" mode by default.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The external GPS sends those sentences to you and you have to decode them to get the location information you want. Furthermore, because they arrive from a serial port they will not arrive as complete packets so you will have to buffer incoming data, scan it for the sentence header and trailer and then unpack the information. This is not trivial.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I've just checked that GPS Connector app and realised that it can send the information to the Android location mocker so it may be easier than I have been saying and you can then use Erels' tutorial to read GPS information. However you need to turn on location mocking in developer options on your phone.


EDIT: I've just seen that you are using a "tvbox" whatever that is, so maybe it won't do location mocking - you will have to investigate that.
 
Upvote 0

Alhootti

Active Member
The external GPS sends those sentences to you and you have to decode them to get the location information you want. Furthermore, because they arrive from a serial port they will not arrive as complete packets so you will have to buffer incoming data, scan it for the sentence header and trailer and then unpack the information. This is not trivial.
I'm not familiar to use these codes . could you please write down the codes
 
Upvote 0

Alhootti

Active Member
i already turned on location mocking in developer options.
in mock location there is only GPS Connector app no our GPS app
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
in mock location there is only GPS Connector app no our GPS app
That is correct, choose that and then your app should be able to use the GPS or my GNSS libraries to access the location information. Note the important note in bold at the end of my post here.
 
Upvote 0
Top