Lee Jenkins wrote:
Hi all,
I'm try to write a console application that interfaces with Asterisk
PBX. The pbx communicates with the console application over stndin and
stdout.
Hi all, after trying a number of different ways to get this to work, I
have found a way.
For some reason, it does not appear to me that using standard Writeln()
to send commands to Asterisk are ignored for some reason, even when
appending #10 or #13#10 or #13 to the end.
At any rate, following the example here:
http://www.freepascal.org/docs-html/rtl/system/flush.html
I create explicit file associate with stdout:
var
F: Text;
sRead, sRet: string;
begin
repeat;
begin
Readln(sRead);
// other assign values as needed
end;
until (sRead = '');
Assign(F,'');
Rewrite(F);
Write('NOOP Here is some sample output to CLI' + #10);
Flush(F);
ReadLn(sRet);
Close(f);
end;
One thing that I ran across was that if I also tried to ReadLn using the
explicit F file, I got an AV.
So it seems (at least for me and my particular setup) that ReadLn reads
ok with Asterisk, but an explicit control over stdout must be used with
explicit flush()'s to ensure that Asterisk gets the ouputted command.
Keep in mind that I am not debugging my app in real time. I'm compiling
it on a VMWare linux image on my windows box and then copying it over to
my asterisk linux box. Just been using a lot of file logging to see
what's going on under the hood when the app runs.
--
Warm Regards,
Lee
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives