Recent

Author Topic: writeln redirect to usart  (Read 572 times)

diego bertotti

  • Jr. Member
  • **
  • Posts: 73
writeln redirect to usart
« on: July 17, 2020, 05:09:47 pm »
hello

somebody knows how i can redirect de write and writeln functions to use as output the usart tx?

thanks
« Last Edit: August 18, 2020, 05:04:58 pm by diego bertotti »

MarkMLl

  • Hero Member
  • *****
  • Posts: 1319
Re: writeln redict to usart
« Reply #1 on: July 17, 2020, 06:39:10 pm »
Console app? Lazarus? Operating system? type of hardware?

Come on old chap, give us a clue.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

ccrause

  • Sr. Member
  • ****
  • Posts: 313
Re: writeln redict to usart
« Reply #2 on: July 17, 2020, 07:00:15 pm »
somebody knows how i can redirect de write and writeln functions to use as output the usart tx?
One has to provide the required character read & write implementations and pass pointers to these functions to OpenIO.  OpenIO is defined in the consoleio unit.  An example of this redirection can be seen in the avrsim unit.  Of course in avrsim the redirection just dump the character in a special register, in your case WriteChar() needs to implement the UART call to transmit a character.

ccrause

  • Sr. Member
  • ****
  • Posts: 313
Re: writeln redict to usart
« Reply #3 on: July 17, 2020, 07:07:21 pm »
Console app? Lazarus? Operating system? type of hardware?

Come on old chap, give us a clue.

MarkMLl
The location of Diego's question gives the necessary context.  Don't worry, I have been baffled before by apparently context-less questions before, only to later realize it is all about the specific subforum.  Something that is easy to miss when looking at the Recent list.

MarkMLl

  • Hero Member
  • *****
  • Posts: 1319
Re: writeln redict to usart
« Reply #4 on: July 17, 2020, 09:45:43 pm »
The location of Diego's question gives the necessary context.  Don't worry, I have been baffled before by apparently context-less questions before, only to later realize it is all about the specific subforum.  Something that is easy to miss when looking at the Recent list.

I agree, my apologies :-)

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

diego bertotti

  • Jr. Member
  • **
  • Posts: 73
Re: writeln redict to usart
« Reply #5 on: July 17, 2020, 10:37:50 pm »
Console app? Lazarus? Operating system? type of hardware?

Come on old chap, give us a clue.

MarkMLl

excuseme

embedded arm stm32f103c8t6 bluepill board...just in case

diego bertotti

  • Jr. Member
  • **
  • Posts: 73
Re: writeln redict to usart
« Reply #6 on: August 15, 2020, 02:17:36 pm »
hello

once more

in embedded enviroment..what happens if i use writeln('something') if i dont write a specific code to redirect?

where they go?

thanks

ccrause

  • Sr. Member
  • ****
  • Posts: 313
Re: writeln redict to usart
« Reply #7 on: August 15, 2020, 06:02:00 pm »
in embedded enviroment..what happens if i use writeln('something') if i dont write a specific code to redirect?

where they go?
Good question.  If you include the consoleio unit then the standard handles (input, output, StdOut etc) are initialized with functions that basically do nothing.  I suspect (but cannot confirm) that in general read/write operations will check for valid configurations and do nothing if not properly initialized.

diego bertotti

  • Jr. Member
  • **
  • Posts: 73
Re: writeln redirect to usart
« Reply #8 on: August 24, 2020, 04:24:13 pm »
Code: Pascal  [Select][+][-]
  1. Unit consoleio;
  2.  
  3.     procedure SysInitStdIO;
  4.       begin
  5.         OpenIO(Input, @EmptyWrite, @EmptyRead, fmInput, nil);
  6.         OpenIO(Output, @EmptyWrite, @EmptyRead, fmOutput, nil);
  7.         OpenIO(ErrOutput, @EmptyWrite, @EmptyRead, fmOutput, nil);
  8.         OpenIO(StdOut, @EmptyWrite, @EmptyRead, fmOutput, nil);
  9.         OpenIO(StdErr, @EmptyWrite, @EmptyRead, fmOutput, nil);
  10.       end;
  11.  
  12.     function EmptyWrite(ACh: char; AUserData: pointer): boolean;
  13.       begin
  14.         EmptyWrite:=true;
  15.       end;
  16.  
  17.     function EmptyRead(var ACh: char; AUserData: pointer): boolean;
  18.       begin
  19.         EmptyRead:=true;
  20.         ACh:=#0;
  21.       end;
  22.  
  23.  

do nothing! you right

 

TinyPortal © 2005-2018