My program is based on MAVLink MissionPlanner source of one of the software of the ground station with SimpleExample simple example of the extension to,
My environment is Windows 7 VS2012
Compile the SimpleExample example is pass for the first time, because this is an example with a command and a new MAVLink library functions do not match, there are several command names have changed, but this example did not change, so you need to have a problem after the compilation errors ordered one by one, correct, actually name change is not big, you have a problem after selecting commands directly to play ", "c # will let you choose to have been able to use the command automatically, just choose a as the original command name,
Note: this method can only control the APM flight control the output of 5-8, the output of 1-4 can't use this approach to change!
SimpleExample about port connection and data packets inside you can see, is simpler,
This article focuses on control of the output code:
Private void but_armdisarm_Click (object sender, EventArgs e) \ \ this is the case with unlock the lock command to send
{
MAVLink. Mavlink_command_long_t the req=new MAVLink. Mavlink_command_long_t ();
The req. Target_system=1;
The req. Target_component=1;
Mand=(ushort) PONENT_ARM_DISARM MAVLink.MAV_CMD.COM; req.com \ \ lock unlock command
The req. Param1=armed? 0:1;
Armed=! Armed;
/*
The req. Param2=p2;
The req. Param3=p3;
The req. Param4=p4;
The req. Param5=p5;
The req. Param6=p6;
The req. Param7=p7;
*/
Byte [] packet=mavlink. GenerateMAVLinkPacket10 (MAVLink.MAVLINK_MSG_ID.COM MAND_LONG, the req);
SerialPort1. Write (packet, 0, packet Length);
Try
{
Var ack=readsomedata
{
}
}
Catch
{
}
}
Private void button1_Click (object sender, EventArgs e)
{
Int a1=the Convert. ToInt16 (numericUpDown1. Value); \ \ output channel choice, generally in 5-8 ports, 1-4 set up there will be no response,
Int a2=the Convert. ToInt16 (textBox1. Text); \ \ set output value generally between 1000-2000,
MAVLink. Mavlink_command_long_t the req=new MAVLink. Mavlink_command_long_t ();
The req. Target_system=1;
The req. Target_component=0;
Req.com mand=(ushort) MAVLink. MAV_CMD. DO_SET_SERVO; \ \ set steering gear PWM value
The req. Param1=a1;
The req. Param2=a2;
//the req. Param3=0;
//the req. Param4=0;
//the req. Param5=0;
//the req. Param6=0;
//the req. Param7=0;
Byte [] packet=mavlink. GenerateMAVLinkPacket10 (MAVLink.MAVLINK_MSG_ID.COM MAND_LONG, the req); \ \ command package
SerialPort1. Write (packet, 0, packet Length); \ \ send command
Try
{
Var ack=readsomedata
{
}
}
Catch
{
}
}
With the above can control 5-8 PWM output channel value, free we can have a try, if the master who know how to control 1-4 of the output value hope glad!
CodePudding user response:
If you want to send the order, need a connection is established, the original posterCodePudding user response:
The building Lord, set the PWM pulse width or duty cycle time is value?