Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:42 28 Oct 2026 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 : Redirecting Text Output

Author Message
PilotPirx

Senior Member

Joined: 03/11/2020
Location: Germany
Posts: 164
Posted: 06:50am 22 Oct 2026
Copy link to clipboard 
Print this post

Hello,
Is it possible with MMBasic to redirect text output, such as OPTION LIST, to a COM port? (PRINT #1)?
I have a printer connected to COM1 and would like to print OPTION LIST.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9253
Posted: 10:12am 22 Oct 2026
Copy link to clipboard 
Print this post

I don't know, it's not something I've ever wanted to do. I can't think of a way to do it directly from the Pico. OPTION LIST is a console command and displays on the console. Anything that is normally sent to a COM port is from the user's program.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
PilotPirx

Senior Member

Joined: 03/11/2020
Location: Germany
Posts: 164
Posted: 12:18pm 22 Oct 2026
Copy link to clipboard 
Print this post

I can print a screen dump, but then I have too much white space on the printout.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1574
Posted: 12:29pm 22 Oct 2026
Copy link to clipboard 
Print this post

how about

option console serial


  Quote  OPTION CONSOLE output
Specifies where print statements will output. Valid settings are BOTH (i.e.
SCREEN and SERIAL), SERIAL, SCREEN, NONE. This is a temporary
option that is reset when a program exits.

Edited 2026-10-22 22:30 by Martin H.
'no comment
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6200
Posted: 12:40pm 22 Oct 2026
Copy link to clipboard 
Print this post

  PilotPirx said  I can print a screen dump, but then I have too much white space on the printout.


Maybe I my memory is confused, but before the WYSIWYG age printing ALWAYS wasted paper before you got it right.
Apple fixed it with the MAC, and soon after that Windows.

Volhout
PicomiteVGA PETSCII ROBOTS
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 653
Posted: 01:02pm 22 Oct 2026
Copy link to clipboard 
Print this post

PilotPirx,

you could try MMCC start/end capture. Everything that prints to the serial console can be captured and processed later, no matter how long the output is (more or less). Very handy IMHO and often used to  document output.

Gerald
                                                                 
73 de OE1HGA, Gerald
 
PilotPirx

Senior Member

Joined: 03/11/2020
Location: Germany
Posts: 164
Posted: 01:03pm 22 Oct 2026
Copy link to clipboard 
Print this post

"option console serial" uses COM3, but i use COM1.
You can redirect it with OPTION CONSOLE PORT 1, but this causes a reset and its permanent. Thats not a good solution.
 
PilotPirx

Senior Member

Joined: 03/11/2020
Location: Germany
Posts: 164
Posted: 01:05pm 22 Oct 2026
Copy link to clipboard 
Print this post

  Quote  Maybe I my memory is confused, but before the WYSIWYG age printing ALWAYS wasted paper before you got it right.

That's true...
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9253
Posted: 01:38pm 22 Oct 2026
Copy link to clipboard 
Print this post

Patient: "It hurts when I do this, Doctor."
Doctor:  "Don't do it then. Next please!"

:)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3417
Posted: 08:46pm 22 Oct 2026
Copy link to clipboard 
Print this post

  Quote  before the WYSIWYG age printing ALWAYS wasted paper before you got it right.
Off topic, but with 3D printers history repeats.
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 472
Posted: 04:59pm 25 Oct 2026
Copy link to clipboard 
Print this post

G'day PilotPirx,
This is something that I too have wanted on several occasions in the past, but up until now could not think of a solution.

For PicoMite RP2350 only (I think)

The program below is probably not the ideal way to achieve this but it does work. It allows the output to the console to be read back and the do:loop can be used to store it in a file or sent to a COM port, it could also be saved in a longstring for further manipulation.

'prog to test UART loopback

Option default integer
Open "com7:" As #1 'test BT Serial
'Open "A:\Looptest.txt" For append As #1

Poke word &h40078030,&h381 'loopback on UART1 (COM2)

Option list ' something to test
'List pins
'Bluetooth status

Pause 50

Do While Loc(#0)
 Print #1,Input$(32,#0); 'print to BT or file
 Pause 50
Loop

Poke word &h40078030,&h301 'loopback off UART1 (COM2)

Close #1

End


This works by poking a 1 to bit 7 of the UARTCR register that enables LOOPBACK for that UART, so everything sent to the serial console is also looped back to the receiver.
This will only work on a serial console. If you are not using the serial console you could enable it and use the same program, DO NOT loop the pins unless it is disabled at the command prompt, it'll loop around forever.

For UART0 (COM1) use address &h40070030 instead. The delays are needed for COM7 @ 9600 baud.

Hope this is useful.

Regards, Lyle.
Edited 2026-10-26 03:07 by mozzie
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 12082
Posted: 05:29pm 25 Oct 2026
Copy link to clipboard 
Print this post

On non-USB builds you can use OPTION SERIAL CONSOLE command with the both option and you will get the console output on both the USB and nominated serial port.
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 472
Posted: 03:28pm 26 Oct 2026
Copy link to clipboard 
Print this post

G'day,
Peter:
that initially sounds counter-intuitive but is of course correct, it does however mean those 2 pins are unable to be used for anything else.
I have now realized the 1024 byte buffer on the console means this is not as useful as hoped, Stepper status over-runs that with ease.

All:
Within the 1024 character limit of the input buffer, this slightly more streamlined version will allow the output of text sent to the console to be captured to a longstring for further analysis or to be saved to a file. I will use this when testing to be able to save diagnostic data to a text file on a system with no PC etc as console.

'prog to test UART loopback

Option default integer
Dim RecStr(511)

'Lpbk_REC "Stepper status"

Lpbk_REC "Option List"

'Lpbk_REC "List Pins"

'Lpbk_REC "BlueTooth Status"

'Lpbk_REC "Memory"

'Lpbk_REC "List System I2C"

Print :Print "OUTPUT LONGSTRING:"
LongString print RecStr()
End

Sub Lpbk_REC Lpbk_COM$
 Poke Word &h40078030,&h381 'loopback on UART1 (COM2)
 Execute Lpbk_COM$
 Pause 1
 Do While Loc(#0)
   LongString Append RecStr(),Input$(32,#0)
   Pause 1
 Loop
 Poke Word &h40078030,&h301 'loopback off UART1 (COM2)
End Sub


For RP2350:
UART0 (COM1) = &h40070030
UART1 (COM2) = &h40078030

For RP2040:
UART0 (COM1) = &h40034030
UART1 (COM2) = &h40038030

Regards, Lyle.
 
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 2026