|
Forum Index : Microcontroller and PC projects : Redirecting Text Output
| Author | Message | ||||
| PilotPirx Senior Member Joined: 03/11/2020 Location: GermanyPosts: 164 |
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 KingdomPosts: 9253 |
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: GermanyPosts: 164 |
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: GermanyPosts: 1574 |
how about option console serial Edited 2026-10-22 22:30 by Martin H. 'no comment |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6200 |
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: AustriaPosts: 653 |
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: GermanyPosts: 164 |
"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: GermanyPosts: 164 |
That's true... |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 9253 |
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: AustraliaPosts: 3417 |
Off topic, but with 3D printers history repeats. |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 472 |
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 KingdomPosts: 12082 |
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: AustraliaPosts: 472 |
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. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |