Re-enable termio settings. (#25)

This commit is contained in:
Jonathan Hui
2016-05-13 09:33:35 -07:00
parent 99870fae01
commit baa8994190
2 changed files with 56 additions and 83 deletions
+6 -22
View File
@@ -80,34 +80,19 @@ void Serial::ReceiveTask(void)
{
uint16_t bufLength;
const uint8_t *buf;
const uint8_t *cur;
const uint8_t *end;
buf = otPlatSerialGetReceivedBytes(&bufLength);
end = buf + bufLength;
for (cur = buf; cur < end; cur++)
{
switch (*cur)
{
case '\r':
case '\n':
otPlatSerialSend(CRNL, sizeof(CRNL));
break;
default:
otPlatSerialSend(cur, 1);
break;
}
}
while (bufLength > 0 && mRxLength < kRxBufferSize)
for (; buf < end; buf++)
{
switch (*buf)
{
case '\r':
case '\n':
otPlatSerialSend(CRNL, sizeof(CRNL));
if (mRxLength > 0)
{
mRxBuffer[mRxLength] = '\0';
@@ -118,21 +103,20 @@ void Serial::ReceiveTask(void)
case '\b':
case 127:
otPlatSerialSend(sEraseString, sizeof(sEraseString));
if (mRxLength > 0)
{
mRxBuffer[--mRxLength] = '\0';
otPlatSerialSend(sEraseString, sizeof(sEraseString));
}
break;
default:
otPlatSerialSend(buf, 1);
mRxBuffer[mRxLength++] = *buf;
break;
}
buf++;
bufLength--;
}
otPlatSerialHandleReceiveDone();