public void Detatch()
 {
     if (currentSerialPortReader is not null)
     {
         currentSerialPortReader.Dispose();
         currentSerialPortReader = null;
         lastState = null;
     }
 }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    currentSerialPortReader?.Dispose();
                    currentSerialPortReader = null;
                    lastState = null;
                }

                disposedValue = true;
            }
        }