ToonTalk extensions are birds
that can fly "outside" of ToonTalk to the operating system. You start off with
only one "foreign" bird. But she can bring you a bird connected to any ToonTalk
extension installed on your system. You can find her near the end of your sensor notebook. She has a question mark on her T-shirt. To
"open" an extension, give her a box with 2 holes: the first should hold the name
of the extension and the second another bird who will come back with a new bird (in a
box). The kinds of messages (boxes), the new bird should be given depends upon which
extension she flies to.
Any programmer who can make Windows DLLs (Dynamic
Link Libraries) can make new extensions. Over time
we hope that programmers will add new extensions, for example, for generating
music, or connecting to the Internet, or doing 3D graphics. Currently, only two extensions
that can be installed. One is for
controlling the LEGO Mindstorms RCX brick and the other is for interfacing
with the file system and is described below.
The
FILE extension. This extension enables you to open files and read and write them. You
should give a bird connected to this extension a box with 3 holes. The first hole should
contain one of the message names listed below. The second hole should contain the name of
the file you want. The third hole should contain a bird who will receive a box with
another bird in it. This new bird will take messages to the file.
Create File.
If the first hole contains the words "create
file", then a file will be created for you. The second hole should contain the name
of the file you want to create. A file with that name should not already exist. The name
should follow the file naming rules of the operating system.
Open.
If the first hole contains the word
"open", then a file will be opened for you. The second hole should contain the
name of a file that already exists. The file is opened using Windows CreateFile
procedure. This means the name can be the name of a file, pipe, mail slot, communications
resource (e.g. "LPT1" or "COM1"), disk device, console, or directory
to open.
Open Serial Port.
If the first hole contains the words "open
serial port", then a serial port will be opened with the characteristics specified in
the name found in the second hole. For example, if the second hole contains "COM1:
baud=1200 parity=N data=8 stop=1" then the serial port number one of your computer
will be opened with a 1200 baud rate, with parity off, 8 bit data, and stop equal to 1.
This feature relies upon Windows BuildCommDCB procedure to interpret port
descriptions.
Messages to Files. After you successfully
opened or created a file, you should have a bird that flies to that file. She should have
the file name on her T-shirt. You can give her a message with 3 holes. The first hole can
be any of the message names listed below. The proper contents of the second hole depend
upon the first. The third hole should contain a bird who will receive a reply.
Read.
The second hole should contain a number that says
how many letters or characters to read. The bird is given a text pad with the letters
read. If the end of the file was reached, then the number of letters will be less.
Write.
The second hole should contain a text pad to add to
the file. The bird is given a number pad that shows the number of letters actually added
to the file.
Read Bytes.
The second hole should contain a number that says
how many letters or characters to read. The bird is given a box with a hole for each
character read. Inside each hole is the ASCII number for the character. If the end of the
file was reached, then the number of letters will be less.
Write Bytes.
The second hole should contain a box with a hole for
each byte to add to the file. Each hole should contain a number between 0 and 255. If a
number is too large only the low order byte will be written. You can use the ASCII
encoding of characters here. The bird is given a number pad that shows the number of
letters actually added to the file.
The ability to read and write bytes is particularly
important when dealing with serial or parallel communication ports.