LinuxQuestions.org
Visit Jeremy's Blog.
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, 05:01 AM   #1
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Rep: Reputation: 18
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, 05:14 AM   #2
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 18
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
 
1 members found this post helpful.
Old 05-09-2015, 08:41 AM   #3
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 18
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
 
1 members found this post helpful.
Old 05-09-2015, 09:04 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,751

Rep: Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318
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.
 
1 members found this post helpful.
Old 05-10-2015, 03:19 AM   #5
ralfbutler
Member
 
Registered: Jul 2009
Posts: 38

Original Poster
Rep: Reputation: 18
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
 
1 members found this post helpful.
Old 05-11-2015, 12:52 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,751

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

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

Rep: Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318Reputation: 6318
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 02:34 PM
Redhat server print via PC USB connected printer csmalley Linux - Newbie 9 03-12-2009 01:58 PM
Printer connected to USB host of wlan box mperez SUSE / openSUSE 0 11-15-2006 10:52 AM
cannot find usb port of my connected printer kpachopoulos Debian 1 08-10-2006 07:29 AM
Strange...can't share usb printer connected to xp pc vatman Linux - Software 2 11-02-2005 06:50 PM

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

All times are GMT -5. The time now is 06:33 PM.

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
Open Source Consulting | Domain Registration