怎样检测USB打印机无纸

用C语言 基于三星2410 ARM920 usb芯片是SL811 打印机是hp1150或1160(PCL5e命令) 也可以用hp1020(ACL命令)(不建议)

要求用C编写一个模块(函数)来判断 USB打印机有没有纸,从而给出相应的提示信息

我还要提供一些相关的资料支持! 可速联系本人(有报酬) e_mail : 个人信息保护,已隐藏

只要发送获取端口状态的命令就可以获取到了,命令码如下: buffer[0]=0xA1;buffer[1]=1;buffer[2]=buffer[3]=buffer[4]=buffer[5]=0;buffer[6]=1;buffer[7]=0; /* SETUP数据,GET_PORT_STATUS */ 如果没有纸的话,那么位5的数据应该为1


先谢谢hcn~ 就知道你会回答~ 其实这个我是知道的! 但无论有纸还是没纸每次获取返回的值都是0x18 即:00011000 第五位总是0 即总是有纸~~ 不知道是不是打印机的问题 hp1150/1160都不行


那你将打印机直接接到计算机上面也是这样返回的吗?


是指用bushound发命令给打印机吗?

还是其他方法? 怎么发?


不是的,你只要将打印机的纸取走之后,过一段时间主机就会发送获取端口状态的命令,这时候你可以用BUSHOUND来抓.


哦 ? 是吗? 我抓来看看有没有~


Bus Hound 5.00 capture. Complements of www.perisoft.net

1

Device - Device ID (followed by the endpoint for USB devices) (5) Intel(R) 82801FB/FBM USB Universal Host Controller - 2658 (6) USB Root Hub (19) hp LaserJet 1150 (DOT4) (20) IEEE 1284.4 兼容打印机 (21) hp LaserJet 1150 PCL 5e Phase - Phase Type CTL USB control transfer DI Data in LEN Data length Data - Hex dump of the data transferred Descr - Description of the phase Delta - Elapsed time from the previous phase to the current phase Time - Time the phase occurred in hour:minute:second.millisec form

Device Phase Data Description Delta Time ------ ----- ------------------------------------------------------------------------------------------------------ ---------------- ----- ------------ 6.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 5.3sc 01:35:39.446 6.0 LEN 04 00 00 00 4 27us 01:35:39.446 6.0 DI 01 01 01 00 .... 2us 01:35:39.446 6.0 CTL 23 01 10 00 02 00 00 00 CLEAR FEATURE 71us 01:35:39.446 6.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 74us 01:35:39.446 6.0 LEN 04 00 00 00 4 21us 01:35:39.446 6.0 DI 00 01 00 00 .... 3us 01:35:39.446 6.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 17us 01:35:39.446 6.0 LEN 04 00 00 00 4 19us 01:35:39.446 6.0 DI 01 01 00 00 .... 3us 01:35:39.446 6.0 CTL 23 03 04 00 02 00 00 00 SET FEATURE 124ms 01:35:39.571 6.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 31ms 01:35:39.602 6.0 LEN 04 00 00 00 4 33us 01:35:39.602 6.0 DI 03 01 10 00 .... 3us 01:35:39.602 6.0 CTL 23 01 14 00 02 00 00 00 CLEAR FEATURE 7us 01:35:39.602 6.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 31ms 01:35:39.634 6.0 LEN 04 00 00 00 4 42us 01:35:39.634 6.0 DI 03 01 00 00 .... 3us 01:35:39.634 6.0 CTL 23 03 04 00 02 00 00 00 SET FEATURE 35ms 01:35:39.669 6.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 27ms 01:35:39.696 6.0 LEN 04 00 00 00 4 34us 01:35:39.696 6.0 DI 03 01 10 00 .... 2us 01:35:39.696 6.0 CTL 23 01 14 00 02 00 00 00 CLEAR FEATURE 7us 01:35:39.696 6.0 CTL 80 06 00 03 00 00 ff 00 GET DESCRIPTOR 103ms 01:35:39.800 6.0 LEN 04 00 00 00 4 4.9ms 01:35:39.805 6.0 DI 04 03 09 04 .... 3us 01:35:39.805 6.0 CTL 80 06 03 03 09 04 ff 00 GET DESCRIPTOR 25us 01:35:39.805 6.0 LEN 1a 00 00 00 26 7.9ms 01:35:39.813 6.0 DI 1a 03 30 00 30 00 43 00 4e 00 43 00 43 00 30 00 30 00 39 00 35 00 37 00 34 00 ..0.0.C.N.C.C.0. 5us 01:35:39.813 6.0 CTL 80 06 00 02 00 00 ff 00 GET DESCRIPTOR 38us 01:35:39.813 6.0 LEN 4e 00 00 00 78 13ms 01:35:39.827 6.0 DI 09 02 4e 00 01 01 00 c0 01 09 04 00 00 03 07 01 03 00 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ..N............. 4us 01:35:39.827 07 05 82 03 08 00 ff 09 04 00 01 02 07 01 02 00 07 05 01 02 40 00 00 07 05 81 02 40 00 00 09 04 ................ 00 02 01 07 01 01 00 07 05 01 02 40 00 00 ...........@.. 19.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 51ms 01:35:39.879 19.0 LEN 12 00 00 00 18 5.1ms 01:35:39.884 19.0 DI 12 01 10 01 00 00 00 08 f0 03 17 0f 00 01 01 02 03 01 ................ 4us 01:35:39.884 19.0 CTL 80 06 00 02 00 00 09 01 GET DESCRIPTOR 26us 01:35:39.884 19.0 LEN 4e 00 00 00 78 13ms 01:35:39.898 19.0 DI 09 02 4e 00 01 01 00 c0 01 09 04 00 00 03 07 01 03 00 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ..N............. 5us 01:35:39.898 07 05 82 03 08 00 ff 09 04 00 01 02 07 01 02 00 07 05 01 02 40 00 00 07 05 81 02 40 00 00 09 04 ................ 00 02 01 07 01 01 00 07 05 01 02 40 00 00 ...........@.. 19.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 26us 01:35:39.898 19.0 CTL a1 00 00 00 00 00 ff 00


我是没装纸 就把打印机连到电脑上 上面是用busbound抓的


获取状态的命令还没有出来,主机应该会发我上面说的命令码,这种状态要过一段时间主机才会发


请问下 现在开发usb打印机(PCL5e)驱动一般采用哪一款打印机啊? 越便宜越好!


我是等了很久的 ~没发现有其他的命令啊~~


召唤hcn~~~~ 你用Get_Port_Status来获取打印机状态 所使用的打印机是什么牌子型号的啊?? 能支持PCL命令吗? 谢谢~~


我用的是三星的打印机,具体型号记不清了,在获取端口状态的时候要很长时间,可能要几分钟才返回,你就将你的计算机一直处在打印状态的话应该就会出这个现象的


要几分钟啊? 打印个东西要检测这么久那样不合理了~ 哎~~ 还是考虑其他方案算了~


只有登录才能回复,可以选择微信账号登录