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

Reproduce issue 1: Retrieving network printer status fails after subsequent attempts #6

Merged
merged 1 commit into from Nov 30, 2021

Conversation

physphil
Copy link
Owner

@physphil physphil commented Nov 30, 2021

Adds the ability to reproduce the issue where retrieving network printer statuses fails after multiple attempts. Getting a printer status works correctly the first time, but fails the second time with the following error:

Failed to getPort. Printer is in use.

During development it was discovered that calling SMPort.releasePort(port) twice will successfully release the port and the status can be retrieved, whereas calling it only once will not.

STR:

  1. Turn on a Wi-Fi printer.
  2. Launch the app and press Scan Network for the app to discover the Wi-Fi printer. Select the printer from the list.
  3. On the printer details page, press Get status, release port TWICE. Verify the printer status changes to Online.
  4. Press Get status, release port TWICE a few more times, verifying the status is always Online.
  5. Press Get status, release port ONCE, verify the status is Online.
  6. Press Get status, release port ONCE again, and verify the status changes to Offline after a few seconds, with the following error message logged. Any subsequent attempt to get the printer status will result in this failure.
StarSampleApp[509:56850] Failed to open printer port, with an error of: Error Domain=jp.star-m.stario Code=-100 "Failed to getPort. Printer is in use." UserInfo={NSLocalizedDescription=Failed to getPort. Printer is in use.}

- add buttons to UI to get status, releasing port once or twice
Comment on lines +20 to +29
private val _printerStatus = MutableSharedFlow<String>()
val printerStatus = _printerStatus.asSharedFlow()

init {
backgroundScope.launch {
starIoExtManagerWrapper.printerStatus.collect { status ->
_printerStatus.emit(status)
}
}
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

@Baileypollard I modified some code here in order to emit printer statuses from either the StarIoExtManager or by calling the starSdk.getWifiPrinterStatus() method. Can you take a quick look and verify this still works as expected in your case?

Comment on lines +24 to +25
Text("MAC address: \(portInfo.macAddress)")
Text("Port name: \(portInfo.portName)")
Copy link
Owner Author

Choose a reason for hiding this comment

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

I added some titles to this text for clarity.

@physphil physphil marked this pull request as ready for review November 30, 2021 19:39
@physphil physphil changed the title Reproduce issue 2: Retrieving network printer status fails after subsequent attempts Reproduce issue 1: Retrieving network printer status fails after subsequent attempts Nov 30, 2021
Copy link
Collaborator

@Baileypollard Baileypollard left a comment

Choose a reason for hiding this comment

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

👏👏 why double releasing the port works is a mystery 😅

@Baileypollard Baileypollard merged commit cc71065 into main Nov 30, 2021
@physphil physphil deleted the ps/poll-retrieve-status branch December 15, 2022 21:31
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.

None yet

2 participants