LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-09-2015, 06:01 AM   #1
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Rep: Reputation: 15
ESC/P commands via terminal to USB connected matrix printer


Hello,

I added an Epson dot-matrix printer to my Ubuntu based system. The printer is connected via USB.
Code:
printf "Hello World!" | lpr
works fine, as well
Code:
echo -e "test" | lpr -o raw
But now I'd like to send some ESC/P commands to the printer. My preference would be to simply create a file with all ESC/P commands required and to just cat and pipe the file to lpr.

However, I got stuck on how those escape commands should look like. For test purposes I used the terminal and tried
Code:
echo -e "\x1B 3" | lpr -o raw
which clearly had an effect on space between characters. But when I try to reset the settings with
Code:
echo -e "\x1B @" | lpr -o raw
the space between characters on test printouts remains.

Would be great if someone has an example how he/she communicates with the printer via esc/p commands in Linux.

Thanks,
Ralf
 
Old 05-09-2015, 06:14 AM   #2
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 15
Ok,
Code:
echo -e "\x1B\x40" | lpr -o raw
initialises the printer.

Then I place all commands into one testfile and print it:
Code:
echo -e "$(cat testfile)" | lpr
Hope that is useful for anyone.
Ralf
 
Old 05-09-2015, 09:41 AM   #3
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 15
Hello again,

This question goes out to all of those who are familiar with ESC/P commands. I use an Epson PLQ 20 dot matrix printer and I want to specify absolute horizontal position:
Code:
\x1B\x28\x55\x01\x00\x0A
\x1B\x5C\x01\xF3
But unfortunately the printer starts printing from the far left. This is the complete code:
Code:
#Init
\x1B\x40
#Choose OCR-B
\x1B\x6B\x05
#Set unit
\x1B\x28\x55\x01\x00\x0A
#Set horizontal position
\x1B\x5C\x30\x05
test
I understand that this is not a Linux related question. But I couldn't find a forum for ESC/P commands and from recent post in LinuxQuestions are a few people that know something about ESC/P commands.

Thanks,
Ralf
 
Old 05-09-2015, 10:04 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,423

Rep: Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103
According to this reference https://files.support.epson.com/pdf/...l/escp2ref.pdf 1B 24 is absolute and 1B 5C is relative horizontal position commands.
 
Old 05-10-2015, 04:19 AM   #5
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 15
Hi michaelk,

Thanks for the super quick reply! Indeed x5C is for relative position. But even if I choose x24 for absolute position I cannot see any change in position.

I would much appreciate if someone could help me.

Thanks,
Ralf
 
Old 05-11-2015, 01:52 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,423

Rep: Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103
The absolute position command might not be available for your printer.
 
Old 05-12-2015, 10:07 PM   #7
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks Michael, I did solve the problem, by switching the printer off and on again :-/
 
Old 05-12-2015, 10:35 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,423

Rep: Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103
Great. If all else fails...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Low Level commands (embedded Linux, terminal commands) JonCombat Linux - Newbie 2 01-05-2013 03:34 PM
Redhat server print via PC USB connected printer csmalley Linux - Newbie 9 03-12-2009 02:58 PM
Printer connected to USB host of wlan box mperez SUSE / openSUSE 0 11-15-2006 11:52 AM
cannot find usb port of my connected printer kpachopoulos Debian 1 08-10-2006 08:29 AM
Strange...can't share usb printer connected to xp pc vatman Linux - Software 2 11-02-2005 07:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration