rsta2 / circle

A C++ bare metal environment for Raspberry Pi with USB (32 and 64 bit)
https://circle-rpi.readthedocs.io
GNU General Public License v3.0
1.85k stars 245 forks source link

How to remove all text not from own CSerialDevice #446

Closed dirkarnez closed 6 months ago

dirkarnez commented 6 months ago

image

Hi bro, when i do serial printing for my own CSerialDevice, when some error / exception happened from my code i can see irrelevant text getting printed too (like the screenshot), may i know is there any #define(s) or settings to block all of these? Because i am using the serial output for graph-plotting and i cannot have any other text, including raw revision code printing since Circle 46.

Also since i am using SCREEN_HEADLESS mode, can i also omit any screen text-printing too? it seems they are redirected to serial.

Thank you so mcuh!

rsta2 commented 6 months ago

Unfortunately I do not know, where this text is coming from. Circle does not send this text.

If you do not want to see the output from the logger, just delete the CLogger member from CKernel. If class of the system tries to access the logger then, a dummy instance is created, which ignores the message. But debugging is difficult in this case.

Circle by itself does not access the screen or the serial interface. The sample programs do this, but they explicitly write on these devices and it can be seen in the programs, where this is done.

The Raspberry Pi 4 and 5 support more than one serial interface, so you could use one interface for the plotter and one for the logger there.

dirkarnez commented 6 months ago

It is very scary that each time on error / exception, different documentation-like text comes out :P

I have tried to remove CLogger but you are right i need it for debugging somehow, as long as the debugging text is managable. However, can i remove CScreenDevice m_Screen;? my application is running in SCREEN_HEADLESS mode and i really want to get rid of all the things related to (HDMI) screen, making the following code in samples suspicious XD

    if (bOK)
    {
        CDevice *pTarget = m_DeviceNameService.GetDevice (m_Options.GetLogDevice (), FALSE);
        if (pTarget == 0)
        {
            pTarget = &m_Screen;
        }

        bOK = m_Logger.Initialize (pTarget);
    }

and cmdline

logdev=ttyS1

Can this line redirecting Screen output to serial?

Thank you so much!

rsta2 commented 6 months ago

How it seems, this text comes from the git-shell. Because I do not know your setup, I do not have an explanation for this. Perhaps it is not triggered from the Circle application?

You can absolutely remove the m_Screen member and the related initialization, if you don't need it. You also don't need the SCREEN_HEADLESS option any more then, because it only implements CScreenDevice in a way, that all output operations are ignored. When there isn't a screen, you cannot write to it, and nothing need to be ignored.

logdev=ttyS1 redirects the logger output to the (first) serial device. In case there is no screen, you can also change the code to this:

    if (bOK)
    {
        bOK = m_Logger.Initialize (&m_Serial);
    }
dirkarnez commented 6 months ago

Thank you so much, going to edit the code. The terminal i use is Tera Term. I tried serial plotting from Arduino IDE too.

dirkarnez commented 6 months ago

It seems i have found the trigger for unknown text printing.

My application is just a modified version of addon/SDCard/sample, in the kernel.cpp#L154, i changed the buffer size to 1024 and read large file. It seems large file will randomly fail (EXCEPTION_SYNCHRONOUS). Reading config.txt as small file always works.

May i know will you have the same effect when you read the attached large file? sf_56.csv

rsta2 commented 6 months ago

I tried addon/fatfs/sample with reading your file with buffer size 1024, and it worked without problems. Can you check the file system of your SD card? After a crash it may be corrupted in a way.

dirkarnez commented 6 months ago

OMG indeed my card is corrupted haahaha, it works so good now after using another SD card. However, may i also know how to also disable this text, please? I want to format the logger message so customized plotter can distinguish logger message and ADC values. Once again thank you so much! image

rsta2 commented 6 months ago

Good, that it works now. If you want to remove these lines, you have to edit lib/logger.cpp. An other way is not supported and not intended. ;)

dirkarnez commented 6 months ago

I see! Will there be an enable / disable option 🤣?

rsta2 commented 6 months ago

Unfortunately not. Circle is not very chatty, but these two lines should be allowed. The third line from the timer can be suppressed by defining NO_CALIBRATE_DELAY in Config.mk:

DEFINE += -DNO_CALIBRATE_DELAY

BTW. The first two lines are the only one, which come from the logger directly, so you could filter out all lines starting with "logger:".

dirkarnez commented 6 months ago

Ok hahahaha