Eddayy / flutter_star_prnt

Flutter plugin for star printer
GNU General Public License v3.0
16 stars 73 forks source link

PlatformException in portDiscovery #22

Closed viktordineout closed 3 years ago

viktordineout commented 3 years ago

Recently i've been seeing this error:

PlatformException(PORT_DISCOVERY_ERROR, Cannot find printer, null null)

This happens when trying to discover using StarPortType.All Works fine when using StarPortType.Bluetooth or StarPortType.LAN. So it seems to be something related to USB.

Since there hasn't been any changes to this library that might have broke this i'm guessing this has something to do with a Android upgrade.

Anyone else seen this recently?

nataphonk commented 3 years ago

It failed because you discover USB printer when there is no USB printer connected. I think this is not an expected behavior. When detect all printer interface, the function should return nothing, not an exception. But the exception is throw from StarPrnt library not from the plugin, so we can do nothing about it. The workaround is try to catch an exception and discover the other interface one by one and add all device together.