background image
C H A P T E R 2 4
Built-in Communications Tools
Serial Tool
24-5
An endpoint can include
kPacket
,
kEOP
, and
kMore
flags to control the sending
and receiving of framed (packetized) data with the framed asynchronous serial
tool. For more information on these flags, see "Sending Data" (page 23-11).
The following is an example that shows how to create an endpoint that uses the
framed asynchronous serial tool:
myFramedEP := {_proto:protoBasicEndpoint};
myOptions := [
{ label: kCMSFramedAsyncSerial,
type: 'service,
opCode: opSetRequired } ];
returnedOptions:= myFramedEP:Instantiate(myFramedEP,
myOptions);
The framed asynchronous serial tool uses the standard asynchronous serial tool
options, as well as two framing options, which are summarized in Table 24-3.
These options are described in detail in "Options for the Framed Asynchronous
Serial Tool" (page 21-29) in Newton Programmer's Reference.
The default settings for the
kCMOFramingParms
option implement BSC framing,
as shown in Figure 24-1.
Figure 24-1
Default serial framing
Each packet is framed at the beginning by the 3-character SYN-DLE-STX header.
The packet data follows; if a DLE (escape character) occurs in the data stream,
Table 24-3
Summary of framed serial options
Label
Value
Use when
Description
kCMOFramingParms
"fram"
Any time
Configures data framing parameters.
kCMOFramedAsyncStats
"frst"
Any time
Read-only option returns the number
of bytes discarded while looking for
a valid header.
Octet 1
SYN
Flag
0001011
DLE
Flag
0001000
STX
Flag
0000001
Message . . .
DLE
Flag
0001000
ETX
Flag
0000001
Frame
Check
Sequence
2
3
. . . . . . . . . . . . . . . . . .
N-3
N-2
N-1
N
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна