Hi,
I have some problem with code the main(). The program is for communicating with a micro controller through the SCI port.
the main() is supposed to do:
Main Program.
1. Set up The message is: “ The main function ”
2. Write the message to the screen.
3. Wait approximately 1 second. with wait_sec() function
4. Check to see if there is an input character waiting to be read. If not, loop back to b. above.
5. If there is an input character waiting, read it in, echoing it, and then output a CR and LF (using CRLF()).
• If the character is “N” or “n”, call MsgIn() to read in a new message that immediately replaces the previous message being printed once per second.
• If the character is “X” or “x”, exit the program.
• If the character is something else, just ignore it.
6. Loop back to 2. above.
Note that MsgIn(char inData[], unsigned int length) that reads in messages received at the SCI input. inData is the address of an input array prepared to receive input data, and the length of the array, and one output argument, the actual received message length.
I have problem understanding the main does especially when it reads the new message and loops back.Code:void main(void) { /* put your own code here */ const data[]="The main function"; char input; InitSci(5); /* initialize SCI post*/ message_out(data); /*display message*/ wait_sec();/*1 sec wait*/ while (1){ /*loop back until the character is ready to be read*/ message_out(data); if(IntStatusSCI()){/*IntStatusSCI() returns true if a character available to be read; returns false if not. */ break;}/*break if the character is read*/ } input=GetSci();/*input character into SCI port*/ CRLF();/*write out a CR and LF*/ if(( input=='N')| (input=='n')) MsgIn(); /*read the message*/ else if( (input=='X')| (input=='n')) exit; else{/*ignore it code*/} }/*end main*/
My second issue is the function MsgIn(). How do we know the length of the new message?
Can someone help me to fix the main function please?
thankx
B