Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Homepage
UARTでコマンドラインインターフェースを実現するためのライブラリです。
UARTからコマンドが入力されるとReadLine関数をコールバックします。
コマンドのデリミタはCR(0x0d)です。
コマンドはバックスペースで消去できます。
#include "mbed.h" #include "MjLineSerial.h" using namespace matsujirushi; RawSerial pc(USBTX, USBRX); MjLineSerial line(&pc); void readLineFunc(const char *str) { if (strcmp(str, "apple") == 0) { line.puts("RINGO"); } else if (strcmp(str, "orange") == 0) { line.puts("MIKAN"); } else { line.puts("unknown."); } line.puts("\r\n"); line.putc('>'); } int main() { pc.baud(115200); line.attachReadLine(readLineFunc); line.putc('>'); for (;;) { line.task(); } }