hi all,
Im writing a simple application in uCos-II that spans a couple of processes. First process (inputField) controls input "field" for words. The idea is to provide a possibility for user to input a word that is sent (by Message Queue) to another process that prints it on screen. Third process also listens keyboard:
void KeyListener(void *pdata) { while(1) { OSSemPend(Priority_over_CPU, 0, &err); //get exclusive control if(kbhit()) { if(ch == 27) //esc OSSemPost(EscPressed); //signal process that kills application } OSSemPost(Priority_over_CPU); // release control OSTimeDly(1); } }
----------------- Source code for the first process:
void InputField(void *pdata) { while(1) { OSSemPend(Priority_over_CPU, 0, &err) ch = getch(); if(ch != 13) input[next_pos] = ch; //append to array else //enter pressed->sent written word to another process OSQPost(MsgQueue, (void *)&input[0]);
OSTimeDly(1); }
}Problem: For some reason the program crashes when task-InputField() gets control and tries to listen keyboard (it has lower prio than KeyListener). How can I get 2 processes listen keyboard? Should I somehow encapsulate keyboard functions and provide exclusive access to them when processes get their turn?
-Juha Rossi