转载于:https://laoyu.me/index.php/archives/32/
0、首先点击这里检查你的打印机是否受支持
树莓派
1、下载树莓派的系统
Raspberry Lite Stretch
Raspberry Lite Jessie
写入SD卡 并且开启SSH
使用Advanced IP scanner扫描树莓派的IP
国内用户先更换中科大或者清华大学的源
中科大源
sudo sed -i 's#://raspbian.raspberrypi.org#s://mirrors.ustc.edu.cn/raspbian#g' /etc/apt/sources.list
sudo sed -i 's#://archive.raspberrypi.org/debian#s://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian#g' /etc/apt/sources.list.d/raspi.list
或者清华大学源
sudo sed -i 's#://raspbian.raspberrypi.org#s://mirrors.tuna.tsinghua.edu.cn/raspbian#g' /etc/apt/sources.list
sudo sed -i 's#://archive.raspberrypi.org/debian#s://mirrors.tuna.tsinghua.edu.cn/raspberrypi#g' /etc/apt/sources.list.d/raspi.list
2、树莓派安装打印机套件
2.1、安装CUPS
sudo apt update
sudo apt install cups
2.2、添加当前用户到打印机管理组
sudo usermod -a -G lpadmin pi
2.3、确保cups允许所有的流量请求 然后重启cups
sudo cupsctl --remote-any
sudo /etc/init.d/cups restart
2.4、{}内为可选操作 非必须,适用于DDNS远程打印服务
{默认情况下CUPS关闭远程访问 要启用远程管理 我们首先需要通过SSH编辑cups配置文件 CUPS配置文件位于/etc/cups/cupsd.conf中 查找以下行
Listen localhost:631
更改为
Port 631
添加以下两行
BrowseRemoteProtocols CUPS dnssd
BrowseAddress @LOCAL
找到Location行
<Location />
Order allow,deny
Allow all
</Location>
改为
<Location /admin>
</Location>
重启CUPS
sudo service cups reload
}可选操作完毕
再CUPS中添加打印机 现在访问树莓派IP:631,应该可以看到CUPS的后台页面了
image.png
选择administration标签
image.png
点击左上角的Add printer 此时你需要使用https登录
默认的用户名 pi
密码 raspberry
登陆后会显示如下界面 在Local Printer中选择自己的打印机
image.png点击continue后出现如下界面 并选中share this printer 如图
image.png在可用驱动程序列表中选择您的型号后 点击Add Printer
image.png最后设置打印机打印选项
image.png至此 打印机一设置完毕 在Mac Linux中可以直接输入IP添加打印机 Windows用户请继续下面的设置
树莓派中开启samba
sudo apt update
sudo apt install samba
修改配置文件
sudo nano /etc/samba/smb.conf
找到 [printers] guest ok 改为 YES
# CUPS printing.
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700
找到 [print$] read only 改为 NO
# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = no
guest ok = no
重启samba服务并设置开机启动
sudo systemctl start smbd
sudo systemctl enable smbd
在windows中添加打印机
以win10为例。先打开资源管理器,在地址栏中输入树莓派samba服务器的地址\IP,如果一切顺利的话,你会看到你的打印机的图标和你打印机的名字(即你刚刚在CUPS中设置的名字),这里以我的打印机为例。你可以尝试双击打印机图标 - (提示找不到驱动程序)确定 - 选择驱动程序 - 完成来添加打印机。如果不行,请尝试下面的方法:
打开所有设置 - 设备 - 打印机和扫描仪 - 添加打印机或扫描仪 - (等两秒)我需要的打印机不在列表中 - 按名称选择共享打印机。
在下面的文本框中输入打印机的地址\IP打印机型号,点击下一步 - (找不到驱动程序)确定 - 选择驱动程序 - (已成功添加IP上的打印机型号)下一步 - 完成或者打印测试页。
这样,你的打印机就成功添加到win系统中了,你可以在任何应用中点击打印,并且使用这个打印机了。
3、下面是扫描仪部分的设置
3.1、安装扫描套件SANE
sudo apt update
sudo apt install sane
测试是否可以找到扫描仪
sudo sane-find-scanner
输出如下所示,可以看到已经识别出了扫描仪
# sane-find-scanner will now attempt to detect your scanner. If the
# result is different from what you expected, first make sure your
# scanner is powered up and properly connected to your computer.
# No SCSI scanners found. If you expected something different, make sure that
# you have loaded a kernel SCSI driver for your SCSI adapter.
# Also you need support for SCSI Generic (sg) in your operating system.
# If using Linux, try "modprobe sg".
found USB scanner (vendor=0x03f0 [HP], product=0xa011 [Deskjet 3050A J611 series]) at libusb:001:005
found USB scanner (vendor=0x0bda [Manufacturer Realtek ], product=0x8172 [RTL8191S WLAN Adapter ]) at libusb:001:004
found USB scanner (vendor=0x0424, product=0xec00) at libusb:001:003
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.
# Not checking for parallel port scanners.
# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.
进一步尝试
sudo scanimage -L
尝试扫描任何文档
sudo scanimage > ~/test.pnm
配置SANE
修改/添加如下内容来配置打开SANE的守护进程
sudo nano /etc/default/saned
更改以下代码
RUN=yes
让SANE接收路由器局域网地址段的ip。请根据你的实际情况更改。如果你的局域网ip地址是192.168.x.x,那么添加192.168.x.0/24即可
sudo nano /etc/sane.d/saned.conf
添加一下代码
192.168.x.0/24
删除一下行
data_portrange = 10000 - 10100
解决权限问题 输入以下代码
ls -l /dev/bus/usb/001
出现
total 0
crw-rw-r-- 1 root root 189, 0 Mar 29 06:56 001
crw-rw-r-- 1 root root 189, 1 Apr 8 2019 002
crw-rw-r-- 1 root root 189, 2 Apr 8 2019 003
crw-rw-r-- 1 root lp 189, 3 Mar 29 07:33 004
它由lp组(Linux打印)的root用户拥有。我们需要将sane守护程序添加到lp组中,以为其授予必要的权限:输入以下代码
sudo adduser saned lp
重启sane,将sane添加到启动项并检查它的status
sudo systemctl start saned.socket
sudo systemctl enable saned.socket
sudo systemctl status saned.socket
你会看到如下输出,可以看到6566端口是给SANE用的
● saned.socket - saned incoming socket
Loaded: loaded (/lib/systemd/system/saned.socket; enabled; vendor preset: ena
Active: active (listening) since Sun 2020-03-29 06:57:54 BST; 1h 8min ago
Listen: [::]:6566 (Stream)
Accepted: 12; Connected: 0
Mar 29 06:57:54 raspberrypi systemd[1]: Listening on saned incoming socket.
按ctrl+c退出
网友评论