Skip to content

Serial Port is not disposed correctly during a flutter hot restart #68

Open
@bryceremick

Description

@bryceremick

Anytime I do a hot restart on my flutter app after the port has been initialized, I get this error:

Unhandled Exception: SerialPortError: Device or resource busy, errno = 16

Basically my app runs through this initialization process during every hot restart:

  1. Close/Dispose the port if it already exists
  2. Create new SerialPort instance
  3. OpenReadWrite
  4. Set Baud Rate
  5. Create new SerialPortReader instance
  6. Listen to data

I get this error at step 3 after a hot restart.

My guess is that the port is not disposed correctly and when a new port gets opened for read/write the OS throws this error because the old port still exists in memory.

This is on Android 7.1 btw.

Any suggestions on how to solve this?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions