简体   繁体   English

当没有连接COM(串行)端口或串行监视器打开时,arduino是否运行打印功能(print,println,printf等)?

[英]does arduino run the print function (print, println, printf, etc.) when no COM (Serial) port is connected or serial monitor open?

Im wondering the print statements in my code are taking up processing cycles when the robot isn't connected to the com port. 我想知道我的代码中的打印语句是否会在机器人未连接到COM端口时占用处理周期。 I am running a time sensitive process and have reason to believe the execution of these lines could be slowing my bot down. 我正在运行一个时间敏感的进程,并且有理由相信这些行的执行可能会使我的机器人慢下来。

Yes It will take processing time even if no serial monitor or other device is connected. 是,即使未连接串行监视器或其他设备,也会花费处理时间。

A good practice is to a have a #define pre-processor directive in your code indicating whether you are debugging or not. 良好的做法是在代码中使用#define预处理程序指令,指示是否在调试。

eg 例如

#define DEBUG_PHASE

#ifdef DEBUG_PHASE
printf(...);
#endif

Of course they are. 当然是。 The MCU still goes through the actions of parsing the format string and sending serial data even when nothing is listening. 即使没有人在听,MCU仍会执行解析格式字符串和发送串行数据的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM