PDA

View Full Version : [SOLVED] How to get printer name attached through LPT or serial Port?



Gurmeet Singh
April 20th, 2012, 11:25 AM
Hi Experts,

How i can get the printer description which has been attached through LPT or Serial port?
I am able to get same information when attached with usb using lsusb and now i want to get the same info when attached through LPT or serial.

In case of MS Windows, When attached printer (PNP enabled and on LPT port) switched on then a ballon is displaying at right bottom of screen showing name of printer also i can get all the information from windows registry at path HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\LPTEN UM\NameofPrinter.

Please guide me how i can get same in ubuntu.

Thanks,
Gurmeet Singh

albandy
April 20th, 2012, 12:02 PM
sudo hwinfo --printer

Gurmeet Singh
April 20th, 2012, 01:31 PM
Thanks albandy.

I want to use any inbuilt command or tool which is coming with Ubuntu distribution.

Can i get the printer information from a C/C++ program like name, id etc attached through LPT port.

Thanks in advance.

CynicRus
April 20th, 2012, 02:04 PM
In my opinion, you can read "/dev/lp0" or "/dev/ports" and get needed information manually.

albandy
April 20th, 2012, 02:54 PM
I don't know but you can check hwinfo source code. I remember that in C exists the system instruction to launch system commands.

CynicRus
April 20th, 2012, 08:36 PM
For launching system command in C function system() is used

Gurmeet Singh
April 21st, 2012, 08:23 AM
Thanks all for your valuable response.


In my opinion, you can read "/dev/lp0" or "/dev/ports" and get needed information manually.

When i am trying to read the /dev/lp0, i am getting permission error.
How i can read the /dev/lp0 in my c/c++ program?

Thanks.

CynicRus
April 23rd, 2012, 06:30 AM
http://koders.com/c/fidC2E4C7C1EE64182E91E95E853281CCAB37D8BDD8.aspx?s =%2fdev%2flp0#L40 - just read this source.

Gurmeet Singh
April 23rd, 2012, 10:21 AM
Thanks CynicRus.

I have seen the code and understood little bit.

Can i use the method given in below link instead?

https://wiki.ubuntu.com/DebuggingPrintingProblems#Parallel_port_printer


Thanks in advance.

CynicRus
April 23rd, 2012, 07:36 PM
You can for everyone. The main thing after all that work. Using basic tools Unix - this is Unix way. You can manually read / dev/lp0, or can call cat /dev/lp0 - this is the same. Just in the first case - a chance to make mistakes much more.

Gurmeet Singh
May 3rd, 2012, 12:35 PM
Thanks.