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

Failed to receive data #24

Closed MartinStokelj closed 5 years ago

MartinStokelj commented 5 years ago

Hello, i have problem, that sometimes my receive do not get anything in que. when i reboot application i get the data. What can be the reason? i create mavlink whith this code

MavLinkGenericTransport mLinkTransport = null; string port = "UDP 192.168.168.2:20002"; if (port.StartsWith("UDP")) { var a = port.Substring(port.IndexOf(' ') + 1).Split(':'); mLinkTransport = new MavLinkUdpTransport() { MavlinkSystemId = 0xFF, MavlinkComponentId = 0xBE, TargetIpAddress = IPAddress.Parse(a[0]), UdpListeningPort = int.Parse(a[1]), UdpTargetPort = int.Parse(a[1]), }; } else { mLinkTransport = new MavLinkSerialPortTransport() { SerialPortName = port, BaudRate = 115200 }; } mLinkTransport.OnPacketReceived += mLinkTransport_OnPacketReceived; mLinkTransport.OnError += mLinkTransport_OnError; mLinkTransport.OnRawBufferSent += mLinkTransport_OnRawBufferSent; mLinkTransport.Initialize();

and at the end i dispose with:

mLinkTransport.Dispose(); mLinkTransport = null;

if connection does not get anything in 15sec i dispose mLinkTransport and then i create it again, but it does not help. The sending works great even if i have problems with OnPacketReceived mLinkTransport.SendMessage(msg);

MartinStokelj commented 5 years ago

I found the problem, send/receive in our case should work like

To solve this problem i had to edit the mavlink library to set payload corectly, according to sended/received data length and not according to auto generated payload.