Writeln and my own procedure

  • 1
  • 2
  • Page 1 of 2
Cusko
 
Avatar
 
Subject:

Writeln and my own procedure

 · 
Posted: 13.07.2010 - 09:05  ·  #1
Hello

Is it possible to use my own procedure in writeln() function?

E.g.
Code

procedure EthOut;
begin
end;

writeln(EthOut, ' ');


Thanks
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Writeln and my own procedure

 · 
Posted: 13.07.2010 - 12:16  ·  #2
Take a look at UsbOut() that I have implemented for use in WriteLn() here: topic.php?p=11320
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Writeln and my own procedure

 · 
Posted: 13.07.2010 - 12:17  ·  #3
Hello Cusko,

if you write

{$DEVICE}
Procedure EthOut(b : byte);

then it should work.

rolf
Cusko
 
Avatar
 
Subject:

Re: Writeln and my own procedure

 · 
Posted: 14.07.2010 - 14:36  ·  #4
Thank you for help,

I am interested in this because you can then simply change from SerOut to Ethernet in existing code.
But I find out from compiler manual that you can use only 8-bit variables in this case and sending one by one byte over ethernet is little to much.
Any other solution maybe?
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Writeln and my own procedure

 · 
Posted: 14.07.2010 - 17:27  ·  #5
you can send it in loop by using your device procedure.
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Writeln and my own procedure

 · 
Posted: 14.07.2010 - 18:08  ·  #6
Quote by Cusko

I am interested in this because you can then simply change from SerOut to Ethernet in existing code.
But I find out from compiler manual that you can use only 8-bit variables in this case and sending one by one byte over ethernet is little to much.
Any other solution maybe?


You can cache EthOut() data in some array until CR or some special character arrives, and only then send whole array via ethernet.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Writeln and my own procedure

 · 
Posted: 14.07.2010 - 18:10  ·  #7
Hi Cusko.

When you are developing your own drivers you can do pretty well what you like. So just because WriteLn (and indeed Write) call your routine character by character, that doesn't mean that you have to send them by ethernet that way. You could, for example, store them to a buffer and only send via ethernet after a certain number of characters have been received or after a time out. This is transparent to any procedures outside your driver procedures. (Obviously you would need to test for timeout on a regular basis).

Hope this helps.

Merlin.
Cusko
 
Avatar
 
Subject:

Re: Writeln and my own procedure

 · 
Posted: 15.07.2010 - 13:35  ·  #8
Thanks for suggestions

I will try to save into buffer.
I already tried similar thing but obviously wrong way.

My code was
Code

{$DEVICE}
procedure EthOut( Letter:char);
begin
  writeln(Serout, 'EthOut');
  TelnetTXBuffer:= TelnetTXBuffer+Letter;
  if Letter = #10 then
     TinaSendPacket(sTelnet, @TelnetTXBuffer, Word( Length( TelnetTXBuffer)));
     SetLength( TelnetTXBuffer, 0);
  endif;
end;


TelnetTXBuffer : string[100]

but if I work with TelnetTXBuffer in device procedure, the procedure will be started from writeln only once and not for every byte (I tested this). If I use only
TinaSendPacket(sTelnet,@Letter, 1);, procedure EthOut is callled for all bytes.
So I will try to build whole string with array.
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   129   143 · Page-Gen-Time: 0.029416s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI