flutter_libserialport

repository·main·Indexed 41 days ago

https://github.com/jpnurmi/flutter_libserialport

A Flutter wrapper for the libserialport C-library that simplifies the build and deployment process for the libserialport Dart package. It supports Linux, macOS, Windows, and Android, providing a consistent interface for port enumeration, metadata access, configuration, and data transfer.

Tokens
1.1K
Snippets
4
Records
9
Agent score
52%

What's inside flutter_libserialport

  1. Customize iOS launch screen assets

    main

    To customize the launch screen for the iOS version of your Flutter application, you can replace the existing image files within the example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory with your own assets.

    Alternatively, you can manage these assets using Xcode:

    1. Open the iOS project workspace using open ios/Runner.xcworkspace.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog.
    open ios/Runner.xcworkspace
  2. Install flutter_libserialport

    main

    To use this package, add flutter_libserialport as a dependency in your pubspec.yaml file. This package acts as a wrapper around the libserialport Dart package, automating the build and deployment of the underlying libserialport C-library so it works out of the box.

    dependencies:
      flutter_libserialport: ^0.6.0
  3. What libserialport can do

    main

    libserialport is a minimal C library designed to abstract OS-specific serial port details. It provides a consistent interface for the following operations across supported platforms:

    • Port enumeration: Obtaining a list of available serial ports on the system.
    • Port metadata: Accessing USB device information, Bluetooth addresses, etc.
    • Port lifecycle: Opening and closing ports.
    • Configuration: Setting port parameters such as baud rate and parity.
    • Data transfer: Reading, writing, and flushing data.
    • Error handling: Obtaining error information.
  4. Build libserialport on Windows

    main

    On Windows, you can build libserialport using one of two methods:

    1. Visual Studio: Use Visual Studio 2019 or the standalone MSBuild tool with the provided solution and project files.
    2. MinGW-w64 (Autotools): Use the MinGW-w64 toolchain (via MSYS2 or cross-compiling).

    Important for MSYS2 users:

    • To produce standard Windows DLLs without additional dependencies, use the "MSYS2 MinGW 32-bit" or "MSYS2 MinGW 64-bit" command windows.
    • Avoid using the "MSYS2 MSYS" shell, as it builds against the Cygwin compatibility layer, which disables port enumeration and metadata support and introduces a dependency on Cygwin.
    # Requirements for MSYS2 builds:
    # Install: autoconf, automake-wrapper, libtool, make, and either:
    # - mingw-w64-i686-gcc (for 32-bit)
    # - mingw-w64-x86_64-gcc (for 64-bit)
  5. Available libserialport example programs

    main

    The following C programs demonstrate various usage patterns for libserialport:

    • list_ports.c: Displays a list of available ports on the system.
    • port_info.c: Displays detailed information about a specific port.
    • port_config.c: Demonstrates how to set and display configuration settings on a port.
    • send_receive.c: Performs a loopback test by sending and receiving data on one or two ports.
    • await_events.c: Demonstrates how to await receive events on multiple ports simultaneously.
    • handle_errors.c: Shows how to handle errors returned by the library.
  6. Build libserialport examples

    main

    You can build the provided example programs using several methods depending on your environment:

    Using Make (Linux/macOS/Unix)

    If you have make, gcc, pkg-config, and libserialport installed, run:

    make

    Note: If the build fails, you may need to modify the Makefile or update your environment paths to ensure pkg-config can locate libserialport.

    Using Microsoft Visual Studio (Windows)

    Open examples.sln in Microsoft Visual Studio 2019 to build libserialport and all example programs.

    Using any other compiler or IDE

    To build manually, ensure that:

    1. The libserialport.h header is available in your include path.
    2. The libserialport library is available to link during compilation and to run at runtime.