library strings_dll;
uses
SysUtils, AdPacket, AdPort,Dialogs,Windows, Messages, Variants, Classes, Graphics, Controls,
Forms, StdCtrls;
type
Tmyclass =
class(TObject)
procedure GetString(Sender: TObject; robotString:
String);
// Event
private
public
end;
var
x,y:integer;
datapacket1: TApdDataPacket;
COM_port1: TApdComPort;
myarray:
array[0..5]
of string;
test2:
array[0..5]
of PChar;
{$R *.res}
procedure Tmyclass.GetString(Sender: TObject; robotString:
String);
begin
showmessage('
Endstring detected');
end;
procedure init();
stdcall;
begin
datapacket1:=TApdDataPacket.Create(
nil);
// nill because we dont have a FORM !
myclass:=Tmyclass.Create;
COM_port1:=TApdComPort.Create(
nil);
//init COM-port properties & events
//---------------------------------------------
COM_port1.Open:=True;
COM_port1.Baud:=115200;
COM_port1.CommNotificationLevel:=10;
COM_port1.DataBits:=8;
COM_port1.DTR:=True;
COM_port1.InSize:=4096;
COM_port1.Logging:=tlOff;
COM_port1.OutSize:=4096;
COM_port1.Parity:=pNone;
COM_port1.StopBits:=1;
COM_port1.Tracing:=tlOff;
COM_port1.RTS:=True;
COM_port1.PromptForPort:=True;
COM_port1.XOnChar:=#17;
COM_port1.XOffChar:=#19;
COM_port1.HWFlowOptions:=[];
COM_port1.SWFlowOptions:=swfNone;
COM_port1.Tag:=0;
COM_port1.AutoOpen:=True;
COM_port1.BufferFull:=0;
COM_port1.BufferResume:=0;
//init all the datapacket properties & events
//---------------------------------------------
datapacket1.AutoEnable:=True;
datapacket1.Enabled:=True;
datapacket1.StartCond:=scString;
datapacket1.StartString:='
?';
//Works!?
datapacket1.EndCond:=[ecString];
datapacket1.EndString:=^M^J;
//LF = ^J = #10
datapacket1.PacketSize:=100;
datapacket1.TimeOut:=2184;
//ca 2 min
datapacket1.ComPort:=COM_port1;
//userdefined com port
datapacket1.IncludeStrings:=True;
datapacket1.OnStringPacket:=myclass.GetString;
// does not work ???
end;
procedure close_t();
stdcall;
begin
COM_port1.Free;
myclass.Free;
datapacket1.Free;
end;
exports
init, close_t;
begin
end.