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

How to Send Message #21

Closed amin347 closed 7 years ago

amin347 commented 7 years ago

Dear Mr Suarez, I recently use your Library and write this Code

  ` public MavLinkSerialPortTransport mluc = new MavLinkSerialPortTransport();
    private void btnConnect_Click(object sender, EventArgs e)
    {
        mluc.SerialPortName = "COM22";
        mluc.BaudRate = 57600;
        mluc.HeartBeatUpdateRateMs = 1000;

        mluc.OnPacketReceived += OnMavLinkPacketReceived;

        mluc.Initialize();
        mluc.BeginHeartBeatLoop();

        lblConnect.Text = "Connected";
        btnConnect.Enabled = false;
    }
    private void button1_Click(object sender, EventArgs e)
    {
        UasCommandLong sas = new UasCommandLong();

        sas.Command = MavCmd.ComponentArmDisarm;
        sas.Param1 = 1;

        mluc.SendMessage(sas);
    }`

I could get data from serial port but when i send message, nothing happens.Please Help me. Thank's

Jesse-Millwood commented 7 years ago

I am having the same issue. Is it not enough to simply call the SendMessage method? I am using udp and trying to send the RC_CHANNELS_OVERRIDE message. When using the debugger it seems have the same content as the message sent by mavproxy by doing a rc 1 1000 command. But my message never shows up even passing through mavproxy when watching for the RC_CHANNELS_OVERRIDE command. I've also matched my MavLinkSystemId to what the uav has for parameters.

Jesse-Millwood commented 7 years ago

nevermind I seem to be sending packets fine. @amin347 are you in a mode that allows you to arm?

amin347 commented 7 years ago

@Jesse-Millwood None of the commands that I write does not work. :(

amin347 commented 7 years ago

@dsuarezv plz help me!!. tnx.

salocinx commented 7 years ago

I can't find usage examples. Is there any documentation specific to the mavlink.net classes?

amin347 commented 7 years ago

@salocinx hey,I've used this example:this and you can use my test app.

salocinx commented 7 years ago

@amin347: hi - thank you very much for your instant help. I'll have a look at your example :-)

diablo1281 commented 7 years ago

Hi, I just start working with this lib, but when I connect to PX4, program throw IndexOutOfRangeException in BlockingCircularStream.Write(byte[] buffer, int offset, int count).

I can't handle it to make working connection. Do you have any idea what is going on?

dsuarezv commented 7 years ago

Can you post a stack trace?

diablo1281 commented 7 years ago

Here it is:

Wystąpił wyjątek System.IndexOutOfRangeException HResult=0x80131508 Message=Tried to write more bytes than the capacity of the circular buffer. Source=mavlink Ślad stosu: w System.IO.BlockingCircularStream.Write(Byte[] buffer, Int32 offset, Int32 count) w C:\Users\diabl\Source\Repos\SimpleMissionPlanner\SimpleMissionPlanner\Libs\ mavlink.net\BlockingCircularStream.cs:wiersz 202 w MavLinkNet.MavLinkAsyncWalker.ProcessReceivedBytes(Byte[] buffer, Int32 start, Int32 length) w C:\Users\diabl\Source\Repos\SimpleMissionPlanner\SimpleMissionPlanner\Libs\ mavlink.net\MavLinkAsyncWalker.cs:wiersz 58 w MavLinkNet.MavLinkSerialPortTransport.ProcessReceiveQueue(Object state) w C:\Users\diabl\Source\Repos\SimpleMissionPlanner\SimpleMissionPlanner\Libs\ mavlink.net\MavLinkSerialPortTransport.cs:wiersz 117 w System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) w System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) w System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() w System.Threading.ThreadPoolWorkQueue.Dispatch() w System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

dsuarezv commented 7 years ago

OK, so the circular buffer is full. Are you reading the messages on your end? If you just connect, and do not process the messages (faster than they are produced) the buffer fills. You can increase the buffer size or process the messages faster.

diablo1281 commented 7 years ago

I just make first try to launch it and check if it connect. With what should I read messages?

dsuarezv commented 7 years ago

I see, check sample on this repo:

https://github.com/dsuarezv/mavlinkclient-cs