LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-28-2020, 09:58 AM   #1
Sembrador
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
Where I can a good and practical tutorial for write a serial or USB printer driver for linux


Hi, I need to write a device driver for a serial printer for linux to send data from lets say PHP program as an example.

I already see this:

I know this development must be do it in C (I already knows)

But I have to see something more specific.

I will appreciate someone points me to the right path.

Thanks in advanced.
 
Old 02-28-2020, 10:10 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Did you try this? Are any of those articles helpful?
 
Old 02-28-2020, 11:08 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,734

Rep: Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920
Welcome to LinuxQuestions.

Quote:
I need to write a device driver for a serial or USB printer driver for linux
What make/model of printer you planning on using? If the USB printer is using a serial port and your just connecting it using a USB serial port adapter then its basically the same thing. If it is a true USB printer then the two are completely different.

More then likely the serial printer will use some sort of printer emulation and mostly likely you could use an existing printer. It also depends on how your using the printer. With most serial printers you can write ASCII characters directly to the serial port and by sending control codes can format the text without needing a special driver.

A USB printer can be a lot more complicated and will wait until we know the printer your actually planning on using.
 
Old 02-28-2020, 12:44 PM   #4
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
The Linux kernel already has the plumbing to send bytes to serial and USB printers. A USB printer will show up as /dev/usb/lp0.

You need to determine the language that your printer speaks. The better document printers speak Postscript. Inexpensive printers speak languages like PCL or Epson's ESC codes.

Fortunately, Ghostscript contains user-mode drivers for many of the latter kind of printers.

If that works, all your application needs to do is to output Postscript. This is the best solution.

If you are using an oddball printer, your application will need to generate device-specific control codes and write them to the device. I have done that for an Epson printer that was too ancient for Ghostscript.
Ed
 
  


Reply



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
LXer: Linux C Programming Tutorial Part 14 - Bitwise operators practical examples LXer Syndicated Linux News 0 03-21-2019 10:03 PM
LXer: UNIX / Linux du Command Tutorial with Practical Examples LXer Syndicated Linux News 0 08-06-2013 10:00 AM
LXer: Linux/UNIX Tar Command Tutorial with Practical Examples LXer Syndicated Linux News 0 05-06-2013 03:00 PM
LXer: Tutorial: How to Write a Tutorial LXer Syndicated Linux News 0 08-01-2008 06:41 AM
LXer: Tutorial: The Penguin's Practical Network Troubleshooting Guide LXer Syndicated Linux News 0 06-08-2006 03:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:10 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
Open Source Consulting | Domain Registration