2011-12-06 39 views
1

現在,我對該類以及如何安裝COMRD800.dll驅動程序(使用命令提示符:regsvr32)有一點了解。使用VB.NET進行RFID編程|第三部分

我使用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」。

Images

正如你所看到的,這個問題我讀值發生。 這是我的項目,如果你想參與我的問題,並找到解決方法。 感謝之前,無論誰試圖解決這個問題。我非常欣賞它。

My Entire Project(包括驅動器和RFID手冊.PDF)

哦,還有一件事,你必須把 「驅動程序(dcrf32.dll,dcrf32.lib,dcrf32.h)文件」 到你的bin或windows/system32 < - 我不知道這是否需要。但是,只要vb.net模塊無法正常工作就嘗試一下。

+0

什麼是錯誤的驅動程序文件說? – PVitt

+0

該文檔根本沒有幫助。 只看到「我的整個項目」鏈接,我也包含了文檔。 這是非常非常簡單,沒有任何解釋。 我一個星期前就自己嘗試一下,現在我搞砸了。 –

回答

1

你的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 
+0

它仍然無法正常工作:( 發生的錯誤是和以前一樣: 「FatalExecutionEngineError」 –

+0

你仍然需要在你的字符串,我錯在它矯正到BYVAL的爲ByRef聲明 –

+0

@ArvidTheodorus我加了一些附加信息 –

相關問題