• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
November 21, 2024, 05:47:59 am

News:

SMF - Just Installed!


Save the data from nrTerminal

Started by ToeKneeH72, July 08, 2021, 11:28:57 am

Previous topic - Next topic

ToeKneeH72

I've a very simple application that uses TnrComm, TnrTerminal and a Tmemo the application is used to configure switches/routers etc via the seral port this all works fine, no issues. What I would like to do is save the output from TnrTerminal to a text file so it can be checked for errors/QA purposes. I tried nrTerminal1.Lines.SaveToFile but this just saves an empty text file. I also tried

procedure TForm1.nrComm1AfterReceive(Com: TObject; Buffer: Pointer;
  Received: Cardinal);
var i:integer;
    s:string;
begin
  s:='';
  for i:=0 to Received-1
  do s:=s+PAnsiChar(Buffer);
  memo1.Text := memo1.text + S;
end;

but this only returned the command I sent, not the response.


I'm sure the solution to this will be very simple, please note I'm very new to all this and just seem to be  going round in circles.

kind regards

Tony

Roman Novgorodov

Possible you forget index i in Buffer pointer?
See corrected sample:

procedure TForm1.nrComm1AfterReceive(Com: TObject; Buffer: Pointer;
  Received: Cardinal);
var i:integer;
    s:string;
begin
  s:='';
  for i:=0 to Received-1
    do s:=s+AnsiChar(PAnsiChar(Buffer)[i]);
  memo1.Text := memo1.text + S;
end;
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

ToeKneeH72

Roman,

Thank you so much, all working now


Tony