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

How to know which device supports Zpl or CPCL? #18

Open
MohsinIkram-Auxilium opened this issue Apr 26, 2023 · 5 comments
Open

How to know which device supports Zpl or CPCL? #18

MohsinIkram-Auxilium opened this issue Apr 26, 2023 · 5 comments

Comments

@MohsinIkram-Auxilium
Copy link

Hi,
I have both Zebra Printing Devices which support ZPL and CPCL Languages.
So I want to distinguish between both devices.
I have reviewed your code, you are writing this in everywhere in your code -> ZebraPrinterFactory.getInstance(printerConnection)
If I define printer with this line -> printer = ZebraPrinterFactory.getInstance(printerConnection)
It always give me ZPL language.
But if I write this line -> printer = ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL,printerConnection)
It always return me CPCL language.
Kind give me best answer. I'm looking for your response.
Thanks

@ssizebra
Copy link
Collaborator

ssizebra commented Apr 26, 2023

A printer can only support CPCL or ZPL at a time. It cannot support both CPCL & ZPL at the same time. The setting of the device.languages on the printer determines which label format language the printer is going to support. The application can switch the label format language at run time with the device.languages SGD (! U1 setvar "device.languages" "zpl", or ! U1 setvar "device.languages" "cpcl"). The application can also query the languages setting with the device.languages SGD (! U1 getvar "device.languages"). Once the device.languages setting on the printer is known, the application can call the getInstance() with the proper parameter, i.e., either ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL,printerConnection) for CPCL printer instance, or ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL,printerConnection) for ZPL printer instance. Calling ZebraPrinterFactory.getInstance(printerConnection) usually defaults to ZPL instance.

@MohsinIkram-Auxilium
Copy link
Author

@ssizebra Sorry for misunderstanding, I was saying I have two devices. One device supports ZPL and other device (ZQ210) supports CPCL Language.
My scenario is I'm showing both devices in Bottom Sheet. Now how I want to know which device support ZPL or CPCL Language. So when I click on any device, I will run code according to that.
So kindly if you have proper code then please send or guide me how can I distinguish between both.

@ssizebra
Copy link
Collaborator

As mentioned early, we can use the device.languages SGD to query the printer's language as below.

printerConnection.Open();
string ptrLangStr = SGD.GET("device.languages", printerConnection);

If the ptrLangStr contains "cpcl" or "line_print", then the printer's language is set as CPCL. If the ptrLangStr contains "zpl", then the printer is in ZPL. Then we can create the proper printer instance with the correct language parameter.

@MohsinIkram-Auxilium
Copy link
Author

@ssizebra Thanks a lot its really helpful.

@MohsinIkram-Auxilium
Copy link
Author

@ssizebra can you please tell me how can I show all the connected zebra printers list in my app?
Right now I'm implementing an logic but it shows all the connected Bluetooth devices with other devices as well.
I just only want to show the Zebra Printers?
Please guide me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants