How to compose MAVLINK_MSG_ID_TERRAIN_REQUEST message

Hi,

I’ve written a packet sniffing program in C that sits between ArduPilot and X-Plane and relays packets back and forth. It’s working well, but now I need to inject a MAVLINK_MSG_ID_TERRAIN_REQUEST message intended to go to the GCS (sysid 255, comp 190) as if it had been sent by the drone (sysid 1, comp 1). Then I await the GCS’s response. However, I must be doing something wrong because the GCS won’t send me the MAVLINK_MSG_ID_TERRAIN_DATA message.

Here’s my method for TCP, and perhaps you could tell me what I’m doing wrong:

First, I compose a message like this:

mavlink_message_t msg;
mavlink_msg_command_long_pack(1, 1, &msg, 255, 190, MAVLINK_MSG_ID_TERRAIN_REQUEST, 1, 338974514, -1176074192, 100, 1938953243, 0, 0, 0);

Then I send it to the GCS:

uint8_t injectbuf[1024];
uint16_t len = mavlink_msg_to_send_buffer(injectbuf, &msg);
size_t bytes = send(gcs_sockfd, injectbuf, (size_t)len, 0);

That’s pretty self-explanatory, I think. I hope someone can help!

Pogo

I think I’ve solved it myself. I am using the wrong packing function. I should be using:

mavlink_msg_terrain_request_pack(1, 1, &msg, 338976270, -1176068014, 100, 1938953243);