hola amigos del foro mi problema es que no se programar en delphi soy tecnico electronico y quisiera si alguien me pudiese compilar este programa que en realidad hay 2 versiones si pudiesen las 2 seria muy bueno para ver cual se ad`pta mejor a mis necesidades, porque es mas o menos lo que busco un programa que controle un periferico por puerto serie por tiempo. abajo les dejo un link hacia las fuentes del programa. desde ya muchisimas gracias y deisculpen las molestias
Código Delphi
[-]
function Activar_RTS(Puerto: String; Espera: Cardinal): String;
var hPort: THandle;
DCB: TDCB;
begin
Result:= '';
Puerto:= Uppercase(Puerto); if (Puerto<>'COM1') and (Puerto<>'COM2') then exit;
hPort:= CreateFile(PChar('\\.\'+Puerto), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if hPort<>INVALID_HANDLE_VALUE then begin
DCB.DCBlength:= sizeof(DCB);
if GetCommState(hPort,DCB) then begin
with DCB do begin
BaudRate := CBR_9600;
ByteSize := 8;
Parity := NOPARITY;
StopBits := ONESTOPBIT;
Flags := $01;
end;
if SetCommState(hPort, DCB) then begin
EscapeCommFunction(hPort,SETRTS);
Sleep(Espera);
EscapeCommFunction(hPort,CLRRTS);
end;
end;
CloseHandle(hPort);
end;
end;
y este es otro
Código Delphi
[-]
var hPort: Thandle;
procedure AbrirPuerto(Puerto: String);
var DCB: TDCB;
begin
Puerto:= Uppercase(Puerto); if (Puerto<>'COM1') and (Puerto<>'COM2') then exit;
hPort:= CreateFile(PChar('\\.\'+Puerto), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if hPort<>INVALID_HANDLE_VALUE then begin
DCB.DCBlength:= sizeof(DCB);
if GetCommState(hPort,DCB) then begin
with DCB do begin
BaudRate := CBR_9600;
ByteSize := 8;
Parity := NOPARITY;
StopBits := ONESTOPBIT;
Flags := $01;
end;
if SetCommState(hPort, DCB) then Exit;
end;
CloseHandle(hPort);
hPort:= INVALID_HANDLE_VALUE;
end;
end;
procedure CerrarPuerto;
begin
if hPort <> INVALID_HANDLE_VALUE then begin
CloseHandle(hPort);
hPort:= INVALID_HANDLE_VALUE;
end;
end;
procedure ActivarRTS;
begin
if hPort <> INVALID_HANDLE_VALUE then EscapeCommFunction(hPort,SETRTS);
end;
procedure DesactivarRTS;
begin
if hPort <> INVALID_HANDLE_VALUE then EscapeCommFunction(hPort,CLRRTS);
end;
http://delphi.jmrds.com/?q=node/8