HP printer / scanner

This is just a quick writeup of what I have done so far to get an HP LaserJet M1522nf (printer / fax / scanner) to work. Currently this device is only used as a copier at the office, but many people asked about the scan button. My main goal is that users can simply press the scan button on the device in order to scan a document and save it to a Samba share.

After connecting the USB cable, Kubuntu automatically installs the printer in Cups. You can change the settings on http://localhost:631. To change the name of the printer (how it appears on the printers list), add a new printer with the same settings, and delete the old one. So now we have a working printer.

For scanning under X Window, try xsane. In my case it failed with an I/O error. The solution was this command:

hp-plugin -i

This installs any missing driver from HP. After that xsane works and we can do some scanning. So far so good.

For scanning on the commandline, use scanimage -L to get a list of devices, and use something like the following command to actually scan:

scanimage -d 'hpaio:/usb/HP_LaserJet_M1522nf_MFP?serial=00CNDT914GWT' --mode Color --resolution 300 > test.pnm

The argument after -d specifies the device found using scanimage -L.

Great! Next thing to do is monitoring the scan button. This however seems to be a major problem, because nobody appears to have implemented it yet. Even after more than 5 years, HP appearently has serious trouble supporting this simple scan button in their HPLIP library. Fortunately, there is another way. If you press the scan button, a message appears on the LCD: "Waiting for PC",

and after a few seconds a timeout occurs because the PC is not responding, after which the printer returns to its ready state.

On some HP printers you can read out the LCD, using the SNMP protocol. So indirectly you can tell whether or not the scan button has been pressed. The only thing to do is hookup the HP device to the network and give it a static (fixed) IP address. Here are some useful commands:

snmpwalk -v 1 -c public <ip_address_of_scanner>
scli <ip_address_of_scanner> -c "show printer display"
scli <ip_address_of_scanner> -c "show printer lights"

The snmpwalk command is part of the snmp package and you can find the scli command in the scli package.

However, the M1522nf does fully support SNMP; you cannot read out the LCD using SNMP on this thing. It does not support Telnet either, and there is no PJL command you can send to the JetDirect port (9100) to query the LCD display. The only way to do that using the web interface, so we use wget to do that every 5 seconds. Here the script I have come up with:

#!/bin/sh

while [ 1 ]
do
   MSG="`wget -q -O - \
      'http://192.168.1.4/info_deviceStatus.html?tab=Status&menu=DevStatus' | \
      grep -A2 'itemLargeFont' | tail -1 | sed -r 's/(&nbsp;| |\t)+/ /g' | \
      sed 's/<[^>]*>//g'`"
   if echo "$MSG" | grep -q 'Waiting for PC'
   then
      echo "Scanning"
      scanimage -d hpaio:/usb/HP_LaserJet_M1522nf_MFP?serial=00CNDT914GWT \
         --mode Color --resolution 300 | cjpeg -optimize -quality 85 > \
         /share/Scanner/`date '+%Y-%m-%d-%H-%M-%S'`.jpg
   else
      echo "Idle"
   fi
   sleep 5
done

In this case 192.168.1.4 is the IP address of the printer and /share/Scanner is a directory on our NFS / Samba server. Now if someone presses the scan button, the scanner starts and the resulting image is converted from PNM to JPEG, and saved under a name like 2010-11-16-12:34:56.jpg.

Mission accomplished ;-)

asad

Very informative written post. The writer here has done a great job. I personally use them exclusively high-quality elements. I would love to see more of the same from you Hotel Deals. Thank you for discussing this great post.

asad

Very informative written post. The writer here has done a great job. I personally use them exclusively high-quality elements. I would love to see more of the same from you Hotel Deals. Thank you for discussing this great post.

Much thanks to you a cluster

Much thanks to you a cluster for offering this to every one of us you really acknowledge what you are discussing! Bookmarked. If you don't mind likewise look for guidance from my site =). We could have a hyperlink change contract between us! holm law group san diego

i am always looking for some

i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. bank owned properties

Excellent and very exciting

Excellent and very exciting site. Love to watch. Keep Rocking. Citation Flow

Cool stuff you must you keep

Cool stuff you must you keep redesign every one of us. instagram likes

TS

I feel a lot more people need to read this, very good info! . . . . . . Preventive Controls for Human Food HARPC

Positive webpage, where did u

Positive webpage, where did u think of the data on this posting?I have perused a couple of the articles on your site now, and I truly like your style. You're the best and please keep up the compelling work. post non profit jobs

If you still want to manage a

If you still want to manage a server, but not from home, check out the Minecraft server hosting area of the Minecraft forum or other websites. Expect to pay monthly for this type of server since finding free hosting is a rarity. But you save the hassle of constantly maintaining a server and ensure it is always online for your players. Minecraft Servers

I am upbeat to discover this

I am upbeat to discover this post exceptionally helpful for me, as it contains part of data. I generally want to peruse the quality substance and this thing I found in you post. A debt of gratitude is in order for sharing. Latest Gadgets

On the off chance that you

On the off chance that you set out to make me think today; mission fulfilled! I truly like you"re composing style and how you express your thoughts. Much obliged to you. Friv 4 school

I really like your writing

I really like your writing style, great information, thankyou for posting. Phoenix SEO Company

I might want to say this web

I might want to say this web journal truly persuaded me to do it! Much obliged, great post. Joseph Hayon

sirking79

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing Body Language Moves

An entrancing dialog is

An entrancing dialog is quality remark. I surmise that it is best to compose additional on this matter, it won"t be an unthinkable point however for the most part individuals are insufficient to chat on such themes. To the following. Salud color copies online

They did good work and aimed

They did good work and aimed to provide me with the highest level of customer service to make sure I was a satisfied customer. Glass repair

Coinsq.com provides all the

Coinsq.com provides all the information about realtime prices & market cap of cryptocurrencies and more. Altcoin price

Amazing article! I need

Amazing article! I need individuals to know exactly how great this data is in your article. It"s fascinating, convincing substance. Your perspectives are much like my own particular concerning this subjec invokana lawsuit

The quality of information

The quality of information that you are providing is simply marvelous. carpet cleaning services folly beach sc

You have a decent point

You have a decent point here!I absolutely concur with what you have said!!Thanks for sharing your views...hope more individuals will read this article!!! home and land packages

sirking79

Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have. Hero Instinct

Good focuses you composed

Good focuses you composed here..Great stuff...I think you've made some really fascinating points.Keep up the great work. Ark item list xbox one

Goodness, cool post. I'd like

Goodness, cool post. I'd like to compose like this as well – requiring significant investment and genuine diligent work to make an incredible article… yet I put things off an excessive amount of and never appear to begin. Much obliged however. Fifty Motion

https://www.yttomp3.org/

an other computer. In KDE there is a VNC server called krfb. The main disadvantage of this, is that when you move the mouse on the server, it does not move the mouse on the client. https://www.yttomp3.org/

Yes i am completely concurred

Yes i am completely concurred with this article and i simply need say this article is extremely decent and exceptionally useful article.I will make a point to be perusing your blog more. You made a decent point yet I can"t resist the urge to ponder, shouldn"t something be said about the other side? !!!!!!THANKS!!!!!! Agilt

Positive site, where did u

Positive site, where did u concoct the data on this posting? I'm satisfied I found it however, sick be inquiring soon to figure out what extra posts you incorporate. magnetic tape

much thanks to you for an

https://www.9597.tw/

Fabulous site you have here.

Fabulous site you have here. You'll find me taking a gander at your stuff regularly. Spared! fishing guides charlestonsc

Your web journal furnished us

Your web journal furnished us with important data to work with. Each and every tips of your post are wonderful. Much obliged for sharing. Continue blogging, cheapest 55 print

It proved to be Very helpful

It proved to be Very helpful to me and I am sure to all the commentators here! 1200g polythene

i was simply scanning along

i was simply scanning along and happened upon your site. simply needed to say great site and this article truly helped me. gamerhome

A debt of gratitude is in

A debt of gratitude is in order for offering this quality data to us. I truly delighted in perusing. Will without a doubt going to impart this URL to my companions. morocco travel advisory

I have been looking at a

I have been looking at a couple of your stories and i can state really well done. I will bookmark your online journal magnetic tape

Amazing article. Extremely

Amazing article. Extremely intriguing to peruse. I truly love to peruse such a decent article. Much obliged! continue shaking. 55printing.com/blogs/brochure-design-tips/

It was a decent post in

It was a decent post in reality. I altogether delighted in understanding it in my lunch time. Will without a doubt come and visit this blog all the more frequently. A debt of gratitude is in order for sharing. webdesign Amsterdam

Amazing article. Extremely

Amazing article. Extremely intriguing to peruse. I truly love to peruse such a decent article. Much obliged! continue shaking. Forest Row Accountants

I know your aptitude on this.

I know your aptitude on this. I should say we ought to have an online discourse on this. Composing just remarks will close the talk straight away! What's more, will confine the advantages from this data. related site

The Canadian company

The Canadian company interested in buying the Villa de Paz Golf Course property on Tuesday removed its application for the land. resources

Wow i can say this is another

Wow i can say this is another extraordinary article not surprisingly of this blog.Bookmarked this website.. Get free hotstar premium

The post is composed in

The post is composed in exceptionally a decent way and it contains numerous valuable data for me. website

Much obliged to you for the

Much obliged to you for the upgrade, exceptionally pleasant site.. more about the author

Is it alright to post a

Is it alright to post a portion of this on my site fundamentally present a hyperlink on this site page? Company Accountants

It was a decent post in

It was a decent post in reality. I altogether delighted in understanding it in my lunch time. Will without a doubt come and visit this blog all the more frequently. A debt of gratitude is in order for sharing. marketing services

I was perusing your article

I was perusing your article and thought about whether you had considered making a digital book on this subject. You"re composing would offer it quick. You have a considerable measure of composing ability. Swiss made

A debt of gratitude is in

A debt of gratitude is in order for offering this quality data to us. I truly delighted in perusing. Will without a doubt going to impart this URL to my companions. จีคลับ

Only a grinning visitant here

Only a grinning visitant here to share the adoration (:, btw remarkable style. Tax Accountant

Incredible overview, I"m

Incredible overview, I"m certain you"re getting an awesome reaction. divorce attorneys

You have a decent point

You have a decent point here!I absolutely concur with what you have said!!Thanks for sharing your views...hope more individuals will read this article!!! buy Delcam Powermill

Much obliged for another

Much obliged for another superb post. Where else would anybody be able to get that sort of information in such a perfect method for composing? Cheap Panoramic Canvas Prints