|
Attendance machine dynamic library description:
Explanation: All functions only accept two parameters
Parameter one: Params structure
Parameter 2: A value indicating the type of hardware, value [30, 60, 2000, 2100, 2200, 2300, 2600]
Params structure definition
Public Type Params
Port As String * 3 // Serial port number, [1 ~ 255]
CtrlID As String * 3 // device number, [1 ~ 127]
Params As String * 1024 // Input: The parameter table passed to the device for processing. Multiple parameters are separated by semicolons and terminated with semicolons.
// Output: Interface return value
End Type
Interface return value definition
100 // Failed to call the interface
101 // This type of device is not supported
102 // The device does not support this interface
103 // The device is not responding
104 // parameter error
105 // The call was successful
106 // The serial port is not open
107 // Error opening file
108 // Communication parameter error, request resend
109 // Return value data check error
110 // Create thread error
111 // The device is busy
I. IT2100
Open serial port
statement
Public Declare Function OpenComm Lib "CM60.dll" (ByRef lParam As Params, ByVal sType As Integer) As Integer
Call example
dim p as Params
dim sType as Integer
dim ret as Long
sType = 2100
p.Port = "001" ‘Open serial port one
p.CtrlID = "001" ‘device number is 1
ret = OpenComm (p, sType)
select case ret
case 100 ‘Open failed
case 105 ‘Successful opening of serial port
case else
end select
I tested:
unit Ukq;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class (TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click (Sender: TObject);
private
{Private declarations}
public
{Public declarations}
end;
type
TParams = Record
Port: String [3];
CtrlID: String [3]; // device number, [1 ~ 127]
Params: string [250];
end;
var
Form1: TForm1;
implementation
{$ R * .dfm}
function OpenComm (var lParam: tParams; sType: Integer): Integer; stdcall; external 'CM60.dll';
function CloseComm (var lParam: tParams; sType: Integer): Integer; stdcall; external 'CM60.dll';
procedure TForm1.Button1Click (Sender: TObject);
var
p: TParams;
sType, ret: Integer;
begin
sType: = 2100;
p.Port: = edit1.text;
p.CtrlID: = edit2.Text;
ret: = OpenComm (p, sType);
showmessage (inttostr (ret));
ret: = CloseComm (p, sType);
p.CtrlID: = '';
showmessage (inttostr (ret));
end;
end.
Opening and closing the serial port both returned 100 (failed to call the serial port), and using the terminal management of the time attendance machine can open the first and second serial ports, I do n’t know if there is something wrong with my test program |
|