Information Technology Reference
In-Depth Information
{
if (kbhit())
{
ch=getche();
if (ch==ESC) break;
send_character(ch);
}
/* empty RS232 buffer */
do
{
if ((ch=get_buffer()) != -1) putch(ch);
} while (ch!=-1);
} while (!done);
disable_interrupts();
reset_vectors();
return(0);
}
28.3 Exercises
28.3.1
Modify Program 28.1 so that a new-line character is displayed properly.
28.3.2
Prove that Program 28.1 is a true multitasking system by inserting a delay in the
main loop, as shown next. The program should be able to buffer all received char-
acters and display them to the screen when the sleep delay is over.
do
{
sleep(10);
/* go to sleep for 10 seconds, real-time system
*/
/* will buffer all received characters */
if (kbhit())
{
ch=getche();
if (ch==ESC) break;
send_character(ch);
}
/* empty RS232 buffer */
do
{
if ((ch=get_buffer()) != -1) putch(ch);
} while (ch!=-1);
} while (!done);
28.3.3
Modify Program 28.1 so that the transmitted characters are displayed in the top
half of the screen and then received in the bottom half of the screen.
28.3.4
Modify Program 28.1 so that it communicates via COM2: (if the PC has one).
28.3.5
Using a loopback connection on a serial port, write a program, which sends out the
complete ASCII table and checks it against the received characters.
28.3.6
Outline how a program could communicate with a serial port card with eight serial
Search WWH ::




Custom Search