Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:37 24 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Reading the console's output?

Author Message
ebbandflow
Newbie

Joined: 31/08/2023
Location: United States
Posts: 35
Posted: 03:01pm 20 Feb 2025
Copy link to clipboard 
Print this post

I have been reading and searching, but figure ASKING couldn't hurt either.  

Is there a way (for instance), to read the console's output into a string for use by the running program? Or perhaps there a console output buffer that can be accessed?
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1538
Posted: 03:06pm 20 Feb 2025
Copy link to clipboard 
Print this post

AFAIK: NO.

(I'm also looking for a way to redirect the output, similar to batch files.)

Regards
Michael
causality ≠ correlation ≠ coincidence
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2150
Posted: 03:12pm 20 Feb 2025
Copy link to clipboard 
Print this post

link the Console Tx pin to the COM1 Rx pin then read it from there
 
ebbandflow
Newbie

Joined: 31/08/2023
Location: United States
Posts: 35
Posted: 04:13pm 20 Feb 2025
Copy link to clipboard 
Print this post

Thank you for the quick responses! I'm surprised that this is not built-in but glad to know there's a work around, I'm going to give this a shot.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 04:46pm 20 Feb 2025
Copy link to clipboard 
Print this post

I'm not sure why you would want it TBH. While a program is running the console would usually only show error messages, which would often be fatal so the program wouldn't be running to process them. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2150
Posted: 05:01pm 20 Feb 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  I'm not sure why you would want it


some functions natively print their output without the option to capture it... I have found in the past on the 'mite platform that MEMORY had useful output

years ago that I had to find a way to capture the directory of a disc and it was only possible dipping into m/code... untill I used a tiddly routine to copy characters from the screen. Getting it as a string would have really made life simple.

programming 102 never dismiss a use case because you can't think of a use case. In my book, everything like this should output a string - you can print it if you want - PRINT USING is a *very* good case in point... the nicely formatted output is useful in dozens of theatres.

h
Edited 2025-02-21 03:08 by CaptainBoing
 
ebbandflow
Newbie

Joined: 31/08/2023
Location: United States
Posts: 35
Posted: 05:21pm 20 Feb 2025
Copy link to clipboard 
Print this post

  CaptainBoing said  
  Mixtel90 said  I'm not sure why you would want it


...programming 102 never dismiss a use case because you can't think of a use case.


 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 05:52pm 20 Feb 2025
Copy link to clipboard 
Print this post

Just because *I* can't think of a use for it doesn't mean that there isn't one, I know that.

My saying that I can't think of a reason doesn't mean that I'm saying that there isn't a reason. The two are not equivalent. There is no dismissal. :)

Sometimes such information is given by the MM.INFO() commands in a far more usable form than having to parse a string to look for it. It's always worth checking them first.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
ebbandflow
Newbie

Joined: 31/08/2023
Location: United States
Posts: 35
Posted: 06:35pm 20 Feb 2025
Copy link to clipboard 
Print this post

Unfortunately I need an exact copy of the data sent to the console and preferably in string form so I don't have to recreate the wheel. It's a little silly but hopefully connecting a few pins will work.  
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10090
Posted: 06:44pm 20 Feb 2025
Copy link to clipboard 
Print this post

  Quote  link the Console Tx pin to the COM1 Rx pin then read it from there


Not applicable if using a USB console.
Why not just use print # to send to a file?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 06:46pm 20 Feb 2025
Copy link to clipboard 
Print this post

I'm intrigued....  :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
ebbandflow
Newbie

Joined: 31/08/2023
Location: United States
Posts: 35
Posted: 07:36pm 20 Feb 2025
Copy link to clipboard 
Print this post

  matherp said  
  Quote  link the Console Tx pin to the COM1 Rx pin then read it from there

Not applicable if using a USB console.


Perhaps if I enable the console over both serial and USB?

  matherp said  Why not just use print # to send to a file?


I'm not sure if I understand what you're proposing exactly. Would this method send all console output to a file or only things explicitly printed to it? I.E. would it mirror the console's output to a file?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 10:17pm 20 Feb 2025
Copy link to clipboard 
Print this post

What are you expecting to see coming from the console that won't have originated in your program?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2458
Posted: 10:49pm 20 Feb 2025
Copy link to clipboard 
Print this post

He mentioned the MEMORY command which only outputs to the console.
Something like the Pipe "|" operator to redirect such output is, I think, what he is after.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 08:15am 21 Feb 2025
Copy link to clipboard 
Print this post

It was the good Cap'n that mentioned MEMORY. In any event, by the time you detect an error when reading that it's likely to be a bit late to delete a load of variables to make more space. :)  We now have MM.INFO(HEAP) anyway, which is the only memory that matters.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2458
Posted: 10:26am 21 Feb 2025
Copy link to clipboard 
Print this post

  Quote  Perhaps if I enable the console over both serial and USB?

Been playing with that.
OPTION SERIAL CONSOLE COM1,GP0,GP1,B
Dim s$
SetPin GP5, GP4, COM2 'link GP5 to GP0
Open "COM2:115200" As #2

Print "   Issuing MEMORY command"
Pause 9
s$ = Input$(255,#2) 'clear Rx buffer
s$ = ""
Memory
Pause 44
Print "                                  " 'add some paddimg
Print "Waiting for COM2 input"

s$ = Input$(200,#2)
Print @(0,280)"Received by COM2"
Print @(0,300)s$ :Print :Print
End

Output
  Issuing MEMORY command
Program:
  2K ( 1%) Program (84 lines)
178K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  2K ( 0%) 12 Variables
  1K ( 0%) General
225K (100%) Free

Waiting for COM2 input





Received by COM2

Program:
  2K ( 1%) Program (84 lines)
178K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  2K ( 0%) 12 Variables
  1K ( 0%) General
225K (100%) Free

Edited 2025-02-21 20:47 by phil99

Footnote added 2025-02-22 21:32 by phil99
A minor refinement.
Dim s$
SetPin gp5, gp4, COM2 : Open "COM2:115200" As #2
Print "   Issuing MEMORY command"
Pause 9
s$ = Input$(255,#2) : s$ = "" 'clear Rx buffer
Memory
Pause 40
Print Space$(20) :Print :Print 'add some padding
Print "Waiting for COM2 input"
s$ = Input$(200,#2)
Print "Received by COM2"
Print S$ :Print
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2150
Posted: 12:15pm 21 Feb 2025
Copy link to clipboard 
Print this post

well that works.

Not saying it is the best or only way, but it works well and nice to see it do so with the complications on the Pi console that Pete pointed out...  we have a solution, we just need a problem  

An enjoyable canter

h
Edited 2025-02-21 22:20 by CaptainBoing
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025