Yılların programcısı olarak kendimi cahilliğin dibinde hissediyorum.
Dll dosyasının adı "plcommpro.dll"
İçinden çağırmak istediğim komut "Connect"
Aşağıdaki şekilde bir komut dizisiyle dll içindeki komuta ulaşabiliyorum.
Fakat dönen değeri bir türlü alamadım.
Kod: Tümünü seç
procedure TForm1.Button1Click(Sender: TObject);
var
DLLHandle: THandle;
CommDLL: TDllFonksiyon;
KomutSTR : String;
DonenDeger:integer;
begin
KomutSTR := 'protocol=TCP,ipaddress=192.168.2.201,port=4370,timeout=2000,passwd=';
DLLHandle := LoadLibrary('plcommpro.dll');
@CommDLL := GetProcAddress(DLLHandle, 'Connect');
if Assigned(@CommDLL) then
begin
DonenDeger := CommDLL(pchar(KomutSTR));
memo1.lines.add('Dönen Değer='+inttostr(DonenDeger));
end
else
memo1.lines.add('Not Assigned');
end;
SDK kullanım kılavuzunda cihaza bağlantıyla ilgili açıklamalar aşağıdaki şekilde.
4. Detailed Description of the PullSDK Interface Functions
4.1 Connect
[Function]
int Connect(const char *Parameters)
[Objective]
The function is used to connect a device. After the connection is successful, the connection handle is returned.
[Parameter description]
Parameters:
[in]: Specify the connection options through the parameter, for example:
"protocol=RS485,port=COM2,baudrate=38400bps,deviceid=1,timeout=50000, passwd=”;
“protocol=TCP,ipaddress=192.168.12.154,port=4370,timeout=4000,passwd=”;
To connect a device, the system needs to transfer the device-related connection parameters.
protocol indicates the protocol used for communication. At present, RS485 and TCP can be used.
port: Communication port of the device. For example, if the RS485 protocol is used, you can set port to COM1: If the TCP is used, the default port is 4370 unless otherwise noted.
deviceid: Device ID used by the serial port.
baudrate: Baud rate used for the communication of the communication of the serial port.
ipaddress: IP address of the related device for TCP/IP communication.
timeout: Timeout time of the connection (unit: ms)If the network connection is in poor condition, you should set the parameter to a larger value. Usually, timeout=5000 (5 seconds) can meet the basic network needs. When the query result contains the error code of -2, you should set timeout to a larger value, for example, timeout=20000 (20 seconds).
passwd: Connection password of the communication. If the parameter value is null, it indicates that no password is used.
(Note: The connection parameters are case-sensitive)
[Returned value]
If the device is connected successfully, the connection handle is returned. Otherwise, the error code of 0 is returned.
[Example]
Python:
params = “protocol=TCP,ipaddress=192.168.12.154,port=4370,timeout=4000,passwd=”
self.commpro = windll.LoadLibrary("plcommpro.dll")
constr = create_string_buffer(params)
self.hcommpro = self.commpro.Connect(constr)
c#:
params = “protocol=TCP,ipaddress=192.168.12.154,port=4370,timeout=2000,passwd=” ;
IntPtr h = Connect(params);
Dll dosyaları ve Kullanım kılavuzunu aşağıdaki linkten indirebilirsiniz.
http://we.tl/mPG40EqvbZ