star-micronics / StarXpand-SDK-Android

StarXpand SDK for Android is a software development kit for supporting application development for Star Micronics devices.
https://star-m.jp/starxpandsdk-oml.html
Other
14 stars 2 forks source link

Connecting to multiple printers from single app throw errors #27

Open jeffizhungrydd opened 3 months ago

jeffizhungrydd commented 3 months ago

Description

Hey team, when we're trying to connect to multiple star printers from the same Android connection. It looks an open connection to the first printer ~blocks operations~ throws errors when trying to connect to the second printer. Is this expected behavior?

Your device where the bug occurs

Your printer

Your development environment

The result of executing the command ver on Windows, sw_vers on macOS, uname –a on Linux, or these equivalent commands.

Additional context

Any other context about your topic.

Tatsuki-Yamamoto2731 commented 3 months ago

@jeffizhungrydd Does “blocks” mean that some kind of error occurs? If so, please let me know which type of error occurs.

jeffizhungrydd commented 3 months ago

Hey Tatsuki, just chatted with my team. It's not a block, we get this error from the SDK

com.starmicronics.stario10.StarIO10InUseException: The device is in use by another process. errorCode: None'

This occurs when we try to get the status for 2 printers from 1 Android device like we do in the Sample Code with to coroutines running in parallel

Tatsuki-Yamamoto2731 commented 3 months ago

@jeffizhungrydd It should not cause errors when doing StarPrinter.open() from one Android device to two printers. I tried it, but no errors occurred.

As the message says, StarIO10InUseException suggests that the printer is being used by another process. One possibility is that one coroutine is not doing close() and another is doing open() on the same StarPrinter instance. For example, remove close() from this sample code and push "GET STATUS" button twice, StarIO10InUseException will occur.

Could you please check to see if a similar scenario is included in your app?

jeffizhungrydd commented 2 months ago

Oh I see, I think that's consistent with what I'm observing. Can you confirm this example?

Example

In this example, even though PrinterA and PrinterB are two different instantiations of the StarPrinter class which connect to two different printers. PrinterB's open call will fail with StarIO10InUseException: The device is in use by another process because PrinterA has held the connection open

I've also tested this with the scenario where PrinterA is a LAN printer, and PrinterB is a Bluetooth printer and I still get this StarIO10InUseException: The device is in use by another process

If yes, do you know how I can connect to multiple printers at the same time?

Tatsuki-Yamamoto2731 commented 2 months ago

@jeffizhungrydd In this case, “#9100 Data Timeout” setting seems to have worked for StarIO10InUseException issue. Could you please try it?