![]() |
Forum Index : Microcontroller and PC projects : Reading the console's output?
Author | Message | ||||
ebbandflow Newbie ![]() Joined: 31/08/2023 Location: United StatesPosts: 35 |
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: GermanyPosts: 1538 |
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 KingdomPosts: 2150 |
link the Console Tx pin to the COM1 Rx pin then read it from there |
||||
ebbandflow Newbie ![]() Joined: 31/08/2023 Location: United StatesPosts: 35 |
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 KingdomPosts: 7585 |
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 KingdomPosts: 2150 |
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 StatesPosts: 35 |
![]() |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7585 |
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 StatesPosts: 35 |
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 KingdomPosts: 10090 |
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 KingdomPosts: 7585 |
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 StatesPosts: 35 |
Not applicable if using a USB console. Perhaps if I enable the console over both serial and USB? 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 KingdomPosts: 7585 |
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: AustraliaPosts: 2458 |
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 KingdomPosts: 7585 |
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: AustraliaPosts: 2458 |
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 KingdomPosts: 2150 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |