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

Star Printer throwing Null pointer exception on connecting #19

Open
zaibniazinnowi opened this issue Jan 16, 2024 · 14 comments
Open

Star Printer throwing Null pointer exception on connecting #19

zaibniazinnowi opened this issue Jan 16, 2024 · 14 comments
Assignees
Labels
Status: question Further information is requested

Comments

@zaibniazinnowi
Copy link

zaibniazinnowi commented Jan 16, 2024

Description

On initializing Printers with following inforamtion

Interfactype MacAddress 001162332406 and name :MCP31 (STR-001)
Interfactype MacAddress 001162332404 and name :MCP31 (STR-001)

SDK is throwing following exception while initializing Printer object
Attempt to invoke interface method 'boolean com.starmicronics.stario10.rawport.c.a(com.starmicronics.stario10.InterfaceType, java.lang.String)

This exception is thrown for multiple printers all information is added above.

Your device where the bug occurs

  • POS

Your printer

  • MCP31 (STR-001)
  • Firmware Version:
    com.starmicronics:stario10:1.4.0
  • Interface:
    LAN (Mac Address)

Additional context

This issue can be recovered only when we clear the app storage or reinstalling the app, discover printer and then its start printing.

@zaibniazinnowi zaibniazinnowi added the Status: triage Start out by looking at issues label Jan 16, 2024
@zaibniazinnowi zaibniazinnowi changed the title Star Printer throwing Nill pointer exception onc Star Printer throwing Nill pointer exception on connecting Jan 16, 2024
@zaibniazinnowi zaibniazinnowi changed the title Star Printer throwing Nill pointer exception on connecting Star Printer throwing Null pointer exception on connecting Jan 16, 2024
@bandit-ibayashi
Copy link
Member

@zaibniazinnowi
The fact that clearing the storage space used by the app or reinstalling the app resolves the problem suggests that the problem is caused by the process of recalling stored values. But more information is needed for a more detailed investigation.

Could you please share your implementation code for the part that initialises the printer and for the part where this exception occurs?

@bandit-ibayashi bandit-ibayashi added Status: question Further information is requested and removed Status: triage Start out by looking at issues labels Jan 24, 2024
@zaibniazinnowi
Copy link
Author

zaibniazinnowi commented Jan 24, 2024

Hi @bandit-ibayashi
Here is the code snippet which is used to initialize printer

 suspend fun init() {
        kotlin.runCatching {
            logP("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName})")
            val identifier = appPrinter.portName
            val interfaceType = **getInterfaceType**(context, appPrinter.interfaceType)
            **val settings = StarConnectionSettings(interfaceType, identifier)
            starPrinter = StarPrinter(settings, context)**
            starPrinter!!.closeAsync().await()
            starPrinter!!.openAsync().await()
            isPrinterConnected = true
        }.onSuccess {
            logP("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName}): Star Printer Initialized Success")
            isPrinterConnected = true
        }.onFailure {
            if (it is StarIO10Exception) {
                FirebaseAnalytics.getInstance(context).logEvent(STAR_INIT_ERROR) {
                    param(PARAM_ERROR_CODE, it.errorCode.name)
                    param(PARAM_PRINTER_NAME, "${appPrinter.name}(${appPrinter.portName})")
                }
                Firebase.crashlytics.log("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName}):: init Failed: errorCode: ${it.errorCode.name}")
                Firebase.crashlytics.recordException(it)
                val errorInfo = PrinterErrorMessages.getStarMessageOnException(context, it)
                appPrinter.errorType = errorInfo.second
                appPrinter.errorMsg = errorInfo.first
                appPrinter.timeStampOfError = System.currentTimeMillis()
                printerDatabase.printerDao().updatePrinter(appPrinter)
                val logError =
                    "StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName}): initialization Failed: ${it.errorCode.name}, ${it.localizedMessage}"
                logP(logError)
                logP("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName}): init Failed message added to db. errorInfo: $errorInfo")
            } else {
                logP("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName}): Star Printer initialization Failed: ${it.localizedMessage}")
            }
            isPrinterConnected = false
        }
    }
    
    
        private fun **getInterfaceType**(context: Context, interfaceType: String): InterfaceType {
        return if (interfaceType.equals(context.getString(R.string.title_interface_lan), true)) {
            InterfaceType.Lan
        } else if (interfaceType.equals(
                context.getString(R.string.title_interface_bluetooth),
                true
            )
        ) {
            InterfaceType.Bluetooth
        } else if (interfaceType.equals(context.getString(R.string.title_interface_usb), true)) {
            InterfaceType.Usb
        } else
            InterfaceType.Lan
    }

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi Thank you for sharing your information.
Sorry for asking again, can you identify which line of code will cause a null pointer exception?

@zaibniazinnowi
Copy link
Author

@Tatsuki-Yamamoto2731

        **val settings = StarConnectionSettings(interfaceType, identifier)
        
        Above line is causing null pointer exception

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi We are checking our library with your information, but we haven't identified the root cause yet.
You have already provided the stack trace information "boolean com.starmicronics.stario10.rawport.c.a(com.starmicronics.stario10.InterfaceType、java.lang.String)", but could you please a full stack trace? It will be helpful for us.
Thank you for your cooperation.

@zaibniazinnowi
Copy link
Author

@Tatsuki-Yamamoto2731
Here is the stack trace
Attempt to invoke interface method 'boolean com.starmicronics.stario10.rawport.c.a(com.starmicronics.stario10.InterfaceType, java.lang.String)' on a null object reference.

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi Thank you very much.
Is it possible to have all the lines before and after the stack trace as well?

@zaibniazinnowi
Copy link
Author

zaibniazinnowi commented Aug 13, 2024

@Tatsuki-Yamamoto2731
I have opened another issue with the link below
[Logs file not generated] (#26)

P.S: We need to resolve this issue at highest priority as it keeps popping again and again.

@zaibniazinnowi
Copy link
Author

zaibniazinnowi commented Sep 15, 2024

@Tatsuki-Yamamoto2731
Here is the use case

Coroutine 1: PrinterA.init()
Coroutine 2: PrinterB.init()
Coroutine 3: PrinterC.init()

Coroutine 1: Open failed.
Coroutine 2: Open failed.
Coroutine 3: Open failed.

below is the code to initialize printer in co-routines
logP("StarPrintBatchUtil::init()::${appPrinter.name}(${appPrinter.portName})")
val identifier = appPrinter.portName
val interfaceType = getInterfaceType(context, appPrinter.interfaceType)
val settings = StarConnectionSettings(interfaceType, identifier)
starPrinter = StarPrinter(settings, context)

starPrinter!!.closeAsync().await()
starPrinter!!.openAsync().await()
isPrinterConnected = true

Moreover, doing this [#9100 Data Timeout] (#28 (comment)) would help to fix the above issue?

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi
It seems that you said "it (#9100 Data Timeout) works" in this comment, but is the problem still unresolved? If so, please state it in the issue #28.

I think this issue #19 should be discussed about the Null pointer exception problem. Is the Null pointer exception problem resolved?

@zaibniazinnowi
Copy link
Author

@Tatsuki-Yamamoto2731 #28 is resolved by updating printer configuration.

I have added another comment related to Portal is not logging and here is the detail comment

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi
I commented on that issue in #28.
If the Null pointer exception problem has been resolved, I would like to close this Issue #19. Please let us know your situation.

@zaibniazinnowi
Copy link
Author

@Tatsuki-Yamamoto2731
I have noticed that it is in progress.

@Tatsuki-Yamamoto2731
Copy link

@zaibniazinnowi Sorry for the late response.
I understood that the null pointer exception problem has not yet been resolved.
I previously requested the entire stack trace from you (in this comment).

According to you, SDK is throwing following exception while initializing Printer object.
"Attempt to invoke interface method 'boolean com.starmicronics.stario10.rawport.c.a(com.starmicronics.stario10.InterfaceType, java.lang.String)"
When this exception was thrown, were there any rows before or after it? Could you please provide them to us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants