Closed sk-huang closed 3 days ago
I change the code , now starPrinter in application is always opend, not closed. But this printerDelegate will occasionally execute the callback of the onCommunicationError method. thie is my exception:
and then call the printAsync method, an exception will be thrown: com.starmicronics.stario10.StarIO10InvalidOperationException: Not opened. errorCode: None
who can tell me why?
@sk-huang It seems that you use V1.3.0 which is a previous version. Could you try the latest version V1.6.0?
@sk-huang The causes of communication error are varied so I have not yet been able to identify the cause of your problem. Maybe the cable contact is not good. If possible, could you try replacing the cable?
Also, when "onCommunicationError" is called, you need to redo openAsync() before printAsync() because the instance of StarPrinter will be closed.
@sk-huang It seems that you use V1.3.0 which is a previous version. Could you try the latest version V1.6.0?
My device is android 7.1 , so can not upgrade to a new version.
@Tatsuki-Yamamoto2731
You say "when 'onCommunicationError'is called, you need to redo openAsync() before printAsync() because the instance of StarPrinter will be closed". But my code always calls the openAsync() before printAsync() . Once onCommunicationError occurs, the current printer instance call openAsync() or printAsync() will give an error.
Now, inside the catch method block, I'll recreate the printer instance, call the openAsync() and printAsync() again. I watched for a while, the probability of error becomes smaller
@sk-huang You have changed your source code to create a new StarPrinter instance in the block of the catch method, but the problem is not completely resolved. From this, I think that the root cause may be a cable connection. I would appreciate it if you tried to replace it.
@sk-huang Just in case, there is one more thing I would like to confirm. For Android, TSP100IIIU needs to connect an Android terminal via USB-B. (cannot use USB-A for communication.) You can refer to this page
Could you please confirm this?
@Tatsuki-Yamamoto2731
My device is a pos machine, and the manufacturer is elo. It integrates printing and scanning code. I see that the cables in the machine are designated interfaces, and the types of cables should be correct.
These machines have been used for several years, and it is also possible that individual machine cables have aged, resulting in poor contact
Last time I changed the code to create a new printer instance in the catch method block and print again. So far online environment has not reported this issue.
Next time this problem happens, i'll ask Dev Ops to try a new cable.
@sk-huang Since there have been no reports of problems for more than 3 months, I am closing this Issue. If the problem is still ongoing, please open a new Issue.
Description
Printing getExceptionStr: com.starmicronics.stario10.StarIO10NotFoundException: Device not found. Connect the USB cable or turn on the device (if the StarPrinter instance has been opened, call the closeAsync method first), and try again. errorCode: None at com.starmicronics.stario10.rawport.g.u(SourceFile) at com.starmicronics.stario10.rawport.g.n(SourceFile) at com.starmicronics.stario10.rawport.a.c(SourceFile) at com.starmicronics.stario10.a$a.b(SourceFile) at com.starmicronics.stario10.StarPrinter.p(SourceFile) at com.starmicronics.stario10.StarPrinter.l(SourceFile) at com.starmicronics.stario10.StarPrinter$s.invokeSuspend(SourceFile) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12) at kotlinx.coroutines.t0.run(DispatchedTask.kt:119) at kotlinx.coroutines.scheduling.CoroutineScheduler.D(CoroutineScheduler.kt:1) at kotlinx.coroutines.scheduling.CoroutineScheduler$c.d(CoroutineScheduler.kt:15) at kotlinx.coroutines.scheduling.CoroutineScheduler$c.n(CoroutineScheduler.kt:29) at kotlinx.coroutines.scheduling.CoroutineScheduler$c.run(CoroutineScheduler.kt:1)
Your device where the bug occurs
Your printer
Your development environment
android studio ProductName: macOS ProductVersion: 13.4.1 ProductVersionExtra: (c) BuildVersion: 22F770820d
Additional context
My devices is android 7.1.2, when i use tag v1.3 in my project, the online apps occasionally report device not found error. How to this bug?
My code snippet (the starPrinter is singleton):