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

Move SteamControllers and _parseMavlinkMessage #26

Merged
merged 2 commits into from
Jul 17, 2024
Merged

Move SteamControllers and _parseMavlinkMessage #26

merged 2 commits into from
Jul 17, 2024

Conversation

47vy
Copy link
Contributor

@47vy 47vy commented Jul 15, 2024

No description provided.

Copy link
Contributor

@BalajiLeninrajan BalajiLeninrajan left a comment

Choose a reason for hiding this comment

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

I made the _tcpSocket var public and added the code below

GetDroneInformation({required this.comm}) {
    _listenTcpPort();
    _parseMavlinkMessage();
  }

  _listenTcpPort() async {
    await comm.tcpSocketIntializationFlag.future;
    comm.tcpSocket.listen(
      (Uint8List data) {
        _parser.parse(data);
      },
      onError: (error) {
        print(error);
        comm.tcpSocket.destroy();
      },
    );
  }

This for some reason gets rid of the errors. We should be able to merge once you do something similar for the serial port.


GetDroneInformation({required this.comm}) {
_parseMavlinkMessage();
comm.stream.listen((Uint8List data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this, we can make _tcpSocket public (or add getter to it) and listen to it that way, somehow that fixes the bug

}

_startupTcpPort(String connectionAddress, int tcpPort) async {
// Connect to the socket
_tcpSocket = await Socket.connect(connectionAddress, tcpPort);
_tcpSocket.listen((Uint8List data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this logic to GetDroneInformation

StreamController<int> get latStreamController => _latStreamController;
StreamController<int> get lonStreamController => _lonStreamController;
StreamController<int> get altStreamController => _altStreamController;
Stream<Uint8List> get stream =>
Copy link
Contributor

Choose a reason for hiding this comment

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

make this for the _tcpSocket instead

Copy link
Contributor

@BalajiLeninrajan BalajiLeninrajan left a comment

Choose a reason for hiding this comment

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

Lgtm!

@47vy 47vy merged commit fe57eb9 into main Jul 17, 2024
1 check passed
@47vy 47vy deleted the more-refactor branch July 17, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants