detecting media type using CPCL on QLn

// Expert user has replied.
A Asheesh Chowdhary 3 years ago
144 1 0

Hi,
 
Is it possible to send the media type required for the print job as part of the CPCL commands to a QLn ?  What we are trying to achieve is if the user has loaded labels in the printer, and we are expecting to print a receipt, we would like the LCD on the printer to display an error, and then when the user changes the media, the printer will print the receipt.
 
If this is not possible, is it possible to query the QLn for the media type currently loaded in the printer ?
 
Thanks
Regards,
Asheesh

Please register or login to post a reply

1 Replies

S Samantha Corn

Hi Asheesh,

There are three CPCL commands for changing the media type in the printer: BAR-SENSE, GAP-SENSE, and JOURNAL​.

Please note, if the QLn has continuous media loaded but is set to noncontinuous (gap or bar), then it will attempt to print, but will feed trying to find a gap or mark. After feeding, it will display an out of media error on the LCD screen, which is similar to the behavior you are trying to achieve. The issue for your use case is if the QLn has labels loaded but is set to continuous media, the printer will not detect an error and will just print over multiple labels.

It is not possible to query what media type the printer is set to using CPCL, but there is a SGD command (see page 722 of the ZPL Programming Guide):

! U1 getvar "ezpl.media_type"

You can set the media type using the same SGD command:

! U1 setvar "ezpl.media_type" "value"

where "value" can be "gap/notch", "mark", or "continuous".

For your use case, you might consider setting the printer to calibrate the media sensors whenever the media door is closed instead of setting the media type. Then you can programmatically check the media type before sending the print job to the printer and give an error in the program instead of relying on the printer to do so.

To set the printer to automatically calibrate the media when the media door is shut, use this SGD command (page 718 of the ZPL Programming Guide):

! U1 setvar "ezpl.head_close_action" "calibrate"

CONTACT
Can’t find what you’re looking for?