Communication with the COM3 port

Asked

Viewed 55 times

0

I’m trying to read the return of an access to the door COM3 which is where the old 56kbps modem is.

Communication is being done and the modem is lugging and receiving outside calls!

But I would like to read the data that the modem can send me.

The connection to the modem port I did so:

...

hCommFile: THandle;
Status: LongBool;
NumberWritten: DWORD;
Buf : array[0..1023] of Byte;
s :string;

.......

//Abre a porta de comunicação
s:='COM3';
hCommFile := CreateFile (
                     PChar(s),
                     GENERIC_READ or GENERIC_WRITE,
                     0, // não compartilhado
                     nil, // sem segurança
                     OPEN_EXISTING,
                     FILE_ATTRIBUTE_NORMAL,
                     0);

// Verifica a abertura da porta
if hCommFile <> INVALID_HANDLE_VALUE then
begin

//Envia a String de Comando
NumberWritten:=0;
Status:= WriteFile(
                    hCommFile,
                    PChar(s)[0],
                    Length(s),
                    NumberWritten,
                    nil);

...

So far so good. But I’m trying to get modem data. I think you need to use the class inputStream but I can’t find anything to Delphi.

I tried that but the code jammed

if FileRead(hCommFile, Buf[0], 1023) = 1 then
begin
   ShowMessage('a');
end;

....

Someone helps.

The goal is to catch a return only and play in a variable!

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.