Home > Back-end >  For help with Delphi realize hai kang DVR485 interface lit channel data problem
For help with Delphi realize hai kang DVR485 interface lit channel data problem

Time:10-01

Hai kang SDK documentation is written in C that:
Void CALLBACK g_fSerialDataCallBack (LONG lSerialHandle, char * pRecvDataBuffer, dwords dwBufSize, dwords dwUser)
{
//... In processing the received passthrough data, pRecvDataBuffer store the received data
}


LTranHandle=NET_DVR_SerialStart (lUserID iSelSerialIndex, g_fSerialDataCallBack, lUserID);//set the callback function to obtain passthrough data

Turn to ace to give directions Delphi should be how to use a callback function to receive data, thank you.

CodePudding user response:

Has the use of Delphi in hai kang SDK development, give an other function, such as the preview image through the callback function to receive data code for learning, seek advice, thank you very much,

CodePudding user response:

Ah, wow good early, never used, help top it

CodePudding user response:

Procedure g_fSerialDataCallBack (lSerialHandle: long; PRecvDataBuffer: pchar; DwBufSize dwUser: DWORD); Stdcall; External '. Your DLL '

CodePudding user response:

My problem is not sure whether the callback function to deal with correctly,
VC is using DLL library NET_DVR_SerialStart function like this:

# define NET_DVR_API extern "C" __declspec (dllimport)

NET_DVR_API LONG __stdcall NET_DVR_SerialStart (LONG lUserID, LONG lSerialPort, void (CALLBACK * fSerialDataCallBack) (LONG lSerialHandle, char * pRecvDataBuffer, dwords dwBufSize, dwords dwUser), dwords dwUser);//to explain the entry of function and parameter


Void CALLBACK g_fSerialDataCallBack (LONG lSerialHandle, char * pRecvDataBuffer, dwords dwBufSize, dwords dwUser)
{
//... Write a callback function to handle the received passthrough data, to store the data received in the pRecvDataBuffer
}


LTranHandle=NET_DVR_SerialStart (lUserID iSelSerialIndex, g_fSerialDataCallBack, lUserID);//initialize serial port, set the callback function to obtain passthrough data

Consult in Delphi loading DLL entry, how to define NET_DVR_SerialStart function call that parameter type, I just don't know how to deal with the third parameter (called a function pointer?) .

CodePudding user response:

Procedure g_fSerialDataCallBack (lSerialHandle: Cardinal; PRecvDataBuffer: PChar; DwBufSize: Cardinal; DwUser: Cardinal);
The begin
//... In processing the received passthrough data, pRecvDataBuffer store the received data
end;

CodePudding user response:

 

Type
//HCNetSDK header file type declaration Delphi rewrite

Basic data type declarations//
DWORD=LongWord;
//WORD: WORD;
USHORT=Word;
LONG=Longint;
//BYTE=char;
//# define BOOL int
UINT=Longword;
LPVOID=Pointer;
HANDLE=Pointer;
LPDWORD=^ LongWord;
//typedef unsigned long long UINT64;

//NET_DVR_Login_V30 parameter structure ()
Type LPNET_DVR_DEVICEINFO_V30=^ NET_DVR_DEVICEINFO_V30;
NET_DVR_DEVICEINFO_V30=Record
SSerialNumber: array [0..] SERIALNO_LEN - 1 BYTE,//serial number
ByAlarmInPortNum: BYTE;//alarm input number
ByAlarmOutPortNum: BYTE;//alarm output number
ByDiskNum: BYTE;//hard disk number
ByDVRType: BYTE;//device type, 1:2: DVR ATM DVR 3: DVS...
ByChanNum: BYTE;//analog channel number
ByStartChan: BYTE;//the start channel number, such as DVS - 1, DVR - 1
ByAudioChanNum: BYTE;//voice channel number
ByIPChanNum: BYTE;//maximum number of digital channels
ByZeroChanNum: BYTE; Channel coding number////zero 2010-01-16
ByMainProto: BYTE;//the main stream 0 - private transport protocol type, 1 - RTSP
BySubProto: BYTE;//subcode streaming protocol type 0 - private, 1 - RTSP
BySupport: BYTE;//ability, and the result is 0 said does not support, 1,
//bySupport & amp; 0 x1, said support intelligent search
//bySupport & amp; 0 x2, indicates whether or not the backups
//bySupport & amp; 0 x4, indicates whether or not the ability to support compression parameters for
//bySupport & amp; By 8, 0 indicates whether or not the support for multiple network card
//bySupport & amp; 0 x10, expressed support for remote SADP
//bySupport & amp; 0 x20, expressed support for the Raid card function
//bySupport & amp; 0 x40, expressed support for IPSAN directory lookup
//bySupport & amp; 0 x80, expressed support for RTP over RTSP
BySupport1: BYTE;//ability set extension, and the result is 0 said does not support, expressed support for 1
//bySupport1 & amp; 0 x1, said whether to support the SNMP v30
//bySupport1 & amp; 0 x2, support to distinguish the playback and download
ByRes1: BYTE;
WDevType: WORD;//device type
ByRes2: array [0.. 15] of BYTE;//keep
end;
//NET_DVR_Login_V30 () parameter structure end


//callback function has no return value statement for process
Type fSerialDataCallBack=procedure (lSerialHandle: LONG; PRecvDataBuffer: PChar; DwBufSize: DWORD; DwUser: DWORD);//stdcall;
//type fSerialDataCallBack=procedure (lSerialHandle: LONG; PRecvDataBuffer: PChar; DwBufSize: DWORD; DwUser: DWORD) of the object;//stdcall;//external 'HCNetSDK. DLL';



//to automatically generate
TForm1=class (TForm)
Memo1: TMemo;
For: TButton;
Button2: TButton;
Label1: TLabel;
Edit1: TEdit;
Button3: TButton;
Label2: TLabel;
Edit2: TEdit;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Procedure Button1Click (Sender: TObject);
Procedure Button2Click (Sender: TObject);
Procedure Button3Click (Sender: TObject);
Procedure Button4Click (Sender: TObject);
Procedure Button5Click (Sender: TObject);
Procedure Button6Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;

Var
Form1: TForm1;
ErrorValues: LongWord;
SzSendBuf: array [0.. 10] of char;
SzReciBuf: array [0.. 10] of char;
//g_fSerialDataCallBack: fSerialDataCallBack;
LUserID: LONG;
StruDeviceInfo: NET_DVR_DEVICEINFO_V30;
DVRIP DVRUserName, DVRPassWord: String;
LTranHandle: LONG;
ISelSerialIndex: integer;
DwUser: DWORD;
LSerialChan: LONG;




//procedure g_fSerialDataCallBack (lSerialHandle: LONG; PRecvDataBuffer: PChar; DwBufSize: DWORD; DwUser: DWORD); Stdcall; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related