树莓派(RaspberryPI 3)用作HP LaserJet P1007的打印机服务器

xiaoxiao2021-03-01  29

网上有一些介绍(说实话并不是太多)。这里只是做个总结摘要。如果不愿意详细研究其他文章,可以参考本文也能成功。

购买一块树莓派板子,安装Raspbian。(推荐使用usbImageTool制作sd卡:http://www.alexpage.de/usb-image-tool/);打开ssh(可由图形界面开启:系统菜单Preference| RaspberryPi Configuration );安装 HPLIP (hp-linux-imaging-and-printing,有兴趣深究的话参考:https://developers.hp.com/hp-linux-imaging-and-printing)。此安装会自动安装 cups。(官网:https://www.cups.org。 CUPS 是一个开源的,用于linux 打印的系统,这可是乔帮主的苹果公司开发的)sudo apt-get install hplip很重要的一步:将pi用户 加入到 lpadmin,如果不加,则后续添加打印机步骤会出现 forbidden,无权限操作。sudo usermod -a -G lpadmin pi 修改cups的配置文件。为了安全,cups服务只能本地访问。可以根据需要扩大访问范围。配置文件在 /etc/cups/cupsd.conf . 修改前可以先停止cups服务: sudo service cups stop。 注意先备份再修改。下面 有 #*** 的就是修改/添加的内容。# Only listen for connections from the local machine. #Listen localhost:631 原来的配置只监听本地。可以改为0.0.0.0:631,或者只是你的网段:192.168.0.0:631 Listen 0.0.0.0:631 # *** # Restrict access to the server… <Location /> Order allow,deny Allow from @Local # *** 如果跨网段,可以再加一行,例如: Allow from 192.168.2.* </Location> # Restrict access to the admin pages… <Location /admin> Order allow,deny Allow from @Local # *** </Location> # Restrict access to configuration files… <Location /admin/conf> AuthType Default Require user @SYSTEM Order allow,deny Allow from @Local # *** </Location>修改完之后重启cups服务:sudo service cups start如果使用其他的打印机,运气好的话已经可以开始添加打印机了,如果用 HP P1007,还需要继续: 安装foo2xqx:  a linux printer driver for XQX stream protocol#下载解压。要在树莓派上执行。最好先建一个目录 wget http://foo2zjs.rkkda.com/foo2zjs.tar.gz# Unpack: $ tar zxf foo2zjs.tar.gz $ cd foo2zjsCompile: $ make Get extra files from the web, such as .ICM profiles for color correction, and firmware. Select the model number for your printer: $ ./getweb P1005 # Get HP LaserJet P1005 firmware file # !!!! 注意下一行,一定要执行 $ ./getweb P1006 # Get HP LaserJet P1006 firmware file $ ./getweb P1007 # Get HP LaserJet P1007 firmware file $ ./getweb P1008 # Get HP LaserJet P1008 firmware file $ ./getweb P1505 # Get HP LaserJet P1505 firmware file Install driver, foomatic XML files, and extra files: $ su OR $ sudo make install # make install (Optional) Configure hotplug (USB; HP LJ P1005/P1006/P1007/P1008/P1505): # make install-hotplug OR $ sudo make install-hotplug (Optional) If you use CUPS, restart the spooler: # make cups OR $ sudo make cups  如果以上步骤没问题,那么已经可以开始添加打印机了:任何一台机器访问:http://树莓派IP:631/ 打印机连接树莓派USB口,在页面选择带有USB字样的设备。注意一定要选中Share this printer.选择驱动的时候一定要选择foo2xqx的驱动。  最后可以在Maintenance打印测试测试页。如果成功了,就可以从电脑添加打印机了。共享打印机地址是:http://树莓派IP:631/printers/添加的打印机名一个坑:由于漏掉了./getweb P1007这一步,打印机断电之后无法初始化。必须用电脑连接打印一次,树莓派才能正常服务。重新执行这一句,并重新 make install 就好了。

参考文章:

http://www.cnblogs.com/h2zZhou/p/5497130.htmlhttps://www.linuxidc.com/Linux/2016-10/135931.htmhttp://foo2xqx.rkkda.com/

转载请注明原文地址: https://www.6miu.com/read-3200226.html

最新回复(0)