C言語からArduinoのSerialオブジェクトを使うには
- C++のソースにSerialオブジェクトを使ったラッパー関数を作る (
my_log() @sub.cpp
) - Cのソースからそのラッパー関数をコールするラッパー関数を作る (
my_log_c() @sub.c
)
という、二段構えのラップラップが必要になる。
C++から直接Serialオブジェクトを使うときに比べてめんどいけど、このやり方を覚えるとArduinoだけでなく他の言語でも使えるので応用が効くはず。
元ネタ:https://stackoverflow.com/questions/66632376/how-to-call-serial-print-from-c-file-in-arduino-ide