platformio / platform-raspberrypi

Raspberry Pi: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/raspberrypi
Apache License 2.0
73 stars 96 forks source link

SerialUSB test port problem #52

Open pedrorovi opened 1 year ago

pedrorovi commented 1 year ago

Hi, I am developing a project with the rp2040 with arduino framework, and I have a problem with unity config and the USB serial logs for Unity tests. I cannot see the logs/results from my tests with USB, but I can monitor the SerialUSB logs in my main function. Any advice?

I had the same problem in another project, but is working with a pio serial tx that I created, and here, it's working if I use Serial1 (gpio 0-1).

unity_config.h

#ifndef NATIVE

#ifndef UNITY_CONFIG_H
#define UNITY_CONFIG_H

#ifndef NULL

#ifndef __cplusplus
#define NULL (void *)0
#else
#define NULL 0
#endif

#endif

#ifdef __cplusplus
extern "C" {
#endif

void unityOutputStart();
void unityOutputChar(char);
void unityOutputFlush();
void unityOutputComplete();

#define UNITY_OUTPUT_START() unityOutputStart()
#define UNITY_OUTPUT_CHAR(a) unityOutputChar(a)
#define UNITY_OUTPUT_FLUSH() unityOutputFlush()
#define UNITY_OUTPUT_COMPLETE() unityOutputComplete()

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif /* UNITY_CONFIG_H */

#endif

unity_config.cpp

#ifndef NATIVE

#include "unity_config.h"

#include <Arduino.h>

void unityOutputStart() { SerialUSB.begin(115200); }
void unityOutputChar(char c) { SerialUSB.write(c); }
void unityOutputFlush() { SerialUSB.flush(); }
void unityOutputComplete() {}

#endif