Datalogic Falcon X3-条形码扫描仪 [英] Datalogic Falcon X3 - Barcode Scanner
问题描述
我刚刚获得了Datalogic Falcon X3 +条形码设备,并被询问是否可以制作一个Javascript应用程序来读取条形码并将其通过sql发送到数据库.
I just got the Datalogic Falcon X3+ Barcode Device and got asked, if I could make a javascript application which reads the barcode and send it via sql to a database.
由于我不是很喜欢Visual Studio 2008中的C ++/C#和Windows SDK,所以我不知道该如何开始.在datalogic的主页上,我找到了一些用JavaScript编写的ActiveX API示例,用于扫描(Memor X3 SDK).
Since I'm not really into C++/C# and the Windows SDK in Visual Studio 2008, I don't know exactly how to start. On the homepage of datalogic I found some ActiveX API examples which are written in javascript for scanning (Memor X3 SDK).
5个文件:
- BARCODE_Identifiers.js
- SCAN_PARAMENTERS.js
- jsBarcodeIdDemo.htm
- jsScanDemo.htm
- jsScanSetupDemo.htm
var BARCODE_ID_CODE_UNDEFINED=-1;
var BARCODE_ID_CODE_25_CIP_HR=0;
var BARCODE_ID_CODE_25_INTERLEAVED=1;
var BARCODE_ID_CODE_25_INDUSTRIAL=2;
SCAN_PARAMETERS.js-摘录
var SCAN_PARAM_WAVE_FILE=67108864;
var SCAN_PARAM_TIMEOUT=67108865;
var SCAN_PARAM_BEEPER_DURATION=67108866;
var SCAN_PARAM_KEYBOARD_EMULATION=67108871;
jsScanDemo.htm-摘录
//ScanEnable...
function ScanEnable(sAction)
{
if (sAction=="ENABLE")
{
DatalogicScanner1.bScanEnabled = true;
//ENABLE Continuous Mode PARAM ONLY IF READER == PORT REDIRECTOR
var nReaderType = oScannerSetup.getReaderIdentifier();
if (nReaderType==SE_READER_PR_CLASS_ID)
{
oScannerSetup.setParameter(SCAN_PARAM_CONTINUOUS_MODE,SCAN_PARAM_ENABLE);
}
}
else
{
//DISABLE Continuous Mode PARAM ONLY IF READER == PORT REDIRECTOR
var nReaderType = oScannerSetup.getReaderIdentifier();
if (nReaderType==SE_READER_PR_CLASS_ID)
{
oScannerSetup.setParameter(SCAN_PARAM_CONTINUOUS_MODE,SCAN_PARAM_DISABLE);
}
DatalogicScanner1.bScanEnabled = false;
}
if (DatalogicScanner1.bScanEnabled == true)
{
btnSoftTrigger.disabled = false;
return("DISABLE");
}
btnSoftTrigger.disabled = true;
return("ENABLE");
}
初始情况
使用Falcon X3 +以任何文本形式扫描条形码时,它不会将解码后的条形码作为文本发送.就是说,我无法通过按键事件来获取条形码.Falcon的控制面板中有一个名为解码"的应用程序.仅在此应用程序中,您才能看到解码后的数据.
The initial situation
When scanning a barcode with the Falcon X3+ being in any kind of text form, it doesn't send the decoded barcode as text. Means, that I can't grab the barcode with a keypress event. The Falcon has an application called "decoding" in it's control panel. Only in this application you can see the decoded data.
我找不到可以将模式切换为 keyboard_emulation = true
或类似内容的设置.
I couldn't find a setting where you can switch modes into keyboard_emulation = true
, or something similar.
我刚刚尝试的是将示例javascript放到Web服务器上,然后使用Falcon X3 +(包含在Windows CE 6.5中)的Internet Explorer访问该.htm文件.但是这里我有同样的问题-没有解码的数据传输.
What I just tried is putting the example javascript onto a web server and then visiting that .htm-file with the Internet Explorer of the Falcon X3+ (which is included on the Windows CE 6.5). But here I have the same problem - there is no decoded data transmitted.
有没有人已经可以使用datalogic falcon x3的简单工具(甚至基于javascript?)?
Is there anyone out there who already has something simple for the datalogic falcon x3 (maybe even based on javascript?) which I could work with?
谢谢!
推荐答案
尽管这是一个古老的问题,虽然没有特别明确地提出,但仍然没有公认的答案(截至2020年1月28日).我提出了以下非常简单的解决方案,并在代码后讨论了一些重要的警告:
Although this is an old question, and not particularly well presented, it still has no accepted answer (as of 2020-01-28). I've come up with the followihg remarkably simple solution, with a couple of important caveats discussed after the code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Scanner Test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<p>The following form accepts input from a barcode scanner.</p>
<hr>
<form method='post' action='scan.php'>
<table>
<tr>
<td>Scanner Input:</td>
<td><input id='scanval' name='scanval' value=''></td>
</tr>
</table>
<input type='submit' name='submit' value='Submit'>
</form>
<script>
window.onload = function() { document.getElementById('scanval').focus(); }
</script>
</body>
</html>
自然,这在所有主流浏览器中都可以正常工作.诀窍是使其能够在Windows CE设备(在我的情况下为Datalogic Falcon X3 +条码扫描器)的IE浏览器中工作.要求将焦点放在页面加载时的输入字段上,以便用户可以立即开始扫描条形码,而无需单击或点击等.
Naturally, this works fine within all major browsers. The trick was getting it to work in the IE browser on a Windows CE device (in my case, a Datalogic Falcon X3+ barcode scanner). The requirement is for the focus to be on the input field at page load, so that a user can immediately start scanning bar codes without having to click or tap, etc.
当然,有很多方法可以设置焦点,但是在此特定环境中似乎唯一可行的方法是使用 window.onload
,并在之后关闭</form>
标记.
Of course, there are many ways to set the focus, but the only way that seemed to work in this specific environment was to use window.onload
, and have it appear after the closing </form>
tag.
我们希望大多数浏览器在按Enter/Return键时会自动提交表单.幸运的是,这可以在Windows CE上的IE中使用.因此,严格来说,我们不需要表单上的Submit按钮.扫描程序显然包括< cr>
或< cr< lf>
来终止每次扫描,因此该表单是自动提交的.
We expect most browsers to submit a form automatically when the enter/return key is pressed. Fortunately this works in IE on Windows CE. So, strictly speaking, we don't need the Submit button on the form. The scanner apparently includes either a <cr>
or a <cr><lf>
to terminate each scan, so the form is automatically submitted.
但是...奇怪的是,当在此设备上调用自动提交时, submit
输入值不会传输到服务器.我在服务器上使用PHP处理传入的表单数据,并且从扫描仪接收到的 $ _ POST
数据结构仅包含 scanval
输入字段值,而不包含提交
值.
HOWEVER... oddly, when auto-submit is invoked on this device, the submit
input value is not transmitted to the server. I use PHP on the server to handle the incoming form data, and the $_POST
data structure received from the scanner contains only the scanval
input field value, NOT the submit
value.
正如人们可能期望的那样,我通常会寻找 submit
按钮输入,以确认表单已成功发布到服务器.确定扫描器仅发送 scanval
而不发送其他任何内容,花了一段时间,并且抓了很多头.
As one might expect, I normally look for the submit
button input as confirmation that a form has been successfully posted to the server. It took a while, and a lot of head scratching, to determine that the scanner was sending only the scanval
and nothing else.
最后,Windows CE在IE浏览器的设置中有一个 User Agent
配置选项,允许您从以下选项中进行选择: Windows CE
, Pocket PC
或与Windows XP相同
.我发现将它设置为 Windows XP
时似乎效果最好.那不是很明显.
Finally, there is a User Agent
configuration option within the IE browser's settings in Windows CE that allows you to choose from among: Windows CE
, Pocket PC
, or Same as Windows XP
. I found that it seems to work best when set to Windows XP
. That was not obvious.
无论如何,我希望这将来可能对其他人有所帮助!
Anyway, I hope this maybe helps someone else in the future!
这篇关于Datalogic Falcon X3-条形码扫描仪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!