flutter_msp

Version 0.4.0Multiplatform MSP (MultiWii Serial Protocol) helper for Flutter & Dart.

flutter_msp is a pure-Dart library that hides the boilerplate of opening serial ports and building MSP frames, letting you focus on your drone, flight‑controller or robot logic instead of the wire format.


Table of Contents

  1. Features
  2. Requirements
  3. Installation
  4. Quick Start
  5. API Overview
  6. Example App
  7. Troubleshooting
  8. Development & Contributing
  9. License
  10. Links

✨ Features

Feature Notes
🔌 Cross‑platform serial I/O Wraps flutter_libserialport – works on Windows, macOS, Linux and Android (USB‑OTG).
📡 MSP V1 & V2 Helpers for '$M<' and '$X<' frames, automatic CRC‑8 DVB‑S2 for V2.
Async / Future‑based Non‑blocking I/O fits naturally into Flutter’s event loop.
🧩 Flexible payloads Accepts String, int and List<int> out‑of‑the‑box – extendable for structs.
🛠 Utility CLI mode Send raw '#' CLI command for legacy firmware.
📝 Verbose logging Toggle to print raw bytes and decoded information.

📋 Requirements

Minimum version
Dart SDK >= 3.0.3 < 4.0.0
Flutter Any stable channel (tested on 3.22)
Rust ✔ users only (Linux) udev rules for serial port or run as root

📦 Installation

Add the package to your app’s pubspec.yaml:

dependencies:
  flutter_msp: ^0.4.0

Fetch it:

flutter pub get

🚀 Quick Start

import 'package:flutter_msp/flutter_msp.dart';

Future<void> main() async {
  // 1. List available ports
  final ports = SerialPort.availablePorts;
  print('Ports found: $ports');

  // 2. Connect
  final msp = MSPCommunication(ports.first);

  // 3. Ping with CLI '#'
  await msp.sendMessageCLI();

  // 4. Send MSP V1 command
  await msp.sendMessageV1(
    100,               // Command code
    [1, 2, 3, 4],      // Int list payload
  );

  // 5. Send MSP V2 command with string payload
  await msp.sendMessageV2(
    200,
    'Hello FC!',
  );
}

sendMessageV…() opens the port (if not already open), sends, waits 1 s for a reply, prints it, then closes.
For long‑running streams open the port once and call encodeMessageV…() directly.


🛠 API Overview

Item Purpose
class MSPCommunication High‑level helper that owns a SerialPort.
avaiblePorts() (Yes, the original misspelling is kept!) Prints ports list.
sendMessageV1(int code, dynamic data) Build & send MSP V1 frame.
sendMessageV2(int code, dynamic data) Build & send MSP V2 frame.
sendMessageCLI() Send legacy '#' command.
encodeMessageV1()encodeMessageV2() Static helpers → Uint8List.
crc8DvbS2() Reference CRC‑8 DVB‑S2 implementation.

Full API docs are generated with dart doc and published to GitHub Pages.


📱 Example App

A minimal Flutter desktop app that streams MSP data lives in /example.

cd example
flutter run -d windows   # or macos / linux / android

The sample shows:

  • Real‑time serial port discovery
  • Connect / disconnect button
  • Live hex dump of in‑flight MSP frames

🐞 Troubleshooting

Symptom Fix
SerialPortError: failed to open the port • Ensure you have permission (Linux: sudo usermod -aG dialout $USER) • Close any other app using the port.
No data received • Confirm baud rate (default: 115 200) • Double‑check your command code • Set verbose = true to inspect raw bytes.
CRC mismatch • Make sure you’re using the correct MSP version (V1 vs V2) on both sides.

🤝 Development & Contributing

# Clone fork
git clone https://github.com/Antizames/Flutter_msp.git
cd Flutter_msp

# Format & static analysis
dart format .
dart analyze .

# Run tests (if any)
flutter test

Pull requests are welcome! Please:

  1. Open an issue first if it’s a large change.
  2. Keep commits focused & well‑described.
  3. Update README / docs where relevant.

📜 License

flutter_msp is released under the MIT License.
See LICENSE for the full text.



Happy hacking, and may your packets stay CRC‑free! 🛸

Libraries

flutter_msp