- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
任何人都可以帮助我解释我在尝试使用 dll 打开端口时遇到的这个错误。当我调用 SAAT_Open(myCharPtrOpen) 时,出现错误:“地址 0003D078 处的访问冲突”。不确定我是否在单元 UntRFIDAPI 上正确定义了句柄。变量 PHandle 定义正确吗?这是我的代码:
procedure TForm5.Button1Click(Sender: TObject);
var
myString, myString2 : string;
myCharPtrInit: PChar;
myCharPtrOpen: PChar;
i : Integer;
Open, Init: Boolean;
begin
// Create a string of Char's
myString := '&hp';
// Point to the first character in the string
i := 1;
myCharPtrInit := Addr(myString[i]);
if SAAT_TCPInit(myCharPtrInit,'192.168.3.238',7086) = True then
begin
StatusBar1.Panels[0].Text := 'Initiated'; //ShowMessage('Initiated');
myString2 := 'hp';
myCharPtrOpen := Addr(myString2[i]);
if SAAT_Open(myCharPtrOpen) = True then StatusBar1.Panels[1].Text := 'Opened';
end;
end;
unit UntRFIDAPI;
INTERFACE
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Dialogs,
StdCtrls, Forms, DBCtrls, DB, Grids, DBGrids,Mask, ExtCtrls,
Buttons, WinTypes;
var
A: String;
function SAAT_TCPInit(pHandle: Pointer; pHostName: String; nsocketPort: Integer):Boolean; stdcall;
function SAAT_Open(pHandle: Pointer):Boolean; stdcall;
function SAAT_Close(pHandle: Pointer):Boolean; stdcall;
implementation
function SAAT_TCPInit; external 'RFIDAPI.dll';
function SAAT_Open; external 'RFIDAPI.dll';
function SAAT_Close; external 'RFIDAPI.dll';
end.
这是 API 调用:
1.1 初始化网口(TCP)连接
//TCP parameters initialization
//Functionality:import by parameter, initialize TCP to prepare for opening connection
//Parameters:
// pHandle for preserving the opening ports handl
// pHostName reader IP address, only effective under the ethernet communication
// nsocketPort network SOCKET port
//Returned value:true: Operation Succeeded, false Operation Failed
bool SAAT_TCPInit (void** pHandle,char *pHostName,int nsocketPort)
如果连接读写器的IP为192.168.0.238,端口为7086,则调用如下:
HANDLE hp;
if (!SAAT_TCPInit(&hp, ”192.168.0.238”, 7086))
{
printf("reader initialization failed!\n");
return false;
}
最佳答案
正如 Rudy 和 David 所指出的,您对 SAAT_TCPInit()
函数签名的翻译是错误的,您对这个 API 的指针句柄的使用也是错误的。他们已经解释了为什么你的代码是错误的,所以我不再重复原因。不过,他们的答案存在一些小问题。
您的 Delphi 代码应该看起来更像这样:
unit UntRFIDAPI;
interface
function SAAT_TCPInit(out pHandle: Pointer; pHostName: PAnsiChar; nsocketPort: Integer): Boolean; stdcall;
function SAAT_Open(pHandle: Pointer): Boolean; stdcall;
function SAAT_Close(pHandle: Pointer): Boolean; stdcall;
implementation
const
RFIDAPIDLL = 'RFIDAPI.dll';
function SAAT_TCPInit; external RFIDAPIDLL;
function SAAT_Open; external RFIDAPIDLL;
function SAAT_Close; external RFIDAPIDLL;
end.
procedure TForm5.Button1Click(Sender: TObject);
var
hp: Pointer;
begin
if SAAT_TCPInit(hp, '192.168.3.238', 7086) then
begin
StatusBar1.Panels[0].Text := 'Initiated';
if SAAT_Open(hp) then
StatusBar1.Panels[1].Text := 'Opened';
...
SAAT_Close(hp);
end;
end;
作为引用,这里是 DLL 的 RFIDAPIEXPORT.h
的内容C++ 的头文件:
/***********************************************************************
* Module: RFIDEXPORT.h
* Author:
* Modified:
* Purpose:
***********************************************************************/
#pragma once
#ifndef _RFIDEXPORT_H
#define _RFIDEXPORT_H
#ifdef RFIDAPI_EXPORTS
#define RFID_API __declspec( dllexport )
#else
#define RFID_API __declspec( dllimport )
#endif
extern "C"
{
bool RFID_API __stdcall SAAT_TCPInit(void** pHandle,char *pHostName,int nsocketPort);
bool RFID_API __stdcall SAAT_COMInit(void** pHandle,unsigned char nBusAddr,char *pComNum,int nBaud );
bool RFID_API __stdcall SAAT_USBInit(void** pHandle,unsigned char nBusAddr,char * pUSBNum,int nBaud );
bool RFID_API __stdcall SAAT_UDPInit(void** pHandle,char *pHostName,int nsocketPort);
bool RFID_API __stdcall SAAT_Open(void* pHandle);
bool RFID_API __stdcall SAAT_Close(void *pHandle);
bool RFID_API __stdcall SAAT_Reconnect(void *pHandle);
bool RFID_API __stdcall SAAT_HeartSend (void* pHandle);
bool RFID_API __stdcall SAAT_SysInfSet (void* pHandle ,unsigned char nType,unsigned char* pParm,int nLen);
bool RFID_API __stdcall SAAT_SysInfQuery (void* pHandle ,unsigned char nType, unsigned char *pPara, unsigned char *pLen);
bool RFID_API __stdcall SAAT_WorkModeSet (void* pHandle ,unsigned char nType);
bool RFID_API __stdcall SAAT_ParmOp (void* pHandle ,unsigned char nType, unsigned char nStartAddrr, unsigned char nLen, unsigned char *pData, unsigned char *pDataLen);
bool RFID_API __stdcall SAAT_RFParaSet (void* pHandle ,unsigned char nType, unsigned char nParaLen,unsigned char* pPara);
bool RFID_API __stdcall SAAT_RFParaQuery (void* pHandle ,unsigned char nType,unsigned char* pPara, unsigned char *pLen);
bool RFID_API __stdcall SAAT_CommunicatParaSet (void* pHandle ,unsigned char nType, unsigned char* pPara, unsigned char nLen);
bool RFID_API __stdcall SAAT_CommunicatParaQuery (void* pHandle ,unsigned char nType, unsigned char* pPara,unsigned char *pLen);
bool RFID_API __stdcall SAAT_NetParaSet (void* pHandle ,unsigned char nType, unsigned char* pPara, unsigned char nLen);
bool RFID_API __stdcall SAAT_NetParaQuery (void* pHandle ,int nType, unsigned char* pPara,unsigned char *pLen);
bool RFID_API __stdcall SAAT_TagOpParaSet(void* pHandle ,unsigned char nType, unsigned char *pPara,unsigned char nLen);
bool RFID_API __stdcall SAAT_TagOpParaQuery (void* pHandle ,unsigned char nType, unsigned char* pPara, unsigned char *pLen);
bool RFID_API __stdcall SAAT_ExtendBroadParaSet (void* pHandle ,unsigned char nType, unsigned char pSendChunnel);
bool RFID_API __stdcall SAAT_ExtendBroadParaQuery (void* pHandle ,unsigned char nType, char* pPara, unsigned char* pLen);
bool RFID_API __stdcall SAAT_TotalAntennaParmQuery (void* pHandle,unsigned char *szAntennaPara,unsigned char *pLen);
bool RFID_API __stdcall SAAT_AntennaParmQuery (void* pHandle,unsigned char nAntenna,unsigned char * pAntennaEnable,unsigned char *pAntennaPower,unsigned char *pAntennaQueryTime );
bool RFID_API __stdcall SAAT_AntennaParmSet(void* pHandle ,unsigned char *pPara,unsigned char nLen );
bool RFID_API __stdcall SAAT_SetAntennaPortEnable (void* pHandle,unsigned char nAntenna,unsigned char nEnable );
bool RFID_API __stdcall SAAT_SetAntennaPower (void* pHandle,unsigned char nAntenna,unsigned char nPower );
bool RFID_API __stdcall SAAT_SetAntennaTime (void* pHandle,unsigned char nAntenna,unsigned char nTime );
bool RFID_API __stdcall SAAT_PowerOff(void *pHandle);
bool RFID_API __stdcall SAAT_CarrierWaveOp(void* pHandle ,unsigned char nType, unsigned char nPort);
bool RFID_API __stdcall SAAT_IOOperate(void* pHandle,unsigned char nPort,unsigned char nState);
bool RFID_API __stdcall SAAT_IOStateQuery(void* pHandle,unsigned char *pState);
bool RFID_API __stdcall SAAT_Reboot (void* pHandle,unsigned char nMode);
bool RFID_API __stdcall SAAT_Reading_IOConfig (void* pHandle,unsigned char nConfigBit);
bool RFID_API __stdcall SAAT_Reading_IOQuery (void* pHandle,unsigned char* pConfigBit);
bool RFID_API __stdcall SAAT_IOPulseWidthSet (void* pHandle,unsigned char nIOPort,unsigned char nWidth);
bool RFID_API __stdcall SAAT_IOPulseWidthQuery (void* pHandle,unsigned char nIOPort,unsigned char* pWidth);
bool RFID_API __stdcall SAAT_6BTagSelect ( void* pHandle, unsigned char nType, unsigned char nStartAddr,
unsigned char nDataBite, unsigned char * Data );
bool RFID_API __stdcall SAAT_6BReadUIDCode (void *pHandle,unsigned char nAntenna,unsigned char nType);
int RFID_API __stdcall SAAT_6BRevUIDMsg (void *pHandle, unsigned char* nAntenna, unsigned char* pUIDData,
unsigned char* nUIDLen);
bool RFID_API __stdcall SAAT_6BReadUserData ( void *pHandle ,unsigned char nAntenna,unsigned char nType,unsigned char * pTagID,unsigned char nStartAddr,unsigned char nReadLen, unsigned char *pdata,unsigned char dataLen);
bool RFID_API __stdcall SAAT_6BWriteUserData (void* pHandle,
unsigned char nAntenna,
unsigned char nType,
unsigned char *pTagID,
unsigned char nStartAddr,
unsigned char *pValue,
unsigned char *pLen);
bool RFID_API __stdcall SAAT_6BTagLock (void* pHandle, unsigned char nAntenna, unsigned char nType,
unsigned char *pTagID, unsigned char nStartAddrr, unsigned char nLen);
bool RFID_API __stdcall SAAT_6BTagLockQuery (void* pHandle, unsigned char nAntenna,
unsigned char *pTagID, unsigned char nStartAddr, unsigned char nLen,unsigned char *pData,unsigned char nDataLen);
bool RFID_API __stdcall SAAT_6CTagSelect ( void *pHandle, unsigned char nBank ,unsigned short nStartAddr,unsigned char MaskBit,
unsigned char *Data ,unsigned char Datalength,unsigned char nSessionZone,
unsigned char nActiveFlag, unsigned char nCutFlag );
bool RFID_API __stdcall SAAT_6CReadEPCCode ( void *pHandle,unsigned char nAntenna, unsigned char nType,
unsigned int nTagCount);
int RFID_API __stdcall SAAT_6CRevEPCMsg (void *pHandle, unsigned char* nAntenna, unsigned char* pEPCData,
unsigned char* nEPCLen);
bool RFID_API __stdcall SAAT_6CReadTIDCode ( void *pHandle,unsigned char nAntenna, unsigned char nType, unsigned int nTagCount);
int RFID_API __stdcall SAAT_6CRevTIDMsg (void *pHandle, unsigned char* nAntenna, unsigned char* pTIDData, unsigned char* nTIDLen);
bool RFID_API __stdcall SAAT_6CWriteEPCCode ( void* pHandle,unsigned char nAntenna,unsigned char nType,
unsigned char *pAccessPWD, unsigned char *pWriteData,unsigned char nLen );
bool RFID_API __stdcall SAAT_6CReadUserData ( void* pHandle,
unsigned char nAntenna,
unsigned int StartAddr,
unsigned int nToReadLen,
unsigned int nWaitTime,
unsigned char * UserData,
unsigned int* pDataLen);
bool RFID_API __stdcall SAAT_6CWriteUserData (void* pHandle,
unsigned char nAntenna,
unsigned char nType,
unsigned char *pAccessPWD,
unsigned int nStartAddr,
unsigned int nWaitTime,
unsigned char *pWriteData,
unsigned int *pToWriteLen);
bool RFID_API __stdcall SAAT_6CWriteBankData (void* pHandle, unsigned char nAntenna, unsigned char nType, unsigned char *pAccessPWD,
unsigned char nBank, unsigned char *pWriteData, unsigned char nLen);
bool RFID_API __stdcall SAAT_6CClearBankData (void* pHandle, unsigned char nAntenna, unsigned char nType, unsigned char *pAccessPWD,
unsigned char nBank, unsigned char nStartAddr, unsigned char nLen);
bool RFID_API __stdcall SAAT_6CAccessPWDSet (void *pHandle, unsigned char nAntenna, unsigned char nType, unsigned char *pOrgPWD,
unsigned char *pNewPWD);
bool RFID_API __stdcall SAAT_6CDestroyPWDSet (void *pHandle, unsigned char nAntenna,unsigned char nType, unsigned char *pAccessPWD,
unsigned char *pDestroyPWD );
bool RFID_API __stdcall SAAT_6CTagLock (void *pHandle, unsigned char nAntenna, unsigned char *pAccessPWD, unsigned char nType,
unsigned char nBank);
bool RFID_API __stdcall SAAT_6CTagKill (void *pHandle, unsigned char nAntenna,unsigned char *pDestroyPWD,
unsigned char *pEPC, int nEPCLen);
bool RFID_API __stdcall SAAT_6CEASFlagSet (void *pHandle, unsigned char nAntenna, unsigned char nType,
unsigned char* pAccessPwd, int nEASFlag);
bool RFID_API __stdcall SAAT_6CEASMonitorEnable (void *pHandle, unsigned char nAntenna,unsigned char nSetEAS);
bool RFID_API __stdcall SAAT_Copyright(void** pHandle, char* copyright);
bool RFID_API __stdcall SAAT_SetLanguageType (void* pHandle,char* szType);
bool RFID_API __stdcall SAAT_GetErrorMessage(void *pHandle,char *szMsg, int nLen);
bool RFID_API __stdcall SAAT_GetErrorCode(void *pHandle,int *pCode);
bool RFID_API __stdcall SAAT_SysTest(void* pHandle ,unsigned char nType,unsigned char nAntenna, unsigned char *pTestParm, unsigned char nLen);
bool RFID_API __stdcall SAAT_RawSendData(void* pHandle , unsigned char *pSendData, unsigned char nLen);
bool RFID_API __stdcall SAAT_RawRevData(void* pHandle , unsigned char *pRecvData, unsigned char* pLen,int nWaitTime);
bool RFID_API __stdcall SAAT_RawSendAndRevData(void* pHandle ,
unsigned char *pSendData,
unsigned char nLen,
unsigned char *pRecvData,
unsigned char *pLen,
unsigned char nWaitTime);
bool RFID_API __stdcall SAAT_EnterTrans(void* pHandle ,unsigned char nType);
bool RFID_API __stdcall SAAT_ResetWifiBaund(void* pHandle);
};
#endif
这里是 DLL 文档的链接:
关于delphi - 任何人都可以帮助我解释我在尝试使用 dll 打开端口时遇到的这个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26819899/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!