Further to my previous email, I am trying to implement send serial port
string to a TCPIP port. Although I can install and start the service as soon
as I send data to it I get a windows error message 1073 'The specified
service already exists'. After that I can not restart the service and have
great difficulty in removing it.
 Any Ideas?
This is the code for the offending unit 

Code-------------------------------------

unit SerialCollexServiceUnit2;

interface

uses
  synaser, sysutils,BlckSock, synsock, Classes, inifiles;

type
  TSerialModule1 = class(TDataModule)
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SerialModule1: TSerialModule1;
  ser:TBlockSerial;
  IniFile : TIniFile;
  SerialSock:TTCPBlockSocket;
  par,LCMD,PortNo,ipaddress,ipport:String;
  Baud,databits,stopbits:integer;
  parity:char;
  hardwarefl,softwarefl:boolean;


   procedure sendcallstring(input:string);


implementation

{$R *.dfm}

 procedure sendcallstring(input:string);
 Begin
 SerialSock:=TTCPBlockSocket.Create;
 try
 SerialSock.RaiseExcept :=false;
 SerialSock.Connect(ipaddress,ipport);
 if SerialSock.lastError<>0 then exit;
 if SerialSock.CanWrite(1000) then
 SerialSock.SendString(input+CRLF);
 finally
 SerialSock.Free
 end;
 End;

procedure TSerialModule1.DataModuleCreate(Sender: TObject);
begin

    IniFile := TIniFile.Create('serialcollex.ini');
    PortNo := IniFile.ReadString('serial','PortNo','COM1');
   Baud := IniFile.Readinteger('serial','baud',9600);
   databits := IniFile.ReadInteger('serial','databits',8);
   stopbits := IniFile.ReadInteger('serial','stopbits',0);
   par := IniFile.ReadString('serial','parity','N');
   parity := par[1];
   hardwarefl := IniFile.Readbool('serial','hardwarefl',false);
   softwarefl := IniFile.Readbool('serial','softwarefl',false);
   ipaddress := IniFile.ReadString('tcpip','ipaddress','127.0.0.1');
   ipport := IniFile.ReadString('tcpip','ipport','4515');
   ser:=TBlockserial.Create;
   try

     ser.RaiseExcept:=false;
     ser.Connect(PortNo);
     ser.Config(Baud,databits,parity,stopbits ,softwarefl,hardwarefl);

     while not (ser.LastError <> 0) do begin
            if ser.lastError<>0 then break;
              if ser.canread(1000) then  begin
              LCMD := ser.Recvstring(1000);
              writeLn(LCMD);
              sendcallstring(LCMD);
              end;

     end;
   finally
     ser.Free;
end;

end;

end.

End of code------------------------------------------------------


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to