使用VB.NET 进行RFID 编程|第三部分

发布于 2024-12-19 15:16:42 字数 1680 浏览 4 评论 0原文

现在,我对这个类以及如何安装 COMRD800.dll 驱动程序有了一些了解(使用命令提示符:regsvr32)。

我使用 Visual Studio 2010 作为文本编辑器,使用 VB.NET 作为编程语言。

但我在这里,另一个问题又在追赶我。我不知道我的错在哪里。

首先,我想解释一下,当使用这个 RF ID 时,在从 RF ID 标签写入和读取十六进制密钥之前需要调用一些函数。 以下是我在写作或阅读之前必须使用的功能。

dc_init(100,115200) 'to open the port, this should be initialized first
dc_beep(icdev,10) 'just to make the device beeping
dc_load_key_hex(icdev,0,0,"ffffffffffff") 'initializing the device key
dc_request(icdev,0,tagtype) 'to get the Card Tag Type
dc_anticoll(icdev,0,snr) 'to get the card's serial number
dc_select(icdev,snr,sizeA) 'to get the size of the card's memory to pc (it always "8")
dc_authentication(icdev,0,0) 'to pass the authentication
dc_write_hex(icdev,1,TestStr) 'writing to the RF ID tag with string TestStr
dc_read_hex(icdev,1,TestStr2) 'Nah, here is where the error occured. 

TestStr2是一个引用变量,换句话说,十六进制的值将存储在那里。 (我应该打印 TestStr2 以从 RF ID 标签获取十六进制值)

当函数返回“0”时,意味着“正确”或正在工作。 但是当函数返回<>时0 表示“有问题”。

到目前为止,它们都返回“0”。 (除了存在错误的 dc_read_hex)。

解释: 这些函数来自驱动程序(dcrf32.dll 文件)。要在我的项目中使用它们,我必须在 VB.NET 模块文件中声明它们。 (在我的项目中,它是“KoneksiRFID.vb”文件)。

到目前为止,我对这些功能没有任何问题,但是当我到达“读取”部分(dc_read_hex 函数)时,我遇到了错误。 它说“FatalExecutionEngineError”。

图像

如您所见,当我读取该值时出现问题。 如果您想参与我的问题并找到解决问题的方法,这是我的项目。 感谢之前尝试解决这个问题的人。我非常欣赏它。

我的整个项目(包括其驱动程序和 RFID 手册 .pdf)

哦,还有一件事,您必须将“驱动程序(dcrf32.dll、dcrf32.lib、dcrf32.h)文件”放入您的 bin 或 windows/system32 <-- i不知道这是否需要。但是,当 vb.net 模块无法正常工作时,请尝试一下。

Now, i know a little bit about the class and how to install the COMRD800.dll driver (using command prompt : regsvr32).

I'm using Visual Studio 2010 as my text editor, and VB.NET as my programming language.

But here i am, another problem is chasing me again. I don't know where is my fault.

First, i wanna explain, that when using this RF ID, there are some function to be called before writing and reading the hex key from RF ID tag.
Here are the functions that i have to use before writing or reading.

dc_init(100,115200) 'to open the port, this should be initialized first
dc_beep(icdev,10) 'just to make the device beeping
dc_load_key_hex(icdev,0,0,"ffffffffffff") 'initializing the device key
dc_request(icdev,0,tagtype) 'to get the Card Tag Type
dc_anticoll(icdev,0,snr) 'to get the card's serial number
dc_select(icdev,snr,sizeA) 'to get the size of the card's memory to pc (it always "8")
dc_authentication(icdev,0,0) 'to pass the authentication
dc_write_hex(icdev,1,TestStr) 'writing to the RF ID tag with string TestStr
dc_read_hex(icdev,1,TestStr2) 'Nah, here is where the error occured. 

TestStr2 is a refference variable, in other words, the value of hex would be stored there.
(i should print the TestStr2 to get hex value from RF ID tag)

When the function return "0" it means "correct" or working.
But when the function return <> 0 it means "something is wrong".

This far, they all return "0". (Except the dc_read_hex where the error existed).

Explaining :
Those functions came from the driver (dcrf32.dll file). To use them in my project, i must declare them in my VB.NET Module file. (in my project it's the "KoneksiRFID.vb" file).

So far i have no problem with the functions, but when i get to the "reading" part (dc_read_hex function) i have an error.
It said "FatalExecutionEngineError".

Images

As you can see, the problem occured when i read the value.
Here is my project if you want to participate in my problem and find a way to solve them.
Thanks Before, for whoever tried to solve this problem. I Appreciate it so much.

My Entire Project (including its driver and RFID manual .pdf)

Oh one more thing, you have to put the "driver (dcrf32.dll, dcrf32.lib,dcrf32.h) files" to your bin or windows/system32 <-- i don't know if this required or not. But, just try it when the vb.net module didn't work properly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-12-26 15:16:42

您的 VB6 定义是这样的:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Long, ByVal adr%, ByVal sdata$) As Integer

您当前的定义是这样的,您还没有调整 adr 的数据类型或返回值:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr%, ByRef sdata$) As Integer

尝试将其定义为:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr as Short, ByRef sdata as String) As Short

编辑:

从这里尝试一下 MSDN 页面您可能需要添加 Imports System.RunTime.InteropServices

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr as Short, <MarshalAs(UnmanagedType.LPTStr)> sdata as String) As Short

Your VB6 definition is this:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Long, ByVal adr%, ByVal sdata$) As Integer

You currently have your definition as this, you have not adjusted the data type of adr or the return value:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr%, ByRef sdata$) As Integer

Try defining it as:

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr as Short, ByRef sdata as String) As Short

Edit:

Give this a try from this MSDN page you will probably have to add Imports System.RunTime.InteropServices.

Declare Function dc_read_hex Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal adr as Short, <MarshalAs(UnmanagedType.LPTStr)> sdata as String) As Short
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文