vMicro version 2.2022.1128 minor version 24 Visual Studio 2022 Community Windows 10 Hi All I have existing Arduino code executing on the Mega2560 platform utilizing multiple layers of Serial messages. Of the 4 available serial ports on the Mega, I am using 0 (Serial) for communicating both with my console, as well as displaying various debugging and other state messages, and 1 (Serial1) for communicating with servos attached to the board. Serial2, and Serial3 are not in use at this time. What is the most efficient way to set up GDB debugging to not interfere with the existing serial use while allowing debugging functionality (without having to rewrite a significant amount of code!). I am currently experiencing the following error when enabling GDB-stub hardware debugging for this code: Error linking for board ATmega2560 (Mega 2560) (Arduino Mega) (mega_atmega2560) HardwareSerial0.cpp.o (symbol from plugin)*: In function Serial (.text+0x0)*: multiple definition of __vector_25 Build failed for project 'TestHarnessServoTranslate' avr8-stub.c.o (symbol from plugin)*: (.text+0x0): first defined here Any insights are appreciated my setup loop: void setup() { debug_init(); pinMode(ledPin, OUTPUT); // for interfacing with SERVOs Serial1.begin(1000000); while (!Serial1) { ; // wait for serial port to connect. Needed for Native USB only } // for serial debug Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for Native USB only } SERVO.pSerial = &Serial1; // assign Serial 1 to servos delay(500); cLog* pLog = cLog::getInstance(); // using singleton pattern - user Serial (0) by default pServo = cServo::getInstance(); // using singleton pattern pServo->Start(&SERVO); SERVO.EnableTorque(254, 1); pHexi = cHexapod::getInstance(); pHexi->Start(); digitalWrite(ledPin, HIGH); } ---- // log.h #ifndef _LOG_h #define _LOG_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif //#include "configuration.h" #define _Trace 5 #define _Debug 4 #define _Info 3 #define _Warn 2 #define _Error 1 #define _GDB 0 extern byte level_log; class cLog { public: void writeLog(String msg, int code); void writeLog(String msg, int attribute, int code); void writeLog(String msg, short attribute, int code); void writeLog(String msg, double attribute, int code); static cLog* getInstance(); // public interface to constructor ~cLog(); // destructor private: cLog(); // private constructor static cLog* instance; // singleton instance pointer int instanceCount; void printMsg(int code); void printMsg(String msg, int code); void printMsg(String msg, int attribute, int code); void printMsg(String msg, double attribute, int code); char* StringToChar(String msg); }; #endif --- #ifndef _cSERVO_h #define _cSERVO_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif #include <SCSCL.h> #include "log.h" #define UPPERLIMIT 800 // MAX raw servo position (0-1023) #define LOWERLIMIT 100 //MIN raw servo position (0-1023) class cServo { public: static cServo* getInstance(); // public singleton class access SCSCL* diagnosticSERVOPointer(); // use RAW servo libraries void Start(SCSCL* pServo); int ReadPos(int ID); int RegWritePos(uint8_t address, uint16_t position, uint16_t time, uint16_t speed = 0); // asynch single servo write: address, position, time, speed = 0 & validate and convert from degrees void RegWriteAction(void); // commit writes void SyncWritePos(u8 ID[], int moveTransactionsCount, u16 Position[], int Time, u16 Speed[]); bool ReadMove(int ID); ~cServo(); private: static cServo* instance; // to store singleton instance pointer int instanceCount; cServo(); // constructor - private to force use of public getInstance() SCSCL *pSERVO; cLog* pLog; // singleton int calcDelay(u16 currentPos, u16 newPos, u16 velocity); }; //end of class cServo class cSharedUtils { public: static int calcDelay(u16 currentPos, u16 newPos, u16 velocity); // in milliseconds static u16 degreesToServoPosition(int degrees); static u16 validateUpperLower(u16 newValue); static int servoPositionToDegrees(u16 position); }; #endif
|