找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 1688|回复: 2

[N1盒子] N1安装无线共享打印机HP1020全过程

[复制链接]
发表于 2022-9-14 20:01 | 显示全部楼层 |阅读模式
本帖最后由 fayehoo 于 2023-1-20 21:42 编辑

这是我第二篇关于N1共享打印机的帖,因为刷了新系统后感觉Android 手机用WPS无线打印的格式正确了,所以觉得有必要另起一贴。

一、刷系统
1、下载最新的系统镜像,去这个网站:
https://github.com/ophub/amlogic-s9xxx-armbian/releases
我现在下的是:
https://github.com/ophub/amlogic ... r_2022.09.13.img.gz

2、用balenaEtcher或Rufus工具将img文件刷到U盘,插到N1启动,启动完毕后登录。
login:root
password:1234
3、然后做无线网络配置
armbian-config
配置完,再重启的话会发现搜索很长时间的网络才能进系统,为了缩短该启动时间,执行下面指令:
mv /etc/network/interfaces /etc/network/interfaces.bak
sync && reboot
4、将系统安装到N1内的EMMC
armbian-install
安装完毕,输入poweroff关机,拔掉U盘,N1重新上电。
5、更新国内源:
sudo vi /etc/apt/sources.list


deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse

6、更新系统:
apt-get update

二、安装驱动和服务
1、 将HP1020打印机接入N1的USB口,打开打印机电源。
lsusb
确认HP打印机已连入USB口。
2、安装cups打印服务
sudo apt-get install cups
sudo vi /etc/cups/cupsd.conf
将cupsd文件中localhost改成0.0.0.0(0.0.0.0意即任意IP地址),Browsing No改成Browsing Yes,并在四个地方分别添加Allow all,具体如下:
Listen 0.0.0.0:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing Yes

# Restrict access to the server...
<Location />
  Order allow,deny
  Allow all
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow all
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>

# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>
编辑完成,重启服务
service cups restart
3、安装HP打印机驱动
sudo apt-get install hplip
hp-setup -i
选USB接口方式,执行该命令过程中,会出现一个文本框,里面有HPLIP的版本号。
如PLUG-IN INSTALLATION FOR HPLIP 3.21.12
然后如果网速够快,就选d直接网络安装,如果网速不行,就选p就地安装,就地安装所需的文件去下面这个网站:
找到对应的版本,下载.run和run.asc两个文件
最后能打出一个测试页就成功了

三、配置打印机
打开浏览器,网址输入N1IP:631,进入cups配置页面。
添加打印机,选HP1020 USB HPLIP XXXX ,然后驱动选hpcups Share框必须勾选上。

四、安装airpint及打印机发现。
apt-get install cups-browsed
sudo service cups-browsed restart

sudo apt-get -y install avahi-daemon avahi-discover libnss-mdns
sudo service avahi-daemon restart

五、其他
为避免hplip使用的libusb和usblp冲突,要么就不用hplip改用foo2zjs,要么就屏蔽usblp,方法如下:
vi /etc/modprobe.d/blacklistusblp.conf,编辑内容blacklist usblp,设权限644。重启后任意开机和热插拔都能正确识别打印机。

有两个指令很有用,一个是USB连接好打印机,输入lsusb命令可以查看是否已连接到usb
root@aml:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 03f0:2b17 Hewlett-Packard LaserJet 1020
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

一个是hp-info -i,可以查看是否正确连接了打印机,是否有错误,特别是1020是GDI打印机,打印机上电后需要下载固件到打印机,deviceid可以显示固件FWVER:20080222是否已下载。

hp:/usb/HP_LaserJet_1020?serial=S44WTQ0

Device Parameters (dynamic data):
  Parameter                     Value(s)                                                  
  ----------------------------  ----------------------------------------------------------
  agent1-ack                    False                                                     
  agent1-desc                   Black toner cartridge                                    
  agent1-dvc                    0                                                         
  agent1-health                 0                                                         
  agent1-health-desc            Good/OK                                                   
  agent1-hp-ink                 False                                                     
  agent1-id                     0                                                         
  agent1-kind                   4                                                         
  agent1-known                  False                                                     
  agent1-level                  100                                                      
  agent1-level-trigger          0                                                         
  agent1-sku                    Q2612A                                                   
  agent1-type                   1                                                         
  agent1-virgin                 False                                                     
  back-end                      hp                                                        
  cups-printers                 ['HP_LaserJet_1020']                                      
  cups-uri                      hp:/usb/HP_LaserJet_1020?serial=S44WTQ0                  
  dev-file                                                                                
  device-state                  1                                                         
  device-uri                    hp:/usb/HP_LaserJet_1020?serial=S44WTQ0                  
  deviceid                      MFG:Hewlett-Packard;MDL:HP LaserJet                       
                                1020;CMD:ACL;CLS RINTER;DES:HP LaserJet                  
                                1020;FWVER:20080222;                                      
  duplexer                      0                                                         
  error-state                   0                                                         
  host                                                                                    
  in-tray1                      1                                                         
  in-tray2                      1                                                         
  is-hp                         True                                                      
  media-path                    1                                                         
  panel                         0                                                         
  panel-line1                                                                             
  panel-line2                                                                             
  photo-tray                    0                                                         
  port                          1                                                         
  r                             0                                                         
  revision                      254                                                      
  rg                            000                                                      
  rr                            000000                                                   
  rs                            000000000                                                
  serial                        S44WTQ0                                                   
  status-code                   1000                                                      
  status-desc                   Idle                                                      
  supply-door                   1                                                         
  top-door                      1  

苹果、安卓或者电脑与N1连接入同一wifi网,苹果和电脑可以默认搜索到打印机,打印无问题。
安卓手机可以用系统打印、Mopria Print、Android CUPS Print三种打印连接方式,都可以打印,后两种需要商店下载安装,推荐Mopria Print。WPS和Word的打印格式都正确,不会出现以前字体大的情况。

六、启动N1时清除历史任务
相信很多人有这个经历,某个打印任务因故障中断,然而重启打印机后,仍然会继续前次的打印任务,通常会带来混乱,所以我们希望一旦重启N1,就清除历史所有遗留打印任务。在gihub的CUPS上咨询之后,得到答复为:
The only way would be to purge the spool (/var/spool/cups) directory before starting cupsd, and that will cause all job history to be lost... You can just delete the "d" files in the spool directory to keep the history, but there will be some cleanup when cupsd starts with errors logged about the missing document files for printing...
具体实现可以尝试下面方法:
编辑 /ect/rc.local 文件,在exit 0前 添加下面的指令,这样可以在N1启动时清除CUPS的历史打印池。
rm -rf /var/spool/cups/*
mkdir /var/spool/cups/tmp
chmod 777 /var/spool/cups/tmp

评分

参与人数 1恩山币 +2 收起 理由
天天*** + 2 感谢你的分享,无论怎样,你都是最无私的人.

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
发表于 2022-9-14 20:08 | 显示全部楼层
牛,,,
支持airPrint 啊…

可以可以
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2024-4-2 16:07 | 显示全部楼层
小白完全看不懂
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 18:40

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表