Sending enums as messages in a uCos OSQue
Posted: Fri Feb 20, 2009 3:03 pm
The queue examples that I've seen send strings as messages. Can I send integers or enums instead?
I have an enum called 'commands', I'd like to have several tasks send 'commands' to UserMain(). I've tried this:
enum commands{ SETUP_FOV_CMD, SETUP_FOCUS_CMD, SETUP_MIRROR_CMD, SETUP_PADDLE_CMD, ...
A task:
void TouchScreenServer(void*){
iprintf( "Starting TouchScreenServer.\r\n" );
commands TSCommand = NOTHING_CMD;
while (true){
char key = TS.Key();
if (WFOVButton.Hit(key)){
TSCommand = WIDE_CMD;
...
OSQPost(&CommandQueue, (void *)TSCommand);
}
} // end of TouchScreenServer
in UserMain :
...
commands Command = NARROW_CMD;
iprintf("Ready...\n");
while(true){
commands* pc = (commands *)OSQPend(&CommandQueue, 0, &QueueError);
Command = *pc;
iprintf("Working...");
switch (Command) {
// FOV commands follow
case WIDE_CMD :
...
This will compile, but hangs when the OSQPend unblocks (never prints "Working ..."). The hardware needs a hard reset to respond to the ID after this. I suspect I've gotten my pointers tangled up.
I think I'm missing something fundamental here, does anyone have an example of passing a non-char* message in a uCos OSQue?
Netburner MFC5234. Eclipse
Thanks,
Sam
I have an enum called 'commands', I'd like to have several tasks send 'commands' to UserMain(). I've tried this:
enum commands{ SETUP_FOV_CMD, SETUP_FOCUS_CMD, SETUP_MIRROR_CMD, SETUP_PADDLE_CMD, ...
A task:
void TouchScreenServer(void*){
iprintf( "Starting TouchScreenServer.\r\n" );
commands TSCommand = NOTHING_CMD;
while (true){
char key = TS.Key();
if (WFOVButton.Hit(key)){
TSCommand = WIDE_CMD;
...
OSQPost(&CommandQueue, (void *)TSCommand);
}
} // end of TouchScreenServer
in UserMain :
...
commands Command = NARROW_CMD;
iprintf("Ready...\n");
while(true){
commands* pc = (commands *)OSQPend(&CommandQueue, 0, &QueueError);
Command = *pc;
iprintf("Working...");
switch (Command) {
// FOV commands follow
case WIDE_CMD :
...
This will compile, but hangs when the OSQPend unblocks (never prints "Working ..."). The hardware needs a hard reset to respond to the ID after this. I suspect I've gotten my pointers tangled up.
I think I'm missing something fundamental here, does anyone have an example of passing a non-char* message in a uCos OSQue?
Netburner MFC5234. Eclipse
Thanks,
Sam