Moderator

Help needed reading Telemetry port APM2.0/ArduPlane 2.63

Hi,

I'm working on a project that involve hardware on a breadboard and software writing.

 

I hope I will not bug you 147 members of this group... with my question... since it is not exacly related to programming Ardupilot per say but is is close ;)

I wish that somebody can bring some lights on the problem I have because i'm stuck really bad....

 

First, a short description of what I'm trying to do:

Phase 1:

- Connect APM 2.0 Telemetry to a ATMega328p and read MavLink messages (basically sniffing messages like the MinimOSD do)

- Store data like Altitude, Lat, Long, attitude, etc.. on a AT45DB321D sitting on the breadboard (basically replicating APM2.0 Logging)

 

To explain my problem I will focus on the GPS Latitude metric. 

 

My code is working fine to parse the Message ID 33 GLOBAL_POSITION_INT

According to the documentation this field use int32_t type.

But when I'm trying to parse Message ID 24 GPS_RAW_INT I get strange behavior.

...and according to the Doc.  This field also use int32_t type.

 

I'm using SoftwareSerial to debug my code and this is what I'm getting:

For message ID 33 I get: 

31 44 2C 1B and give me 455885873.  Good! lat where I'm living is about 45.5885873

But... for message ID 24 I get:

44 2C 1B 69 and give me 1763388484. wrong... Bytes sequence are shifted...

 

What is wrong here?

I browse Arduplane 2.63 code in order to give me some hint regarding the parsing... but it is hard to reverse engineering code... and could not find anything except that maybe Mavlink ID24 is version 0.9??? I'm confused....

 

Another note.  I'm using "union" for parsing.  Maybe this is wrong...?  you tell me...

//union u_tag_int32_t {char b[4];int32_t ival;} Myint32;

But it is working for message ID33.

 

Is someone could help me resolve this?  That person would make my day!

I'm a true believer to DIYDrone site.  I found really nice people here.  And what a trill to fly a plane with AutoPilot onboard! I'm almost half a century old... and I needed this in order to get forward.

 I don't want to be melo dramatic here... but believe me... You guys save my life.

 

Oh and... Phase 2 is to send parsed data to a MAX7456 also on the breadboard.  And maybe build a MinimOSD with logging capability.  Just for the fun of it!

 

I read some time ago a sentence of Chris saying that we should publish our project asap even if it is not finished.  I agree. And I will publish everything here and I'm not here to make $$.

.. but at this time... I'm stuck really bad with the situation and have nothing valuable to publish.

 

Thank you all!

Eric 

 

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  •     public const byte MAVLINK_MSG_ID_GLOBAL_POSITION_INT = 33;
        [StructLayout(LayoutKind.Sequential,Pack=1,Size=28)]
        public struct mavlink_global_position_int_t
        {
            /// <summary> Timestamp (milliseconds since system boot) </summary>
            public  UInt32 time_boot_ms;
                /// <summary> Latitude, expressed as * 1E7 </summary>

            public  Int32 lat;

    ...}

     

        public const byte MAVLINK_MSG_ID_GPS_RAW_INT = 24;
        [StructLayout(LayoutKind.Sequential,Pack=1,Size=30)]
        public struct mavlink_gps_raw_int_t
        {
            /// <summary> Timestamp (microseconds since UNIX epoch or microseconds since system boot) </summary>
            public  UInt64 time_usec;
                /// <summary> Latitude in 1E7 degrees </summary>

            public  Int32 lat;

    ...}

     

    Msg=33 has a 32bit time value but the Msg=24 has a 64bit time value.  Unless you account for that everything will be shifted by 32bits.  The messages do not appear to be fixed size, so if you are reading it in an array, you need to account for that.

     

This reply was deleted.