Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module to read and write from serial port #4

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "flutter_app/dart_mavlink"]
path = flutter_app/dart_mavlink
url = [email protected]:nus/dart_mavlink.git
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sun Jul 16 13:37:01 EDT 2023
gradle.version=7.4.2
Binary file not shown.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new org.sigrok.flutter_libserialport.FlutterLibserialportPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_libserialport, org.sigrok.flutter_libserialport.FlutterLibserialportPlugin", e);
}
}
}
1 change: 1 addition & 0 deletions flutter_app/android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter.sdk=/opt/homebrew/Caskroom/flutter/3.10.2/flutter
14 changes: 14 additions & 0 deletions flutter_app/ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter
FLUTTER_APPLICATION_PATH=/Users/matthewkeller/WARG/IMACS-2/flutter_app
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
13 changes: 13 additions & 0 deletions flutter_app/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/matthewkeller/WARG/IMACS-2/flutter_app"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
19 changes: 19 additions & 0 deletions flutter_app/ios/Runner/GeneratedPluginRegistrant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Generated file. Do not edit.
//

// clang-format off

#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h

#import <Flutter/Flutter.h>

NS_ASSUME_NONNULL_BEGIN

@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end

NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */
14 changes: 14 additions & 0 deletions flutter_app/ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Generated file. Do not edit.
//

// clang-format off

#import "GeneratedPluginRegistrant.h"

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
}

@end
38 changes: 38 additions & 0 deletions flutter_app/lib/serial_comms.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'dart:typed_data';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_libserialport/flutter_libserialport.dart';

class SerialComms {
final SerialPortReader _reader;
final SerialPort _port;
StreamController<Uint8List> _dataStreamController = StreamController<Uint8List>();
Stream<Uint8List> get onData => _dataStreamController.stream;

SerialComms(SerialPort port, {int? timeout})
: _port = port,
_reader = SerialPortReader(port, timeout: timeout) {
port.openReadWrite();
_reader.stream.listen((Uint8List data) {
_dataStreamController.add(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback will call parser.parse(data); where parser = MavlinkParser(dialect); .

}, onError: (error) {
// TODO
}, onDone: () {
_dataStreamController.close();
});
}

void listen() {
onData.listen((Uint8List data) {
print('Received data: ${data}');
});
}

void write(Uint8List data) {
_port.write(data);
}

void close() {
_reader.close();
}
}
1 change: 1 addition & 0 deletions flutter_app/macos/Flutter/ephemeral/.app_filename
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter_app.app
13 changes: 13 additions & 0 deletions flutter_app/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter
FLUTTER_APPLICATION_PATH=/Users/matthewkeller/WARG/IMACS-2/flutter_app
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=/Users/matthewkeller/WARG/IMACS-2/flutter_app/lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9jZGJlZGE3ODhhMjkzZmEyOTY2NWRjM2ZhM2Q2ZTYzYmQyMjFjYjBkLw==
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=/Users/matthewkeller/WARG/IMACS-2/flutter_app/.dart_tool/package_config.json
Loading