Skip to content

[BUG] Cannot disable Debug print #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
robcazzaro opened this issue Jun 14, 2023 · 2 comments
Closed

[BUG] Cannot disable Debug print #279

robcazzaro opened this issue Jun 14, 2023 · 2 comments
Assignees
Milestone

Comments

@robcazzaro
Copy link

I'm using Platformio, and I'm trying to reduce the size of a SimpleFOC project running on a GD32F130C8 processor with only 32K FLASH.

One obvious way is to reduce the size of the debug messages. I looked at the various messages, and in the file SimpleFOCDebug.h I found this

 * Add -DSIMPLEFOC_DISABLE_DEBUG to your compiler flags to disable debug in
 * this way.

When I set that build flag, though, it fails in FOCMotor.cpp in line 85, trying to enable a non-existing class

void FOCMotor::useMonitoring(Print &print){
  monitor_port = &print; //operate on the address of print
  SimpleFOCDebug::enable(&print);
  SIMPLEFOC_DEBUG("MOT: Monitor enabled!");
}
@RoboDurden
Copy link

Don't know if this will help the simpleFOC code but i always use debug macros that either map to serial ouput code or nothing:

#ifdef SERIALDEBUG
	#define DEBUG(code)	{code}
	#define OUT(s)	{SERIALDEBUG.print(s);}
	#define OUT2(s,i)	{SERIALDEBUG.print(s);SERIALDEBUG.print(": ");SERIALDEBUG.print(i);}
	#define OUT2T(s,i)	{SERIALDEBUG.print(s);SERIALDEBUG.print(": ");SERIALDEBUG.print(i);SERIALDEBUG.print("\t");}
	#define OUTN(s)	{SERIALDEBUG.println(s);}
#else
	#define DEBUG(code)
	#define OUT(s)
	#define OUT2(s)
	#define OUT2T(s)
	#define OUTN(s)
#endif

usage:

  DEBUG( 
    OUT2T("GD32",iNow) 
    for (int i=0; i<HALL_Count; i++)  OUT2T(i,aoHall[i].Get())
    OUT2T("angle",sensor.getAngle()) 
    OUT2T("speed",sensor.getVelocity())
    OUT2T("iI2cReq",iI2cReq);
    OUT2("iI2cRec",iI2cRec);
    OUTLN()
  )

@runger1101001
Copy link
Member

Fixed this on the dev branch @robcazzaro , thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants