arduino开发遇见的问题(求助!!)
·
一、串口输出问题
1.情况一
main
void setup() {
esp32DebugInit();
}
void loop() {
mySerial.println("bbbbbbbbbbb");
delay(1000);
}
debug.h
#define TX_PIN 16
#define RX_PIN 17
static HardwareSerial mySerial(2);
void esp32DebugInit(void);
debug.c
void esp32DebugInit(){
mySerial.begin(115200,SERIAL_8E1,RX_PIN,TX_PIN);
analogReadResolution(12);
mySerial.println("aaaaaaaaa");
}
结果
无法输出 bbbbbbbbbbb
只有 aaaaaaaaa

2.情况二
main
void setup() {
esp32DebugInit(&mySerial);
}
void loop() {
mySerial.println("bbbbbbbbbbb");
delay(1000);
}
debug.h
#define TX_PIN 16
#define RX_PIN 17
static HardwareSerial mySerial(2);
void esp32DebugInit(HardwareSerial *mySerial);
debug.c
void esp32DebugInit(HardwareSerial *mySerial){
mySerial->begin(115200,SERIAL_8E1,RX_PIN,TX_PIN);
analogReadResolution(12);
mySerial->println("aaaaaaaaa");
}
结果
都能输出

为什么????
二、
1.情况一
sprintf(data,"x:%d y:%d",tmp_x,tmp_y);
mySerial.println(data);
结果
能完整输出
2.情况二
sscanf(data,"x:%d y:%d",tmp_x,tmp_y);
mySerial.println(data);
结果
无法输出
更多推荐
所有评论(0)