- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试监听打印机状态变化(例如卡纸、暂停...) 下面的代码给出“Bad notify-recipient-uri”响应,然后锁定 ippReadFile 并且在打印机暂停时不释放/未暂停。
int main()
{
http_t *http = httpConnectEncrypt(cupsServer(), ippPort(),
cupsEncryption());
ipp_t *request = ippNewRequest(IPP_CREATE_PRINTER_SUBSCRIPTION);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost:631/printers/Generic-text-only");
ippAddString(request, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI, "notify-recipient-uri",
NULL, "cups_test://");
ippAddString(request, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD, "notify-events",
NULL, "printer-state-changed");
ipp_t *response = cupsDoRequest(http, request, "/");
while (1)
{
ipp_state_t state;
ipp_t *event = ippNew();
while ((state = ippReadFile(0, event)) != IPP_DATA)
{
printf("%s\n","Got Data");
}
printf("%s\n","Repeating");
ippDelete(event);
}
}
在筛选打印机属性后,我发现 notify-schemes-supported
属性设置为“dbus”。我无法使用 IPP_SET_PRINTER_ATTRIBUTES
更改属性。关于如何让它发挥作用的任何想法?
最佳答案
一个不需要任何 C 代码的非常基本的示例是针对 create-printer-subscription
宏使用 ipptool
来订阅事件的 rss URI。这是 pyipptool
说明的方法。 .
ipptool
通常随 CUPS 一起提供,但对于现代 Ubuntu 版本,您可能需要安装 cups-ipp-utils
。
首先,创建一个可以接收事件的 HTTP 套接字监听器...
python -m SimpleHTTPServer 9876
其次,将事件发送到套接字监听器。
ipptool -d recipient=rss://localhost:9876 ipp://localhost:631/printers /usr/share/cups/ipptool/create-printer-subscription.test
最后,触发一个事件,比如禁用打印机。
cupsdisable PDFWriter # or some valid printer name
cupsenable PDFWriter
rss://
URI 方案将对 HTTP 套接字服务器使用 PUT
命令。由于 SimpleHTTPServer
没有对 PUT
命令的内置支持,因此会出现 501
错误。您将必须自定义 HTTP 监听器来处理这些命令,但您会看到触发的事件。
请注意,默认的 create-printer-subscription
宏配置为发送 printer-config-changed
和 printer-state-changed
的事件> 但是 not printer-queue-order-changed
可以通过复制宏并对其进行编辑来进行调整。
此外,这将使订阅在默认租用期限内保持事件状态(定义为 86400
in the source,应该是一天)。可以为无限期订阅指定零的附加参数 notify-lease-duration
。
关于CUPS 状态变更订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43621322/
在 RFC8011 p.152 打印机可以有一个常见的状态原因列表。在我的测试中,这个列表似乎非常不完整。是否有更完整的 CUPS 列表? 未列出的打印机状态原因的一些示例: cups 等待作业完成
有没有办法明确告诉 CUPS 服务器您发送的文件是 text/html从而覆盖 mime.types 查找? 最佳答案 就在这里。 使用这个命令行: lp -d printername -o docu
我正在尝试用 Java 做一个编译器,并且使用 CUP 来生成语法的语法。 我有这个 Parser.cup /* Terminals (tokens returned by the scanner).
我想让我的 RasPi 在由三个 Linux 客户端组成的小型家庭网络中充当小型打印和文件服务器。不幸的是,Brother 只提供 x86 的二进制驱动程序,所以我无法在 RasPi 上运行我的 Br
打印作业到 CUPS 服务器时,您可以设置 cupsd.conf 参数 PreserveJobHistory和 PreserveJobFiles控制您要保留的作业数量。 CUPS 始终将实际打印作业文
我正在尝试使用 pip 在隔离 (--no-site-package) virtualenv 中安装 pycups,我得到了这个回溯。我无法弄清楚我做错了什么。有什么想法吗? 谢谢, Download
我正在尝试监听打印机状态变化(例如卡纸、暂停...) 下面的代码给出“Bad notify-recipient-uri”响应,然后锁定 ippReadFile 并且在打印机暂停时不释放/未暂停。 in
如果我在 OSX 中通过普通打印对话框(首选项->打印机)添加打印机,它会显示在列表中。 如果我随后进入 CUPS 并将这台打印机的驱动程序更改为 RAW(这就是我需要的)- 那么我可以这样做,但它会
复古打印机日:我有一台旧的 IbmPro 兼容点阵打印机,通过 USB 并行适配器连接到我的 Ubuntu 20.04 系统。它工作得很好!设置它的一个主要技巧:将 URI 设置为/dev/usb/l
我在使用 CUPS 2.2.7 时遇到了一些问题 这是我的/etc/hosts 文件: 127.0.0.1 example.com 127.0.0.1 localhost 在 http://l
我(几乎)做了一个杯子排序算法,它接受颜色和半径参数,然后吐出按半径长度排列的杯子名称。 示例输入 2 blue 7 10 red 示例输出 red blue 问题是我想创建一个过滤器来检查拆分时第一
成功安装我的杯子打印机Ubuntu18.4。当我单击设备端的添加打印机图标时,它显示名称为“CUPS-BRF-Printer”。我想更改此名称。如何更改默认名称..如何更改? 最佳答案 1º停止CUP
我正在尝试使用戴尔 ppd 打印到戴尔 2350dn。它曾经有效,现在无效,但我很少使用这台打印机,也不知道在此期间发生了什么。 cups 错误日志有: E [07/Feb/2014:16:11:53
如何通过 CUPS API 获取 CUPS 打印作业失败的原因? 使用 CUPS API,我打印了两个未能打印的作业。在 CUPS 网络界面上,我可以看到失败的原因:“不支持的打印数据。”和“无法写入
在本地网络上,在我的 CUPS 管理页面中,当我尝试添加网络打印机时,每台打印机都会出现多次: 例如,Lexmark T644 出现: *Lexmark T644 (2) (Lexmark Lexma
我正在使用 IPP 协议(protocol)与 CUPS 通信。我在 CUPS 中安装了我的打印机的所有驱动程序(使用 .ppd 文件),并且打印机获得了最新的固件。 当我查询打印机正在打印的作业时,
我怎么知道lpr命令 (CUPS) 我的文件实际上是 PDF? lpr file.pdf 不会打印任何东西。 最佳答案 这真的是基于CUPS的lpr ,还是在安装 CUPS 之前没有移除的另一个假脱机
我有两台机器。一个使用 CUPS 1.5.0,另一个使用 CUPS 1.6.1。两台机器位于同一本地网络上。我想要完全发现网络上的打印机。如果我运行以下命令: CUPS_DEBUG_LEVEL=2 /
我在调试 CUP 语法时陷入困境。 所以我在 CUP 中有以下语法: /* Integer operators */ precedence left SUM_OP, SUBS_OP; preceden
有没有办法使用 CUPS 库获取打印机的所有字节命令列表,这些命令应发送到打印机以执行操作。例如:如果我想找出打印机自动剪切功能的字节命令,我可以使用 CUPS 来实现吗?他们有此功能的 API 吗?
我是一名优秀的程序员,十分优秀!