I'm trying to implement a BINA
with Delphi 7
using Super Bina
!
I added the component in form
and in botão
fiz:
procedure TfrmPrincipal.btnAbreConClick(Sender: TObject);
var
texto: String;
begin
spBina.Conectado:=true;
spBina.LeiaDTMF(texto,100);
ShowMessage(texto);
end;
and no onDTMF
did
procedure TfrmPrincipal.spBinaDTMF(Sender: TObject; Count: Integer);
var
Buffer : String;
Contador: Integer;
begin
// Define o valor do Time Out
Sleep(500);
// Confere o número total de bytes dentro do pacote enviado
Contador := spBina.InputCount;
// Lê o pacote enviado e armazena no Buffer
spBina.Read(Buffer, Contador);
// Alimenta um campo Memo com os dados recebidos
Memo1.Lines.Add(Buffer);
end;
So,
in the code of botão
, on the ring of the phone line I get RING in ShowMessage
. Only that!
in the code of onDTMF
, upon reaching spBina.Read(Buffer, Contador);
, is giving access to memory !
How do I fix this?
// Ler no modo sincrono
function TSspBina.ReadAsync(var Buffer; Count: Integer; var AsyncPtr: PAsync): Integer;
var
Success: Boolean;
BytesTrans: DWORD;
begin
AsyncPtr^.Kind := okRead;
Success := ReadFile(FHandle, Buffer, Count, BytesTrans, @AsyncPtr^.Overlapped)
or (GetLastError = ERROR_IO_PENDING);
if not Success then
raise ECspBina.Create(CError_ReadFailed, GetLastError);
Result := BytesTrans;
end;
When you do ReadFile