Is it possible to use the online/offline switch to choose between two printer types?

Post Reply
keenerb
Posts: 23
Joined: Sun Sep 10, 2023 12:34 am

Is it possible to use the online/offline switch to choose between two printer types?

Post by keenerb »

I'd like to emulate an Epson ESC/P and a PCL printer at times, and don't really have much use for an online/offline switch.

Would it be possible to repurpose that switch? Is it tied to GPIO pins and the app? OPEN = HP emulation, CLOSED = Epson emulation?

On a related note, is it theoretically possible to auto-detect the escape code set used and automatically process PCL output and ESC/P output by examining the raw file?
RWAP
Site Admin
Posts: 405
Joined: Wed Sep 13, 2017 9:20 pm
Location: Oswestry, Shropshire
Contact:

Re: Is it possible to use the online/offline switch to choose between two printer types?

Post by RWAP »

keenerb wrote: Wed Sep 13, 2023 7:16 pm I'd like to emulate an Epson ESC/P and a PCL printer at times, and don't really have much use for an online/offline switch.

Would it be possible to repurpose that switch? Is it tied to GPIO pins and the app? OPEN = HP emulation, CLOSED = Epson emulation?
This could be done, but would need a change to the standard code. It would take quite a bit of thought and programming as the emulators are independent programs launched only once on startup - so at what point do we end the EPSON emulator and launch the HP emulator - only when starting up or once conversion of a print job has been completed ?

The other issue is the number of printers we currently emulate is much more than just HP and EPSON - I guess you could have another configuration option specifying which emulators would be switched between (maybe a different setting in the offline_switch parameter).

A good idea a though - we just need to thrash out the details.
On a related note, is it theoretically possible to auto-detect the escape code set used and automatically process PCL output and ESC/P output by examining the raw file?
Not easily no - as the start sequence of printer control codes is not standard across software/equipment it is hard to know what you would look for to differentiate between the various printer emulations.

The main issue is that a printout could consist of many lines (or pages) of plain text before it includes the first control code sequence (eg to select BOLD or ITALICS, or insert a graphic). So you would need to first parse all of the incoming data before you could even make a guess at what printer needed to be emulated.
Retro-Printer Specialists
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module

Also Involved in:
Icephorm
keenerb
Posts: 23
Joined: Sun Sep 10, 2023 12:34 am

Re: Is it possible to use the online/offline switch to choose between two printer types?

Post by keenerb »

I actually found an old programmable keypad laying around I repurposed for a printer control panel. I enabled the console autologin for the pi account, and created a handful of scripts like:

swapepson.sh
echo Epson > /root/config/emulation
service retroprinter --full-restart

and

swaphp.sh:
echo HP > /root/config/emulation
service retroprinter --full-restart

and defined the buttons to simply send "sudo /home/pi/swapepson.sh" and "swaphp.sh" to the auto logged in PI user.

Third button prints last created PDF to default printer by default, OR reboots raspberry pi if I press it twice within five seconds:

REBOOTFILE=/home/pi/reboot
if test -f "$REBOOTFILE"; then
rm $REBOOTFILE
reboot
else
touch $REBOOTFILE
filename=`ls -Art /home/pi/data/pdf | tail -n 1`
sleep 5s
echo "lp /home/pi/data/pdf/$filename"
rm $REBOOTFILE
fi

Macro command for that button is "/home/pi/printsh &" and seems to work really well.

For home use having an unsecured local login prompt on a machine with no monitor and no keyboard isn't much of a concern but it might bother some people.
retroprinter.jpg
retroprinter.jpg (133.41 KiB) Viewed 2025 times
RWAP
Site Admin
Posts: 405
Joined: Wed Sep 13, 2017 9:20 pm
Location: Oswestry, Shropshire
Contact:

Re: Is it possible to use the online/offline switch to choose between two printer types?

Post by RWAP »

There is now an updated version of the Retro-Printer software which allows you to switch between emulation modes:

The updated files can be downloaded from:
https://www.dropbox.com/scl/fi/z9bpvphp ... 39u5m&dl=0

Unzip that file on your Windows PC then use Bitvise SSH to connect to the Retro-Printer.

In the terminal console enter:

cd /home/pi/temp/sdl/escparser

./retroprinter-stop.sh

Then upload all of the zipped files to the folder /home/pi/temp/sdl/escparser

You should then just be able to use:
./retroprinter-restart.sh

To restart the retro-printer.

To enable switching, change the /root/config/offline_switch
Change this from Yes to

HP,Epson

(for example to switch between HP (ON) and Epson ESC/P2 (OFF).
Retro-Printer Specialists
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module

Also Involved in:
Icephorm
keenerb
Posts: 23
Joined: Sun Sep 10, 2023 12:34 am

Re: Is it possible to use the online/offline switch to choose between two printer types?

Post by keenerb »

I just saw this reply. I"ll try it out immediately, this will be very useful!
Post Reply