Giter VIP home page Giter VIP logo

dart_mavlink's People

Contributors

nus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dart_mavlink's Issues

Issue with persistent data in statustext lists

Hi,
I came across this issue with data persisting in the text list of statustext messages that come quickly together.

I setup code based on your 'parser' example, but that looks for statustext messages and prints the results.
I then connected Ardupilot SITL and tested by issuing "arm throttle" command in mavproxy.

This results in three statustext messages being sent, the first two in close succession, the last one a few seconds later, three messages shown in wireshark
image
image
image

Timing is as shown:
image

Using the following code in dart to parse the messages:

parser.stream.listen((MavlinkFrame frm) {
      if (frm.message is Statustext) {
        var st = frm.message as Statustext;
        String toprint = ascii.decode(st.text, allowInvalid: true);
        print('$toprint');
      }
    });

This gives the output:
image

So it seems like there is some data persistence issue in the lists?
Unless I've done something wrong.

The third message can be cleaned up by detecting the null termination in the list, but the second one has no null termination at the end of the message text

How to send messages

Hey, thanks for this lib,
I was able to make your example run without any issue, but i might be missing something i can't find how to send messages.

Could you help me by providing an example or even show me where i could find those informations ?

Corrupted FTP message following a non-ftp frame

Hi, I have found the following issue: A FTP message gets injected with the previous message's excess data:

        test('parse_secondMessage', () async {
            MavlinkParser parser = MavlinkParser(MavlinkDialectCommon());
            final completer = Completer<MavlinkMessage>();
            parser.stream.listen((MavlinkFrame frm) {
                if (frm.message is FileTransferProtocol) {
                  completer.complete(frm.message);
                }
            });
            // a heartbeat followed by a FTP ACK in the same frame:
            List<int> bytes = [253, 28, 0, 0, 149, 1, 1, 30, 0, 0, 43, 196, 233, 0, 159, 76, 89, 189, 119, 113, 38, 61, 42, 28, 211, 63, 128, 224, 101, 56, 160, 47, 44, 187, 80, 14, 229, 184, 100, 205, 253, 19, 0, 0, 150, 1, 1, 110, 0, 0, 0, 1, 1, 4, 0, 0, 128, 6, 3, 0, 0, 0, 0, 0, 0, 68, 65, 80, 77, 171, 119];
            Uint8List rawData = Uint8List.fromList(bytes);
            parser.parse(rawData);
            MavlinkMessage message = await completer.future;
            expect(message, isA<FileTransferProtocol>());
            FileTransferProtocol ftp = message as FileTransferProtocol;
            Uint8List sub = ftp.payload.sublist(0,18)
            expect(sub , equals(Uint8List.fromList([4, 0, 0, 128, 6, 3, 0, 0, 0, 0, 0, 0, 68, 65, 80, 77, 0, 0])));
        });

fails:

Expected: [4, 0, 0, 128, 6, 3, 0, 0, 0, 0, 0, 0, 68, 65, 80, 77, 0, 0]
  Actual: [4, 0, 0, 128, 6, 3, 0, 0, 0, 0, 0, 0, 68, 65, 80, 77, 56, 160]
   Which: at location [16] is <56> instead of <0>

suggestion to fix:

common.dart (commit 4c93f21):

  factory FileTransferProtocol.parse(ByteData data_) {
      ...
      var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);

change to:

  factory FileTransferProtocol.parse(ByteData data_) {
      ...
      var d = data_.buffer.asUint8List(data_.offsetInBytes, data_.lengthInBytes) + List<int>.filled(len, 0);

Trying to pull MISSION Params List From the Drone But no response from it.

I am using this below to send the request

var missionParamRequestList = MissionRequestList(
    targetSystem: 1,
    targetComponent: 1,
    missionType: mavMissionTypeMission,
  );
  var frm = MavlinkFrame.v2(1, 1, 1, missionParamRequestList);
  await port?.write(frm.serialize());
  print("sent");

for listening to the parameters i am using this code

dialect = MavlinkDialectCommon();
parser = MavlinkParser(dialect!);

parser?.stream.listen((MavlinkFrame frm) {
  //...
});

MAVLink XML change to allow exponentiation operator in bitmask flag

FYI We're modifying the MAVLink XSD validation file in ArduPilot/pymavlink#920 to allow a bitmask value to be declared using the Python exponentiation operator.

This makes it easier to immediately visualize which bit is set by a flag, because you can use the syntax

<entry value="2**15" name="BIT15" />

rather than

<entry value="32768" name=" BIT15" />

This is transparent to mavgen because the parser evaluates the number before creating the generated headers. However it may affect other parsers.
We're not updating the XML yet to allow other parsers time to update.

Any concerns, please raise on ArduPilot/pymavlink#920

Unable to command any message

Im trying to command a message and I can not make it work. Event the parameter example that comes in the lib.

I do not get the ack.

Trying to arm the drone:

void armVehicle() {
    CommandLong armVehicle = CommandLong(
        param1: 1,
        param2: 0,
        param3: 0,
        param4: 0,
        param5: 0,
        param6: 0,
        param7: 0,
        command: 400,
        targetSystem: 1,
        targetComponent: 1,
        confirmation: 0,
      );
    MavlinkFrame frame = MavlinkFrame.v2(0, 255, 1, armVehicle);
    var _serialized_frame = frame.serialize();

    _socket!.send(_serialized_frame, _socket!.address, _socket!.port);

Im also unable to send the heartbeat to the Px4

Heartbeat heartbeat = Heartbeat(
      customMode: 0,
      type: mavTypeGcs,
      autopilot: mavAutopilotInvalid,
      baseMode: 0, 
      systemStatus: 0, 
      mavlinkVersion: 0
    );
    
    MavlinkFrame frame = MavlinkFrame.v2(0, 255, 1, heartbeat);
    _socket!.send(frame.serialize(), InternetAddress.anyIPv4, 14540);

Any Idea How we can pass the data like REQUEST_DATA_STREAM or PARAM_REQUEST_LIST via usb

i am using some thing like this but i am not sure if its working or not

RequestDataStream requestDataStream = RequestDataStream(
      targetSystem: 1,
      targetComponent: 1,
      startStop: 1,
      reqMessageRate: 2,
      reqStreamId: 0,
);
await port?.write(requestDataStream.serialize().buffer.asUint8List());
var paramRequestList = ParamRequestList(
      targetSystem: 1,
      targetComponent: 1,
);
await port?.write(paramRequestList.serialize().buffer.asUint8List());

Not able to send command

I am not able to change the mode. Can anyone please help me out how to change the mode.

My code

var changeMode=SetMode(customMode: 216, targetSystem: 1, baseMode: 88); var frm = MavlinkFrame.v1(sequence, systemId, componentId, paramRequestList); socket.send(frm.serialize(), d.address, d.port);

Publishing on pub.dev

Hello, I just saw this library on the MAVLink website, great work! Do you plan on publishing this library to pub.dev, to make it easier to import?

Bug in setInt8List and setUint8List functions in mavlink_message.dart

Bug in setInt8List and setUint8List functions in mavlink_message.dart

Hi there,

I've identified a bug in your code related to the setInt8List and setUint8List functions in the mavlink_message.dart file. The issue is that these functions do not increment the offset, causing all elements to be inserted at the same location. Below is the corrected version of the functions:

static void setInt8List(ByteData data, int offsetByte, List<int> list) {
  int len = list.length;
  for (int i = 0; i < len; i++) {
    data.setInt8(offsetByte + i, list[i]);
  }
}

static void setUint8List(ByteData data, int offsetByte, List<int> list) {
  int len = list.length;
  for (int i = 0; i < len; i++) {
    data.setUint8(offsetByte + i, list[i]);
  }
}

Unfortunately, I'm unable to submit a pull request. Could you please implement these changes, or consider adding me as a contributor so that I can submit the fix?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.