beautypg.com

Oki JOB60851 User Manual

Page 65

background image

Chapter 4 Software Development

page 4-30

pointer as necessary for string input.

If the character is a carriage return, the function echoes both it and a line feed back to the terminal
emulator and stores the latter in memory instead.

The function repeats the above cycle the number of times specified by the count argument to the
read() function. The compiler automatically determines this count from the standard I/O library
function calling read().

The echo portions of the function are there to provide visual feedback when testing the firmware
from the personal computer keyboard. If the user application program does not need this feedback,
echoing can be dropped.

(2) write() function

Figure 4.5.4 gives a flowchart for function operation.

Read first character from string

Character is line feed

Character is not line feed

Write character to

transmit buffer

Transmit character in

transmit buffer

Write carriage return to

transmit buffer

Transmit character (CR)

in transmit buffer

Write character (LF) to

transmit buffer

Transmit character (LF)

in transmit buffer

Figure 4.5.4. write() Operation

The control flow is slightly more complicated than that for read(), but the entire operation can

be

described in a single sentence: The function reads a character from the buffer and transmits it,
inserting a carriage return into the output stream before a line feed.

The function repeats the above cycle the number of times specified by the count argument to the
write() function. The compiler automatically determines this count from the standard I/O library
function calling write().