Pixhawk won't arm from a C# ground station (the command is sent)
Pixhawk won't arm from your C# ground control station? If no reply comes at all, the ID or CRC is wrong. If FAILED comes back, the reason is in the line after the ACK.
You press the ARM button in the C# ground control station you wrote yourself, and the propellers don't move. The same Pixhawk arms when connected to Mission Planner, but in your program either nothing happens or a one-line rejection drops onto the screen.
These two symptoms point to different places. If no reply comes at all, the packet was filtered out before it got through to the autopilot. If a rejection comes, the packet arrived, and the reason was sent out in another message.
Where the packet goes when you press ARM
The button sends the autopilot a MAVLink message called COMMAND_LONG. It contains command number 400, with 1 as the first parameter. The autopilot passes this packet through three gates in order. The figure below shows where each gate's "no" branch leads.
When the ARM packet reaches the autopilot, it ends up at one of four outcomes
Look at the two dashed boxes in the figure. On those two branches the autopilot doesn't send back a single byte, and your program waits forever for a reply.
If no reply comes at all, check the first two gates
The first gate is the checksum bytes. MAVLink adds a fixed byte to the checksum of each message type. For COMMAND_LONG this number is 152. If the number is wrong, the autopilot treats the packet as corrupt and silently drops it.
The second gate is the IDs. The target system number in the packet must match the autopilot's own number, which is 1 in a default setup. Your program's own ID, on the other hand, must not be identical to the autopilot's: when the sender is 1/1, ArduPilot treats the packet as its own echo and doesn't process it.
By default, ArduPilot expects 255 as the ground station number. If your program uses 255 as its own number, you get past both this gate and any ID restriction that may be enabled later without getting stuck.
If it's rejected, the reason comes next
If the packet reached the third gate, the autopilot replies with COMMAND_ACK. If the result is 0, arming is done. If the result is 4, one of the checks failed, and the autopilot writes the reason in a separate STATUSTEXT message.
If you exit the read loop when COMMAND_ACK arrives, you miss the reason line. ArduPilot usually sends the rejection reason right after the ACK. If the loop ends there, only FAILED is left on screen.
Example: a second takeoff after landing
In a rehearsal, you landed the drone in LAND mode, swapped the battery and pressed ARM again from the ground control station. If you didn't change the flight mode in between, the autopilot is still in LAND mode, and it doesn't allow arming in LAND.
Your program receives result 4, and the line right after it says Arm: Land mode not armable. When you switch the mode to STABILIZE or LOITER and press the button again, the result goes back to 0.
Short code: send ARM, read the reply
The .NET console program below builds the frame by hand without loading any MAVLink package and prints the replies it receives. The example connects to the TCP address 127.0.0.1:5760. On a real board, you open the serial port and use its BaseStream.
using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
// On the board: open a SerialPort and use its BaseStream. Here TCP 5760.
var s = new TcpClient("127.0.0.1", 5760).GetStream();
ushort Crc(byte[] b, int n, byte extra)
{
ushort c = 0xFFFF;
for (int i = 1; i <= n; i++)
{
byte x = i < n ? b[i] : extra;
x ^= (byte)c; x ^= (byte)(x << 4);
c = (ushort)((c >> 8) ^ (x << 8) ^ (x << 3) ^ (x >> 4));
}
return c;
}
// COMMAND_LONG (msgid 76, CRC_EXTRA 152): ARM = command 400, param1 = 1
var p = new byte[33];
BitConverter.GetBytes(1f).CopyTo(p, 0);
BitConverter.GetBytes((ushort)400).CopyTo(p, 28);
p[30] = 1; // target_system = the autopilot's MAV_SYSID
p[31] = 1; // target_component = 1 (autopilot)
var f = new byte[45];
f[0] = 0xFD; f[1] = 33; f[5] = 255; f[6] = 190; f[7] = 76;
p.CopyTo(f, 10);
ushort crc = Crc(f, 43, 152);
f[43] = (byte)crc; f[44] = (byte)(crc >> 8);
s.Write(f);
// Read the reply: COMMAND_ACK (77) and STATUSTEXT (253)
var bitis = DateTime.Now.AddSeconds(3);
while (DateTime.Now < bitis)
{
if (s.ReadByte() != 0xFD) continue;
var h = new byte[9]; s.ReadExactly(h);
var g = new byte[h[0] + 2]; s.ReadExactly(g);
int id = h[6] | (h[7] << 8) | (h[8] << 16);
if (id == 77 && g[0] == 0x90 && g[1] == 0x01)
Console.WriteLine("COMMAND_ACK result = " + (h[0] > 2 ? g[2] : 0));
if (id == 253)
Console.WriteLine(Encoding.ASCII.GetString(g, 1, h[0] - 1).TrimEnd('\0'));
}In the code, p[30] and p[31] are the target IDs, while f[5] and f[6] are your program's own ID. Keep the target as 1/1 and your own ID as 255/190.
What you'll see
If you run the program while the drone is in STABILIZE mode and all arming checks are clear, you'll see this:
COMMAND_ACK result = 0
Arming motorsIf the autopilot stayed in LAND mode, the output changes like this:
COMMAND_ACK result = 4
Arm: Land mode not armableIf no line appears on screen, check the 152 constant and both ID pairs again. If lines appear but say 4, the fix is in the Arm: line that follows.
Error Messages and Their Meanings
Arm: Land mode not armable
The autopilot is in LAND mode. Before arming, switch to STABILIZE, ALT_HOLD or LOITER.
Arm: RTL mode not armable
The autopilot is stuck in RTL mode. In the same way, switch to a mode that allows arming and try again.
Arm: Mode requires mission
You're in AUTO mode, but no mission is loaded on the autopilot. Upload the route, or arm in another mode.
Arm: Hardware safety switch
The safety button connected to the Pixhawk is still blinking. Hold the button down until the light stays solid, then send ARM again.
Arm: System not initialised
The autopilot hasn't finished booting. Wait a few seconds and send the command again.
Also check on the board
- If Mission Planner keeps the same COM port open, your C# program can't open that port. Disconnect Mission Planner first.
- If you use a telemetry radio, the baud value in your program must match the radio's serial rate. That's the rate you select when connecting in Mission Planner.
Build your own ground control station solidly
In a MAVLink client you build by hand, the first place you get stuck is usually the ARM command. In the C# from Beginner to Advanced course, you write a ground control station with WinForms step by step. The Latest Additions section holds this command's decision order in the autopilot, its place in the source code and a quick diagnosis table.
Custom Turkish Ground Control Station Library: a C# MAVLink library with Turkish code comments and a ready-made test interface, so you can start building your own GCS.
Was this article helpful?
Learn this topic from start to finish
Season plan: all six courses for 9 months, ₺790 a month. ₺390 a month for high school and university students, ₺351 the first month with your member code. You can stop in any month you like. Start the Season plan · I'm a student