LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Printer parallel port problem (https://www.linuxquestions.org/questions/linux-newbie-8/printer-parallel-port-problem-4175646070/)

31416 01-12-2019 12:22 PM

Printer parallel port problem
 
Hello,
I am new to Linux so I have a lot of doubts every time I want to do anything. Linxquestions.org has been of great help to solve many ot these doubts. Therefore I would like to begin my post by writing a big thanks to all the contributors here.
Now I am stuck with the following problem.
System debian 4.4.5-8. (I know is very old but is used in a industrial pc with an specific program and I cannot update it)
I want to print a file by sending it directly to the printer by using the command cat.
Printer is connected to the parallel port and is a small lable printer model micra.

When I type
cat Eti.prn > /dev/lp0
The prompt blinks and nothing happens. I have to type ctrl C to be able to type more commands.
If I send the file from the terminal where the industrial program is running the printer prints the label perfectly well therefore I disregard any problem related to cables, printer settings or syntax in the file.
I have checked permissions and are as follows:

crw-rw---- 1 root lp 6, 0 jan 11 14:03 /dev/lp0 ( /dev/lp0 in yellow )
I log in as root

I would like to understand why is not working command cat so any hints to troubleshoot this will be welcome.

ferrari 01-12-2019 07:09 PM

Welcome to LinuxQuestions.org. First question - Are you sure that /dev/lp0 is the correct device node for communicating with the printer?

31416 01-13-2019 04:35 AM

Thank you for answering.
No. I’m not sure.
In /dev Only find lp0 and parport0 as possible names for the parallel port.
How could I find it for sure?
Please note that I am really new to linux so maybe I am missing very elementary things!

ehartman 01-13-2019 05:03 AM

Quote:

Originally Posted by 31416 (Post 5948199)
cat Eti.prn > /dev/lp0
The prompt blinks and nothing happens. I have to type ctrl C to be able to type more commands.
If I send the file from the terminal where the industrial program is running the printer prints the label perfectly well therefore I disregard any problem related to cables, printer settings or syntax in the file.
I have checked permissions and are as follows:

crw-rw---- 1 root lp 6, 0 jan 11 14:03 /dev/lp0 ( /dev/lp0 in yellow )
I log in as root

Normally the printer port (and the parallel port too) are owned exclusively by the printer subsystem (most often CUPS - the Common Unix Printing System) which runs under group "lp", which has a writing permission TO the /dev/lp0 device.
When CUPS has been setup correctly you print by using the command lp (or optionally lpr) instead of accessing the printer directly. See the man page, but what does
Code:

lp Eti.prn
do?
It could also be possible that your industrial program contains its own printing subsystem and has an exclusive lock ON the device file.

31416 01-14-2019 02:06 AM

Quote:

Originally Posted by ehartman (Post 5948435)
Normally the printer port (and the parallel port too) are owned exclusively by the printer subsystem (most often CUPS - the Common Unix Printing System) which runs under group "lp", which has a writing permission TO the /dev/lp0 device.
When CUPS has been setup correctly you print by using the command lp (or optionally lpr) instead of accessing the printer directly. See the man page, but what does
Code:

lp Eti.prn
do?

it gives:
-bash: lpr: command not found
or
-bash: lp: command not found

does this means that CUPS is not installed?

Quote:

It could also be possible that your industrial program contains its own printing subsystem and has an exclusive lock ON the device file.
Is there any way to know this for sure?

ferrari 01-14-2019 02:16 AM

Check /var/spool/lpd. Is there a lock file? (eg lpd.lock)

ferrari 01-14-2019 02:20 AM

Quote:

it gives:
-bash: lpr: command not found
or
-bash: lp: command not found

does this means that CUPS is not installed?
Yes, it may well be that CUPS is not installed. These utilities are part of 'cups-client'. I guess the legacy application is just writing to the device node directly perhaps.

31416 01-14-2019 02:38 AM

Quote:

Originally Posted by ferrari (Post 5948828)
Check /var/spool/lpd. Is there a lock file? (eg lpd.lock)

There is not such a directory.
ls /var gives:
log run

ferrari 01-14-2019 02:49 AM

Then I guess we can exclude the device file lock (unless there's something I'm missing here).

You mentioned
Quote:

Code:

cat Eti.prn > /dev/lp0
The prompt blinks and nothing happens. I have to type ctrl C to be able to type more commands.
Is the .prn file valid? I can only speculate here, but perhaps it is missing some essential formatting codes, or is incomplete in some other way? (We can only take your word for this of course.)

A long shot, but is the printer enumerated via the following?
Code:

cat /proc/sys/dev/parport/parport*/autoprobe*

ferrari 01-14-2019 03:17 AM

I forgot that you had mentioned that when the file is sent via the application, it prints ok. I'm speculating that perhaps it sends a command to actually invoke the printing. You may be able to examine the file (hex editor?), and perhaps check the commands contained in it. Do you have access to a user manual (with label printer commands) for the printer in question?

31416 01-14-2019 04:03 AM

Quote:

Originally Posted by ferrari (Post 5948838)

Is the .prn file valid? I can only speculate here, but perhaps it is missing some essential formatting codes, or is incomplete in some other way? (We can only take your word for this of course.)

A long shot, but is the printer enumerated via the following?
Code:

cat /proc/sys/dev/parport/parport*/autoprobe*

Under /proc/sys/dev/parport/parport0/ there are autoprobe, autoprobe0, autoprobe1 … autoprobe3 all of them seems to be empty. when doing
Code:

cat /proc/sys/dev/parport/parport*/autoprobe*
nothing happens.


Quote:

Originally Posted by ferrari (Post 5948838)

Is the .prn file valid? I can only speculate here, but perhaps it is missing some essential formatting codes, or is incomplete in some other way? (We can only take your word for this of course.)

I think the .prn is valid. It is generated by the editor software of the printer manufacturer. Furthermore, when I send the file via the industrial program, it prints. In order to do this before I use the .prn file from the industrial program I need to edit it by changing the file name, adding a header and a eof sign and a text in front of each line. This is a requirement from the industrial program and this way you can use any file from any printer manufacturer.

Quote:

I forgot that you had mentioned that when the file is sent via the application, it prints ok. I'm speculating that perhaps it sends a command to actually invoke the printing. You may be able to examine the file (hex editor?), and perhaps check the commands contained in it. Do you have access to a user manual (with label printer commands) for the printer in question?
Yes I have access to the manual and I can edit via notepad ++ the file. As stated before, the file is generated by the printer´s manufacturer editing software.
I´ve checked the .prn file opening it in notepad ++ and seems to follow all the rules the manual indicates.

31416 01-14-2019 09:40 AM

Just to make sure the file Eti.prn is ok, I used al old pc with xp and parallel port and from DOS
Code:

copy eti.prn lpt1:
prints the label.
Therefore, I am sure the printer understands Eti.prn

michaelk 01-14-2019 10:38 AM

My parallel port printers died many years ago and I don't remember where I put my parallel port loop back connector so I can't confirm if everything still works anymore. However, just as a frame of reference the same thing happens when I try catting a file to an unconnected printer port i.e the command "hangs" until I cancel via ctrl-c. All my autoprobe are empty too but the irq is 7 which is valid for lp0 and the devices sub directory does contain active.

Do you have more then one printer port on your industrial computer? Are you sure you are using the correct printer device?

31416 01-14-2019 11:13 AM

Quote:

Originally Posted by michaelk (Post 5948973)
Do you have more then one printer port on your industrial computer?

Hello, thanks for answering
The computer has only one physical parallel port. Besides, there are serial ports, usb ports, ...
Quote:

Are you sure you are using the correct printer device?
I don’t know what are you refering to by “using the correct printer device”. I do know the printer is connected to the external physical parallel centronics connector. From what I read it is supposed to be refered in Linux as lp0. I don’t know much more than that.
By the way, I cat to /dev/lp0 Could it be possible that this parallel connector appears in linux in any other directory ?
For me it is important to learn how the printing process works and how to troubleshoot it.

ferrari 01-14-2019 11:39 AM

Quote:

By the way, I cat to /dev/lp0 Could it be possible that this parallel connector appears in linux in any other directory ?
For me it is important to learn how the printing process works and how to troubleshoot it.
Some typical diagnostic approaches you could do

1) Examine kernel outut relating to a parport or similar...
Code:

dmesg ¦ grep par
Code:

dmesg| egrep "par|lp"
2) Examine the kernel's device tree in /proc/sys/dev/parport....
Code:

ls -l /proc/sys/dev/parport/parport*/autoprobe*
Which is why I suggested probing for printer hardware already with
Code:

cat /proc/sys/dev/parport/parport*/autoprobe*
or
Code:

sudo cat /proc/sys/dev/parport/parport*/autoprobe*
3) Finally if you had CUPS or even lprng (minimal *nix-style printing system) installed, you could could make use of lpinfo to see if a printer is detected with
Code:

lpinfo -v


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