简体   繁体   English

条形码扫描仪在html字段中输入的文本缓慢

[英]Slow text input in html field from barcode scanner

I have a webpage in my LAN in order to input barcodes in real time to a db through a field (framework django + postgresql + nginx). 我在局域网中有一个网页,以便通过字段(框架django + postgresql + nginx)将条形码实时输入到db。 It works fine, but lately we have a customer that uses 72 char barcodes (Code Matrix) that slows down inputs because before next scan, user must wait the redraw of the last one in the field (it takes about 1-2 seconds, redrawing one char after the other). 它工作正常,但是最近我们有一个客户使用72个字符的条形码(代码矩阵),这会减慢输入速度,因为在下一次扫描之前,用户必须等待字段中最后一个的重绘(大约1-2秒,重绘)一个字符,另一个字符)。

Is there a way to reduce latency of drawing scanned text in the html field? 有没有一种方法可以减少在html字段中绘制扫描文本的延迟? Best thing would be to show directly all the scanned barcode, not one char after the other. 最好的办法是直接显示所有扫描的条形码,而不是一个字符接着另一个字符。 The scanner is set to add an "Enter" after the scanned text. 扫描仪设置为在扫描的文本后添加“ Enter”。

At the end, as Brad stated, the problem is more related to scanner's settings (USB in HID mode), although PC speed is also an issue. 最后,如Brad所述,尽管PC速度也是一个问题,但问题更多与扫描仪的设置(HID模式下的USB)有关。 After several tests, on a dual core linux machine I estimate delay due 85% to the scanner and 15% to PC/browser combo. 经过几次测试,在双核linux机器上,我估计延迟是由于扫描器的85%和PC /浏览器组合的15%。

To solve the problem I first searched and downloaded the complete manual of our 2D barcode scanner (306 pages), then I focused on USB Keystroke Delay as a cause, but default setting was already set to 'No Delay'. 为了解决该问题,我首先搜索并下载了二维条码扫描器的完整手册(306页),然后我着眼于USB击键延迟 ,但默认设置已设置为“无延迟”。

The setting that affected reading speed was USB Polling Interval , an option that applies only to the USB HID Keyboard Emulation Device. 影响读取速度的设置是USB Polling Interval ,该选项仅适用于USB HID键盘仿真设备。

The polling interval determines the rate at which data can be sent between the scanner and the host computer. 轮询间隔决定了扫描仪和主机之间可以发送数据的速率。 A lower number indicates a faster data rate: default was 8ms, wich I lowered to 3ms without problems. 较小的数字表示更快的数据速率:默认值为8ms,直到我降低到3ms都没有问题。 Lower rates weren't any faster, probably because it was reached the treshold where PC becomes the bottleneck. 降低费率并没有更快,可能是因为它达到了PC成为瓶颈的高潮。

CAUTION: Ensure your host machine can handle the selected data rate, selecting a data rate that is too fast for your host machine may result in lost data: in my case when I lowered polling interval to 1ms there were no data loss within the working PC, but when testing inside a virtual machine there was data loss as soon as I reached 6ms. 注意:确保您的主机可以处理所选的数据速率,选择对您的主机而言太快的数据速率可能会导致数据丢失:就我而言,当我将轮询间隔降低到1ms时,工作PC内没有数据丢失,但是在虚拟机内部进行测试时,一旦达到6ms,数据就会丢失。

Another interesting thing is that browsers tend to respond significantly slower after a long period of use with many tabs open (a couple of hours in my case), probably due to caching. 另一个有趣的事情是,长时间使用浏览器并打开许多选项卡后,浏览器的响应速度往往会明显变慢(在我的情况下为几个小时),这可能是由于缓存造成的。

Tests done with Firefox and Chromium browsers on old dual core PC with OS Lubuntu (linux). 在装有OS Lubuntu(linux)的旧双核PC上使用Firefox和Chromium浏览器进行的测试。

This probably has nothing to do with your page, but with the speed of the scanner interface. 这可能与您的页面无关,但与扫描仪界面的速度有关。 Most of those scanners intentionally rate-limit their input so as not to fill the computer's buffer, avoiding characters getting dropped. 这些扫描仪中的大多数都有意对它们的输入进行速率限制,以免填充计算机的缓冲区,从而避免字符丢失。 Think about this... when you copy/paste text, it doesn't take a long time to redraw characters. 考虑一下...复制/粘贴文本时,不需要很长时间即可重新绘制字符。 Everything appears instantly. 一切都会立即出现。

Most of those scanners are configurable. 这些扫描仪大多数都是可配置的。 Check to see if there is an option on your scanner to increase its character rate. 检查扫描仪上是否有增加字符速率的选项。

On Honeywell and many other brand scanners the USB Keystroke Interval is marked as an INTERCHARACHTER DELAY. 在Honeywell和许多其他品牌的扫描仪上,USB击键间隔被标记为INTERCHARACHTER DELAY。

Also if there is a BAUD rate that would be something to increase. 另外,如果存在BAUD汇率,那将会有所增加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM