beautypg.com

5. standard i/o over serial link – Oki JOB60851 User Manual

Page 61

background image

Chapter 4 Software Development

page 4-26

4-5. Standard I/O over Serial Link

Section 2-.3 "Running User Programs" downloaded and executed a simple "Hello world!" program
that displays its message on the personal computer screen.

C compilers for personal computers assign a keyboard to the standard input and a monitor to the
standard output. The JOB60851 board has neither, but the programmer can provide substitutes as
described in this section.

4-5-1.

JOB60851 Board Standard I/O

The sample file stdrw573.c maps the JOB60851 board's standard input and output to a serial link
joining a terminal emulator running on the host personal computer to an MSM66Q573 serial port on
the JOB60851 board.

Standard input: Data from terminal emulator to MSM66Q573 RX pin
Standard output: Data to terminal emulator from MSM66Q573 TX pin

The functions required to create these mappings are read() and write(). Because of their tight links
with hardware, these are known as low-level functions (as opposed to high-level functions without
such dependencies).

Figure 4.5.1 summarizes the data flows for the resulting I/O.

C language I/O functions

Low-level standard I/O library

functions read() and write()

MSM66Q573 serial port

Terminal emulator running on

personal computer

getchar(), putchar(), and similar standard
library functions (high-level standard I/O
library functions)

High-level output functions write their data
with write(). High-level input functions read
their data with read().

TX data from write().
RX data to read().
(Only SIO0 used)

Data received: from MSM66Q573 TX pin
Data transmitted: to MSM66Q573 RX pin

Figure 4.5.1. JOB60851 Board Standard I/O

Table 4.5.1 shows the dependencies on these two low-level functions by the higher-level I/O
functions included in the standard libraries for the JOB60851 board C compiler (cc665s). Because of
these dependencies, be sure to include the corresponding source code file (stdrw573.c) on the
compiler command line.