# Can't cat to ulpt0 ? HP-1020 usb printer.



## jwdevel (Dec 2, 2012)

Hi,

I haven't really set up printing on FreeBSD before, so I may be missing something simple. Any help appreciated!

I have a HP-1020 USB printer. When I attach it to my FreeBSD 9 system, I see in dmesg:


```
ulpt0: <Hewlett-Packard HP LaserJet 1020, class 0/0, rev 2.00/1.00, addr 2> on usbus3
ulpt0: using bi-directional mode
```

That all seems fine as far as I can tell.

I also have a 'raw printer' share set up in samba. When I print from Windows (which has a HP-1020 driver), it sends a printer-ready file into samba's spool.

For example, when I print from Windows, it might create the file:


```
/var/spool/samba/smbprn.00000007.hVEF9i
```

I have confirmed that this file is in the expected format - its first 4 bytes are 'JZJZ', which indicates a ZjStream document, the wire protocol this printer understands.

Now, if I understand this correctly, I just need to send this file to the printer, nothing fancy. I am not trying to print from FreeBSD or any other unix machine. I do not need or want CUPS or anything else like that. I just want to send some already-prepared data straight to my printer.

So I try:


```
# cat /var/spool/samba/smbprn.00000007.hVEF9i > /dev/ulpt0
```

It takes a moment before completing, but the printer does nothing.

The same happens if I use '/dev/unlpt0'.

Shouldn't this just work?
Any ideas as to what might be going wrong, here?

I know about (but have not used, yet) foo2zjs and HPLIP, but from my reading those seem to exist for the purpose of converting normal documents into the format the printer understands. If I print from Windows, its driver already does the hard part, so I don't think I should need them...

Thanks for any help
-John


----------



## wblock@ (Dec 2, 2012)

As a test, print to a file on the Windows system, copy that to the FreeBSD system, and manually cat it to /dev/unlpt0.  If it works, the problem is with lpd(8), possibly a filter.  If it doesn't print, the printer may need some initialization code sent to it at startup or before each print job.

An even better test is to connect the printer to the Windows system and try to print that file there.  See http://answers.microsoft.com/en-us/...-windows/cc20646f-686c-4b45-9495-1d833b0f5fda.


----------



## jwdevel (Dec 2, 2012)

I did a 'print to file' on windows (oddly, the printer had to be plugged in or the printing program would hang...), and it produced a binary identical file to the one that shows up in the samba spool.

Haven't tried copying to LPT1 on Windows, yet...


----------



## jwdevel (Dec 5, 2012)

I got this figured out!

This particular model of printer needs to have special firmware loaded onto it before it will work in a unix environment.

The firmware can be obtained from the foo2zjs project, though it's originally from HP itself. I wasn't interested in installing CUPS, so had to find the firmware file (sihp1020.img) and convert it to the right format, using foo2zjs' "arm2hpdl" utility.

The rest followed the advice on this site: http://menhennitt.com.au/wordpress/...et-1020-from-freebsd-8-using-cups-and-foo2zjs

That lets you set up rules to upload the firmware on device attach, and set permissions.

Now in smb.conf, my print command is just:


```
print command = logger "Printing: %f to %p - Job:%J, Pages:%c, Bytes:%z"; cat "%f" > /dev/ulpt0; rm "%f"
```


----------



## wblock@ (Dec 5, 2012)

If you have problems printing, particularly large files, unlpt0 might still help.  Thanks for posting the firmware solution!


----------

