
Introduction
Under windows, there are applications that need
NMEA messages from a GPS device transmitted over a COM port. Under Android, it is possible to generate similar messages using the API. In general, the idea was to deliver data to a virtual COM port from Android. If you are wondering how you managed to do this, I ask for cat
What should have been done?
Implement required the following:
- Configure TCP / IP connection between device and PC
- Get NMEA data on Android
- Transfer them via UDP protocol to computer
- Receive a UDP packet on the computer and send it to the COM port
')
TCP / IP connection
The connection was organized using the Revers wired tether, for this, the phone had root privileges and a TCP / IP connection to the PC was created using the
android-wired-tether program. Why not over WiFi? Yes, there is such a possibility, it is possible to create a virtual WiFi adapter on windows 7 and it will already connect to it from Android. But my Atheros AR5B95 adapter after 5 minutes of connection took the system to a blue screen, so it was decided to create a connection all the same over the wire + on it the device also charges, which is important when using GPS (it is voracious in terms of power).
NMEA data from Android, receiving and sending
The data on Android was obtained by the following code:
//NMEA listener
LocationManager LM = (LocationManager) getSystemService(Context.LOCATION_SERVICE); ((LocationManager)getSystemService(Context.LOCATION_SERVICE)).requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,new LocationListener(){
@Override
public void onLocationChanged(Location loc) {}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status,Bundle extras) {} });
LM.addNmeaListener(new GpsStatus.NmeaListener() {
public void onNmeaReceived(long timestamp, String nmea) {
SendNmea2UDP(nmea);
}});
And they were transmitted to the
SendNmea2UDP method which sent them to the UDP port of the PC:
public void SendNmea2UDP(String nmeastring)
{
message = nmeastring;
msg_length=message.length();
messageB = message.getBytes();
nmeapacket = new DatagramPacket(messageB, msg_length,local,server_port);
try
{
socket.send(nmeapacket);
}
catch(Exception e) {}
}
NMEA data on PC
To receive data and send them to the COM port from computers, a simple application was written in C #.
With the help of
Virtual Serial Ports Emulator , two associated virtual COM ports were created, one of which received data from the program on a PC, and on the second virtual COM port you can already receive them in any position that needs them.
Conclusion
If anyone is interested in the source code of programs, then he is here on
Android and
Windows
As a result, you can run a program that understands NMEA data from the COM port:

At the bottom right is a program that accepts UDP from Android and transmits NMEA to a virtual COM port. The upd2com program sends to port 3, and for example in this case, SASPlanet accepts from port 4 (this is organized using VSPE). The little red dot is where I'm testing all this right now.
Thank you for your attention, I hope the article was interesting for you.
Sources used
NMEA datawired_tether_1_4.apkVirtual Serial Port EmulatorUDP listener C # sampleTethering and reverse tetheringroot HTC Desire with HBOT 0.93