#include "../src/betaflight.h" #include "../src/serial.h" #include #include #include #include #if defined(__APPLE__) #include #else #include #endif int main() { using namespace bfebbx; using namespace std::chrono_literals; int master = -1, slave = -1; assert(openpty(&master, &slave, nullptr, nullptr, nullptr) == 0); // Set slave to raw mode to disable line-ending translation struct termios tio; assert(tcgetattr(slave, &tio) == 0); cfmakeraw(&tio); assert(tcsetattr(slave, TCSANOW, &tio) == 0); // FC echoes the command then reports the value and a prompt. const char* canned = "# get craft_name\r\ncraft_name = TESTQUAD\r\n# "; ssize_t len = static_cast(std::string(canned).size()); assert(write(slave, canned, static_cast(len)) == len); Serial s = Serial::fromFd(master); auto name = getCraftName(s, 1000ms); assert(name.has_value()); assert(name.value() == "TESTQUAD"); close(slave); return 0; }