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 1 forks source link

com.starmicronics.stario10.StarIO10CommunicationException Open failed. #29

Open zaibniazinnowi opened 3 weeks ago

zaibniazinnowi commented 3 weeks ago

Your device where the bug occurs Device: POS(ELO), Samsung Tablet OS: Android * Version Version 14 and 9 Your printer Model Names: MCP31 (STR-001) Firmware Version: (com.starmicronics:stario10:1.6.0) Interface: Ethernet/LAN

Is it possible to expose method to restart the printer from SDK so that customer does not need to call every time.

I am facing issue with MCP31 (STR-001) Non-fatal Exception: com.starmicronics.stario10.StarIO10CommunicationException Open failed and it is expected to resolve after updating configuration mention above but no success.

I am using multiple printers and making sure that each print must be disconnected properly after performing job and i have verified from the app logs as well.

After restarting printer, it starts connecting and printing.

I have updated printer configuration as well mentioned in below ticket

#28

com.starmicronics.stario10.StarPrinter.a (SourceFile:11) com.starmicronics.stario10.StarPrinter.a (SourceFile:10) com.starmicronics.stario10.StarPrinter.b (SourceFile:3) com.starmicronics.stario10.StarPrinter.access$internalOpen com.starmicronics.stario10.StarPrinter$s.invokeSuspend (Unknown Source:78) kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106) kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:584) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:793) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:697) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:684)

Tatsuki-Yamamoto2731 commented 1 week ago

@zaibniazinnowi Please refer to “3.1.4 Reset with authorization” in the following document. (This document is for MCP31CI/CBI, not for MCP31L/LB, but the method is also available to MCP31L/LB) mC-Print3 General Specification 2nd Generation

[Preparation] Execute self-printing and check "user" Login Password. How to execute self-printing

"user" Login Password is written in the red frame below. image

[Implementation (example)]

import java.net.InetAddress
import java.net.Socket
import java.io.OutputStream

fun sendResetCommand() {
        val ipAddress = "XXX.XXX.XXX.XXX"  //IP address of the printer
        val inetAddress = InetAddress.getByName(ipAddress)
        val port = 22222  //Destination port number

        // Reset command
        val data = byteArrayOf(
            0x1C.toByte(),
            0x30.toByte(),
            0x75.toByte(), //"u"
            0x73.toByte(), //"s"
            0x65.toByte(), //"e"
            0x72.toByte(), //"r"
            0x00.toByte(), //null
            0xHH.toByte(), //---------------------------
            0xHH.toByte(), // 
            0xHH.toByte(), //Your "user" Login Password
            0xHH.toByte(), //
            0xHH.toByte(), //---------------------------
            0x00.toByte()  //null
        )

        var socket: Socket? = null
        var outputStream: OutputStream? = null

        try {
            socket = Socket(inetAddress, port)
            outputStream = socket.getOutputStream()

            outputStream.write(data)
            outputStream.flush()
        } catch (e: Exception) {
            e.printStackTrace()
        } finally {
            try {
                outputStream?.close()
                socket?.close()
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }
}

I hope this method is useful to you.