brasizza / sunmi_printer

BSD 3-Clause "New" or "Revised" License
38 stars 45 forks source link

getPrinterStatus() always return ERROR #45

Closed Mapashito1 closed 7 months ago

Mapashito1 commented 1 year ago

When I write...

PrinterStatus result = await SunmiPrinter.getPrinterStatus() print(result)

...always result == PrinterStatus.ERROR . It's a sunmi v2

Why? I can print OK but I never can get status.

brasizza commented 1 year ago

I need to know your device. Maybe it doesn't have the method implemented

Mapashito1 commented 1 year ago

I need to know your device. Maybe it doesn't have the method implemented

It's a sunmi V2 model

I've tried to debug code and I inspected status after _woyouService.updatePrinterState() and it returns 0 (it's not a exception)

In native android (not flutter), when I call to updatePrinterState(), the result is OK

RioRocker97 commented 1 year ago

hey, i got the same problem too. if you can implement it , that would really help me with my work. Thx.

brasizza commented 1 year ago

This is the method The exception will return 0 i can change this implementation to send -1 but i will need to check


public int updatePrinter() {
        try {
            final int status = _woyouService.updatePrinterState();
            return status;
        } catch (RemoteException e) {
            return 0; // error
        } catch (NullPointerException e) {
            return 0;
        }
    }```
Mapashito1 commented 1 year ago

I've added a print....

public int updatePrinter() {
        try {
            final int status = _woyouService.updatePrinterState();
            print(status);
            return status;
        } catch (RemoteException e) {
            return 0; // error
        } catch (NullPointerException e) {
            return 0;
        }
    }

And it prints 0. Then it's not a exception, I don't why but _woyouService.updatePrinterState() always return 0

brasizza commented 1 year ago

the _woyouService is not made by me, i just use the AIDL , maybe the v2 model can't find the print. the _woyouService is just a stub from AIDL .

Em ter., 4 de out. de 2022 às 14:02, Mapashito1 @.***> escreveu:

I've added a print....

public int updatePrinter() { try { final int status = _woyouService.updatePrinterState(); print(status); return status; } catch (RemoteException e) { return 0; // error } catch (NullPointerException e) { return 0; } }

And it prints 0. Then it's not a exception, I don't why but _woyouService.updatePrinterState() always return 0

— Reply to this email directly, view it on GitHub https://github.com/brasizza/sunmi_printer/issues/45#issuecomment-1267299080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGV4NUKL6WOSKOSKZDEJLLWBRPJXANCNFSM6AAAAAAQZVX6P4 . You are receiving this because you commented.Message ID: @.***>

-- Marcus Vinicius Brasizza

Raspibr Brasil

http://raspibr.com.br http://raspibr.com.br

iamricky123 commented 1 year ago

Hello, I had the same issues with the Sunmi V2 model where SunmiPrinter.getPrinterStatus() always give me ERROR. I had use this package https://pub.dev/packages/sunmi_printer , and the PrinterStatus give me a NORMAL instead.

brasizza commented 1 year ago

Thanks i will check it out!

RioRocker97 commented 1 year ago

Hello, I had the same issues with the Sunmi V2 model where SunmiPrinter.getPrinterStatus() always give me ERROR. I had use this package https://pub.dev/packages/sunmi_printer , and the PrinterStatus give me a NORMAL instead.

it worked ! and i found a way to get that to be working in sunmi_printer_plus too

i replaced all aidlservice from sunmi_printer source file and

then edit some function in sunmiPrinterMethod.java,sunmiPrinterPlugin.java

that doesn't appear in replaced iWoyuService.aidl (such as cutpaper(),lcddisplay stuff function)

then i re-build my project with it and it worked !

although it still give me only 2 status : NORMAL and PREPARING whenever i try to open the printer lid or remove the paper from printer , it still show the same PREPARING status i think there maybe some status that doesn't get properly from iWoyuService.aidl (i used Sunmi V2 btw 3 )

brasizza commented 1 year ago

Hello, I had the same issues with the Sunmi V2 model where SunmiPrinter.getPrinterStatus() always give me ERROR. I had use this package https://pub.dev/packages/sunmi_printer , and the PrinterStatus give me a NORMAL instead.

it worked ! and i found a way to get that to be working in sunmi_printer_plus too

i replaced all aidlservice from sunmi_printer source file and

then edit some function in sunmiPrinterMethod.java,sunmiPrinterPlugin.java

that doesn't appear in replaced iWoyuService.aidl (such as cutpaper(),lcddisplay stuff function)

then i re-build my project with it and it worked !

although it still give me only 2 status : NORMAL and PREPARING

whenever i try to open the printer lid or remove the paper from printer , it still show the same PREPARING status

i think there maybe some status that doesn't get properly from iWoyuService.aidl

(i used Sunmi V2 btw

3

)

Hi, i would love a PR for that! Can you manage it?

RioRocker97 commented 1 year ago

Sure, just give me a couple day to finish up my work and i ll open it

palevi67 commented 10 months ago

Any updates? I'm using latest version of sunmi_printer_plus and still always getting ERROR from getPrinterStatus() ... and I need this in order to avoid printing if printer is not ready!

brasizza commented 10 months ago

Any updates? I'm using latest version of sunmi_printer_plus and still always getting ERROR from getPrinterStatus() ... and I need this in order to avoid printing if printer is not ready!

can you send me what error please?

palevi67 commented 10 months ago

I mean I always get an ERROR status when I call getPrinterStatus(), no matter if printer is open, out of paper, normal or whatever ...

palevi67 commented 10 months ago

Here is the code I use:

Future<String> getEstadoImpresora() async {
  await SunmiPrinter.bindingPrinter();
  //await SunmiPrinter.initPrinter();
  PrinterStatus ps = await SunmiPrinter.getPrinterStatus();
  return ps.toString();
}
brasizza commented 10 months ago

Here is the code I use:

Future<String> getEstadoImpresora() async {
  await SunmiPrinter.bindingPrinter();
  //await SunmiPrinter.initPrinter();
  PrinterStatus ps = await SunmiPrinter.getPrinterStatus();
  return ps.toString();
}

Didnt reply yet because i dont have the equipment. what device are you using ?

palevi67 commented 10 months ago

It's a Sunmi V2s

brasizza commented 10 months ago

I dont have this equipment, just k2 and k2 mini. I will check if i can find about this method in v2