Safe chprintf outside shell loop
Posted: Sun Apr 06, 2014 4:17 pm
hiya!
I have a problem with chprintf function which crash shell thread.
I have casual shell thread (like in USB-CDC example) and normal thread:
If i disable chprintf - all working fine, but i need to do output to USB console outside shell thread.
What i do wrong? May be some kind of lock required to notify system shell thread to suspend any action?
I have a problem with chprintf function which crash shell thread.
I have casual shell thread (like in USB-CDC example) and normal thread:
Code: Select all
static WORKING_AREA(waMsgThread, 128);
static msg_t mMsgThread(void *arg) {
(void)arg;
Thread *t;
msg_t msg;
packet_t pkt;
char buf[6];
chRegSetThreadName("MsgProc");
while (TRUE)
{
t=chMsgWait();
msg = chMsgGet(t);
memcpy(&pkt, (void *)msg, sizeof(packet_t));
chMsgRelease(t, msg);
if (shelltp)
{
chprintf((BaseSequentialStream *)&SDU1, "....");
... a lot of chprintf here ...
}
}
}
If i disable chprintf - all working fine, but i need to do output to USB console outside shell thread.
What i do wrong? May be some kind of lock required to notify system shell thread to suspend any action?