Jens Frank Jensen / Mbed 2 deprecated foc-ed_in_the_bot_compact

Dependencies:   mbed FastPWM3

interrupts.cpp

Committer:
bwang
Date:
2017-03-10
Revision:
82:5e741c5ffd9f
Child:
83:eb3704d4943f

File content as of revision 82:5e741c5ffd9f:

#include "globals.h"
#include "CommandProcessor.h"

char linebuf[128];
int index = 0;

void rxCallback() {
    while (io.pc->readable()) {
        char c = io.pc->getc();
        if (c != 127 && c != '\r' && c != '\t') {
            linebuf[index] = c;
            index++;
            io.pc->putc(c);
        } else if (c == 127) {
            if (index > 0) {
                index--;
                io.pc->putc(c);
            }
        } else if (c == '\r') {
            linebuf[index] = 0;
            io.pc->putc(c);
            processCmd(io.pc, io.pref, linebuf);
            index = 0;
            io.pc->putc('>');
        }
    }
}