Change API to require all calls be from the same context. (#78)

* Remove atomic driver and all uses of otPlatAtomic* in OpenThread.
* Change posix example to only use a single thread of execution.
This commit is contained in:
Jonathan Hui
2016-05-27 09:16:04 -07:00
parent 21e0e8aa92
commit 7d2e4a0267
26 changed files with 410 additions and 591 deletions
+9 -27
View File
@@ -50,9 +50,6 @@ static const char sEraseString[] = {'\b', ' ', '\b'};
static const char CRNL[] = {'\r', '\n'};
static Serial *sServer;
Tasklet Serial::sReceiveTask(&ReceiveTask, NULL);
Tasklet Serial::sSendDoneTask(&SendDoneTask, NULL);
Serial::Serial(void)
{
sServer = this;
@@ -68,28 +65,20 @@ ThreadError Serial::Start(void)
return kThreadError_None;
}
extern "C" void otPlatSerialSignalReceive(void)
extern "C" void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
Serial::sReceiveTask.Post();
sServer->ReceiveTask(aBuf, aBufLength);
}
void Serial::ReceiveTask(void *aContext)
void Serial::ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength)
{
sServer->ReceiveTask();
}
void Serial::ReceiveTask(void)
{
uint16_t bufLength;
const uint8_t *buf;
const uint8_t *end;
buf = otPlatSerialGetReceivedBytes(&bufLength);
end = buf + bufLength;
end = aBuf + aBufLength;
for (; buf < end; buf++)
for (; aBuf < end; aBuf++)
{
switch (*buf)
switch (*aBuf)
{
case '\r':
case '\n':
@@ -115,13 +104,11 @@ void Serial::ReceiveTask(void)
break;
default:
Output(reinterpret_cast<const char *>(buf), 1);
mRxBuffer[mRxLength++] = *buf;
Output(reinterpret_cast<const char *>(aBuf), 1);
mRxBuffer[mRxLength++] = *aBuf;
break;
}
}
otPlatSerialHandleReceiveDone();
}
ThreadError Serial::ProcessCommand(void)
@@ -201,12 +188,7 @@ exit:
return;
}
extern "C" void otPlatSerialSignalSendDone(void)
{
Serial::sSendDoneTask.Post();
}
void Serial::SendDoneTask(void *aContext)
extern "C" void otPlatSerialSendDone(void)
{
sServer->SendDoneTask();
}
+2 -7
View File
@@ -80,8 +80,8 @@ public:
*/
int OutputFormat(const char *fmt, ...);
static Tasklet sReceiveTask;
static Tasklet sSendDoneTask;
void ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength);
void SendDoneTask(void);
private:
enum
@@ -91,12 +91,7 @@ private:
kMaxLineLength = 128,
};
static void ReceiveTask(void *aContext);
static void SendDoneTask(void *aContext);
ThreadError ProcessCommand(void);
void ReceiveTask(void);
void SendDoneTask(void);
void Send(void);
char mRxBuffer[kRxBufferSize];
+1 -1
View File
@@ -80,7 +80,7 @@ public:
private:
enum
{
kMaxLineLength = 80,
kMaxLineLength = 128,
};
static void HandleUdpReceive(void *aContext, otMessage aMessage, const otMessageInfo *aMessageInfo);