dsuarezv / mavlink.net

A better MavLink object generation for C#. Richer message classes are generated from the object definitions.
38 stars 35 forks source link

Mavlink sending message and didn’t response message #22

Open heotaein opened 6 years ago

heotaein commented 6 years ago

I use "Silicon Labs CP210x USB to UART Bridge (COM6)".

///////////////////////////////////////////////////////////////////////////////////////////////////////// step1. connect Serialport - success In pixhawk2.1, the default information is displayed. (GPS, etc.) ///////////////////////////////////////////////////////////////////////////////////////////////////////// public MavLinkSerialPortTransport mavLinkSerialPortTransport = null; public Ardupilot() { mavLinkSerialPortTransport = new MavLinkSerialPortTransport(); mavLinkSerialPortTransport.SerialPortName = SerialPortName; mavLinkSerialPortTransport.BaudRate = BaudRate; mavLinkSerialPortTransport.OnPacketReceived += new PacketReceivedDelegate(recvPacket); mavLinkSerialPortTransport.Initialize(); }

private void recvPacket(object sender, MavLinkNet.MavLinkPacket packet) { Console.WriteLine(packet.Message.MessageId); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// step2. Test Sending Message - sucess But the delegate does not respond. :sob: ///////////////////////////////////////////////////////////////////////////////////////////////////////// public void MissionCount() { UasMissionCount uasMissionCount = new UasMissionCount() { MissionType = MavMissionType.Mission, TargetComponent = 1, TargetSystem = 1, }; mavLinkSerialPortTransport.SendMessage(uasMissionCount); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// I sent a lot of other messages, but not all of them answered.

dsuarezv commented 6 years ago

There is a sample that uses the library here: https://github.com/dsuarezv/mavlinkclient-cs

I don't have a pixhawk to test the protocol, but some autopilots need a specific sequence of messages to get a response. Try to find information on the specific protocol you are using, or ultimately, write a small proxy with mavlink.net to intercept all the messages and see how ground station or other software talks to the autopilot.

heotaein commented 6 years ago

Thank you for answering. I would like to know if I use fewer methods to connect using serialport. For applications that are to be used as other devices, is this method correct? I don't use UDP Connect.

heotaein commented 6 years ago

https://github.com/dsuarezv/mavlink.net/issues/17

https://github.com/amin347/TestMavlink.net It's made using the "MavlinkNet.dll" file in the URL. it seems to be a problem with the latest version.