Tag: printer

PJL ReadBack – read response from printer

This is pretty hard to do that on USB printer connected to windows. You have to have bidirectional driver for your printer and somehow read it (there is no that option in win32 printing). There is no bidirectional windows drivers for most of printers.

It is much easier to ReadBack from printer connected to network. You can do that with simple app called PCL Paraphernalia
http://www.pclparaphernalia.eu/index.html

ReadBack from USB printer on Linux is possible! Printer is installed as a character device (you can read and write to it).

Some tips:

  • After read printer send to them ESCAPE character. If not, next send and work will not work.
    echo -e "\e" > /dev/usb/lp0
  • My printer does not respond nothing for @PJL INQUIRE *_* – no respond from printer for variables with underscore example: @PJL INQUIRE TOTALPAGE_LMT (probably total page limit) and others:
    ONLYFOR_PANEL
    TOTALPAGE_LMT
    COUNTPAGEPF1_LMT
    COUNTPAGEPFM_LMT
    A4PAGES_LMT
    LEGALPAGES_LMT
    JISB5PAGES_LMT
    A5PAGES_LMT
    A6PAGES_LMT
    MONARCPAGES_LMT
    PLAINPAGES_LMT
    THICKPAGES_LMT
    ENVELOPESPAGES_LMT
    POSTCARDPAGES_LMT
    LABELPAGES_LMT
  • You can try to check device is busy but it not work correctly. You should do the command in loop until you read more than zero length reponse (or set timeout in looop to next try)
    while true
            do
               fuser -s /dev/usb/lp0
               if [ $? -ne 0 ]
               then
                  break
               fi
    done
  • Send PJL:
    echo -e "\e%-12345X@PJL\r\n@PJL INFO ID \r\n\e%-12345X" > /dev/usb/lp0
  • Read PJL – I do not know when you should read and when the response is ready. So i try to read in loop or few cat commands, read or dd.
    #1way
    response=$(dd if=/dev/usb/lp0 of=temp.txt 2>&1)
    echo "$response"
    echo -e "\e" > /dev/usb/lp0
     
    #2way
    while IFS= read -r -n1 char
    do
     printf "$char"
    done < /dev/usb/lp0 echo -e "\e" > /dev/usb/lp0
     
    #3way
    cat /dev/usb/lp0
    echo -e "\e" > /dev/usb/lp0
  • Example script to read the printer ID:
    #!/bin/bash
     
    PRINTER=/dev/usb/lp0
    ESCAPE=$(echo -e "\e")
    FF=$(echo -e "\x0C")
    char=""
    IFS=""
    echo "" > temp.txt
     
    	while true
    	do
    		sleep 0.5
    		#WAIT FOR NOT BUSY
    		while true
    		do
    			fuser -s "$PRINTER"
    			if [ $? -ne 0 ]
    			then
    				break
    			fi
    		done
    		#send PJL to printer
    		echo -e "\e%-12345X@PJL\r\n@PJL INFO ID \r\n\e%-12345X" > "$PRINTER" 
    		#TRY TO READ IMMEDIATELY
    		char=$(dd if="$PRINTER" of=temp.txt 2>&1)
    		echo -e "\e" > "$PRINTER"
    		#CHECK THAT dd READ ANY BYTES
    		echo "$char" | grep "bytes copied" > /dev/null
    		if [ $? -ne 0 ]
    		then
    			printf "."
    		else
    			echo "$char" | grep "^0 bytes copied" > /dev/null
    			if [ $? -ne 0 ]
    			then
    				cat temp.txt
    				echo "" > temp.txt
    				break
    			else
    				printf "."
    			fi
    		fi
    		char=""
    	done

    the response:
    @PJL INFO ID
    "Brother HL-1110 series:84UE03:Ver1.08"

PJL – send commands to printer in RAW, BIN file

Printer Job Language (PJL) – that’s a script language to communicate with printer. Every manufacturer has its own commands. There is a few standarized KERNEL commands.

I will describe how to send commands to printer in Windows. I will write all examples based on brother printers because HP has better documentation.

You can include PCL and other languages in PJL files. Just use ENTER PJL command with supported language.

Special characters – you can write it with ALT + CODE where code for <ESC> is 27. If you do not have numpad you should use hex editor like HxD. You can’t send literally <ESC> it has to be 1B in binary hex. In notepad++ it should be like:

LF and CR is just enter in text editor (check editor settings!). In PJL use always: <CR><LF> because printers should ignore all that can’t recognize (f.ex. CR – windows end line).

<HT>Horizontal Tab
ASCII 9 HEX 09
ALT + 9
<LF>Line Feed
ASCII 10 HEX 0A
ALT + 10 or Enter
<CR>Carirage Return
ASCII 13 HEX 0D
ALT + 13 or Enter
<SP>Space
ASCII 32 HEX 20
ALT + 32 or Space
<ESC>Escape
ASCII 27 HEX 1B
ALT + 27
<FF>Form Feed
ASCII 12 HEX 0C
ALT+12
<WS>White Spaceadd some spaces or horizontal tabs with the CRLF at the end of line

There is a bin file with these characters: pjl-chars

PJL Info

To run PJL commands you have to prepare file and send it in RAW format to printer. Use only capital letters. You can edit it with Notepad++. For HEX editint use HxD.

Universal format for example PJL:
<ESC>%-12345X@PJL
@PJL EXECUTE command
<ESC>%-12345X
Bin RAW download example: pjl-example

Test PJL Support

You can test that your printer support PJL. Send to the printer:
<ESC>%-12345X@PJL
@PJL EXECUTE MAINTENANCEPRINT
@PJL EXECUTE TESTPRINT
@PJL EXECUTE DEMOPAGE
@PJL EXECUTE RESIFONT
@PJL EXECUTE PERMFONT
@PJL EXECUTE PRTCONFIG
<ESC>%-12345X

Download test: test-pjl

Printer should print some test pages.
If print %-12345X@PJL[...] you have send it in wrong way! (as text no RAW binary file)

Run PJL on Local Printer

To send RAW file to local printer connected via USB, LPT you can use freeware program: PrintFile
http://www.lerup.com/printfile/

Works on x64 and x86 windows (Windows 10 too).

  1. Download and install
  2. Run PrintFile as admin
  3. Click Settings, choose on the bottom your printer and click Save
  4. Click PrintFile and choose your prepared file. The receiving LED or LCD should say Rece3iving Data (for one second if it is small file).

Run PJL on Network or Local Printer

First run CMD as admin. Change directory to directory with pjl files. Disable firewall for a while.

If your printer is local (USB or LPT) you can make it Network by just sharing the Printer in Windows (set simple name – one word). Then you can run commands to send PJL RAW files in CMD:
copy /b test.pjl  \\%COMPUTERNAME%\PrinterSharedName
or
type test.pjl > \\%COMPUTERNAME%\PrinterSharedName

You can map network printer to LPT port if you need:
NET USE LPT1: \\%COMPUTERNAME%\PrinterSharedName
persistent:
NET USE LPT1: \\%COMPUTERNAME%\PrinterSharedName /PERSISTENT:YES

If you will install  in windows additions (Programs and functions) LPR and LPD service you can use:
lpr -S %COMPUTERNAME% -P PrinterSharedName "-o l" test.pjl
or to the network printer (check the printer working with RAW or something else):
lpr -S 192.168.1.x -P raw "-o l" test.pjl

Receive the response

I do not know how to receive response PJL. I can’t read any output.
There is post how to read PJL responses from printer connected to USB and network devices:PJL ReadBack – read response from printer
For example command:
<ESC>%-12345X@PJL <CR><LF>
@PJL INFO ID <CR><LF>
<ESC>%-12345X
printer should response something like:
<ESC>%-12345X@PJL <CR><LF>
@PJL INFO ID <CR><LF>
ID=Brother HL-1660e
<ESC>%-12345X

 

PJL Documentations:
Brother:
https://www.brother.com.au/pdf/support/controlcodes/PCL_Tech_Manual.pdf

Download (PDF, 9KB)

HP:
http://h10032.www1.hp.com/ctg/Manual/bpl13208.pdf

Download (PDF, 2.86MB)

Brother firmware upgrade on MFC-L2700DW

I will show you some tips how to update firmware in Brother printers. You have to be sure that you have correct firmware file. If the headers are correct printer will flash no matter what do you send (i think so :). There is no checksum, only size control?

I will try to find how to enter service mode in this printer, the header should be a clue:

Flash file is the same that is downloaded by printer in web panel or with tool to upgrade on computer.

Flashing printer in network

Requirements:

  1. firmware file: LZ5094_L[1].djf
    http://www.mediafire.com/file/a3p9a5otccys6u9/LZ5094_L%5B1%5D.djf.zip
    Same file with changed extension to bin:
    http://www.mediafire.com/file/ibbelr09l6bmv1f/MFC-L2700DW.bin.zip
  2. BRAdmin Lite: 10/11/2016 (1.29.0000)
    http://support.brother.com/g/b/downloadend.aspx?c=us_ot&lang=en&prod=mfcl2700dw_us_eu_as&os=10013&dlid=dlf005040_000&flang=4&type3=284
    or BRAdmin Professional:
    http://support.brother.com/g/b/downloadend.aspx?c=us_ot&lang=en&prod=mfcl2700dw_us_eu_as&os=10013&dlid=dlf005042_000&flang=4&type3=26
  3. I have tested on EU versions printers, probably all firmwares are the same only mainboard has set regional settings in service menu.

Upgrade process:

  1. Download firmware and BRAadmin. Install BRAdmin.
  2. Connect your printer to network, turn it on. Do not send any printing,scan or other task.
  3. Rename .djf extension to .dat or .bin or any other. If you do not do that, BRAdmin won’t accept the file:
  4. Run BRAdmin. Right click on you printer and click Send file and choose .dat or .bin file:
  5. Wait for complete:
  6. Now on your printer LCD you should see

    Firmware Upgrade

  7. Wait about 20 minutes to printer finish the process (copy,scan,fax LEDs will blinking)

Flashing printer at USB

Sorry, I will try it later because I do not have USB connected printer. But BRPrint Auditor should make possible to see USB connected printer in BRAdmin:
http://support.brother.com/g/s/id/common_download/en/auditor_pro3.html?c=us_ot&lang=en&redirect=on