mihai-dinculescu / msfs-2020-gps-link

Transmit GPS data from Microsoft Flight Simulator 2020 to navigation apps.
MIT License
13 stars 1 forks source link

Garmin Aviation In support #60

Open kirkbysound opened 1 year ago

kirkbysound commented 1 year ago

Historically a lot of hardware aviation GPS units manufactured by Garmin were interfaced with the Aviation In RS232 Standard.

It's quite hard to find documentation but it exists in the GNS 480 installation manual in section B.2.1.1 and goes also by the name "Mapcom"

I've done a bit of poking around myself with the data and can reliably have a GPSMap unit follow aviation in from a serial device driven in Processing from a mac. My knowledge of rust is limited though so I'm not really equipped to look at how to add the feature myself. It's a fairly simple format in terms of serial messages written. I'll paste in my commented code from Processing below and maybe someone with a bit more rust knowledge than me could integrate it into GPS Link? It would be massively useful to allow these older devices to connect as many are built into virtual cockpits.

If I get time I might look at doing work on this myself but I think it would be a breeze for someone to copy and adjust the COM port page with the outputs adjusted to work. I can throw this into an Arduino and parse NMEA to convert into the format below but it seems rather a clumsy solution.

Sending the following at 9600 once a second causes a GPS in simulation mode with aviation in selected to update as expected.

As follows:

    myPort.write(0x02);           // STX

    myPort.write("A");            // A Lat
    myPort.write("N");            // North or South of Equator
    myPort.write(" ");            // 
    myPort.write("55");           // Degrees
    myPort.write(" ");
    myPort.write("5720");         // MMinutes SSeconds
    myPort.write(0x0D);           // Item Terminator

    myPort.write("B");            // B Lon
    myPort.write("W");            // East or West of Meridian Line
    myPort.write(" ");            // 
    myPort.write("003");          // Degrees
    myPort.write(" ");
    myPort.write("2120");         // MMinutes SSeconds
    myPort.write(0x0D);           // Item Terminator

    myPort.write("C");            // Magnetic Track in Degrees - 3 decimal
    myPort.write("000");          // 000
    myPort.write(0x0D);

    myPort.write("D");            // Ground Speed Knots
    myPort.write("667");          // 667 Mach 1
    myPort.write(0x0D);

    myPort.write("E");            // Distance to active waypoint DDDDD = nm * 10
    myPort.write("00300");        // 
    myPort.write(0x0D);

    myPort.write("G");            // Cross Track Error
    myPort.write("L");            // R or L
    myPort.write("0000");         // distance off course hundredths of nm
    myPort.write(0x0D);

    myPort.write("P");            // Pressure Altitude
    myPort.write("+");            // + / - value
    myPort.write("0008");         // -1599 to + 5999 tens of feet +/- sea level, Dashed when invalid
    myPort.write(0x0D);

    myPort.write("I");            // Desired Track Magnetic
    myPort.write("0000");         // 0000 Degrees x 10
    myPort.write(0x0D);

    myPort.write("K");            // Active Waypoint Identifier xxx (xx)
    myPort.write("");
    myPort.write(0x0D);

    myPort.write("L");            // Bearing to active waypoint (degrees x10)
    myPort.write("1350");
    myPort.write(0x0D);

    myPort.write("z");            // Indicated Altitude in feet 0000
    myPort.write("5000");
    myPort.write(0x0D);

    myPort.write("Q");            // Magnetic Variation
    myPort.write("E");            // East
    myPort.write("000");          // Degs
    myPort.write(0x0D);          

    myPort.write("S-----");       // Not sure what S is. Keeping it here. Was captured from XPlane 11
    myPort.write(0x0D);

    myPort.write("T---------");   // Warnings. 4th Char will be an A if nav data is flagged
    myPort.write(0x0D);

    myPort.write("w01@");         // Moving Map Primary Route Data
    myPort.write(0x0D);

    myPort.write(0x03);           // ETX
mihai-dinculescu commented 1 year ago

I'm happy to have this added, and as you've said, it should be easy to modify the COM broadcaster.

I'm unsure of some of the fields we're currently not following (although we could).

Some are easy to guess, and some aren't. The complete list of what MSFS makes available is at https://www.prepar3d.com/SDKv5/sdk/references/variables/simulation_variables.html.

kirkbysound commented 1 year ago

Fantastic! It's a gaping omission from everyone at present.

I can help with testing on devices at my end. I have a few different models supporting the input. The good thing about the garmin unit I have is that it sort of makes up the route once it's told a few values, so once it's running, it's happy to keep freewheeling until it sees another message come in.

I did a bit of reverse engineering using the Xplane11 garmin output. I'll paste in the chunk of serial data I captured below. This is just ASCII text though so will be missing any binary data. I can re-capture using something a bit lower level but will need to figure out a way of doing that cleanly.

As you can see, a lot of the messages are just 0'd or dashed out so probably representative of what's been done before

Thanks so much for doing this. I have downloaded Vis Studio and the components for rust but it'll be easy work for you!

All the best, Andrew


z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C132
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C131
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C131
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C131
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C131
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C130
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C130
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C129
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C128
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C129
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C129
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C129
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00416
AN 47 2774
BW 122 1843
C129
D001
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D002
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D002
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D001
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C129
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C128
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C128
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C128
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C127
D001
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1843
C128
D003
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00417
AN 47 2774
BW 122 1842
C125
D004
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00418
AN 47 2774
BW 122 1842
C123
D005
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00418
AN 47 2774
BW 122 1842
C121
D005
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00418
AN 47 2774
BW 122 1842
C117
D006
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00419
AN 47 2774
BW 122 1842
C114
D007
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00419
AN 47 2773
BW 122 1841
C110
D008
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00420
AN 47 2773
BW 122 1841
C107
D008
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00421
AN 47 2773
BW 122 1841
C102
D009
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00421
AN 47 2773
BW 122 1840
C099
D010
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00422
AN 47 2773
BW 122 1840
C094
D011
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00423
AN 47 2773
BW 122 1840
C090
D011
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00423
AN 47 2773
BW 122 1839
C086
D012
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00424
AN 47 2773
BW 122 1839
C082
D013
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00424
AN 47 2773
BW 122 1838
C077
D015
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00425
AN 47 2773
BW 122 1837
C074
D018
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00426
AN 47 2773
BW 122 1837
C070
D020
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00427
AN 47 2773
BW 122 1836
C066
D022
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00427
AN 47 2773
BW 122 1835
C063
D022
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00428
AN 47 2773
BW 122 1834
C060
D022
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00429
AN 47 2773
BW 122 1833
C059
D021
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00429
AN 47 2773
BW 122 1832
C058
D020
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00430
AN 47 2773
BW 122 1831
C058
D020
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C058
D016
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C058
D010
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D004
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
z00431
AN 47 2774
BW 122 1830
C057
D000
E00000
GR0000
I0000
KL0000
QE153
S-----
T---------
w01@
mihai-dinculescu commented 1 year ago

Looking at your data, I think there is scope to implement an MVP with just:

So how is this protocol called exactly?

kirkbysound commented 1 year ago

Much the same as NMEA. It's sent once a second and anything listening on the serial line takes the data. I think later models perhaps send more frequently. My unit works at 9600 which I think is default on some but i'd imagine later units operate with higher refresh times.

xplane 11 kicks out Garmin Aviation format data if you want a look at what it's doing. XP12 has removed it by the look of things though.

Thanks!