[comp.sys.mac.programmer] Newline mode on devices

ccc_ldo@waikato.ac.nz (02/13/90)

In <34254@ucbvax.BERKELEY.EDU>, oster@dewey.soe.berkeley.edu (David Phillip
Oster) complains about the fact that newline mode in read calls only
works with files, not with the serial port (or other devices, for
that matter). He says "It should. That it does not is a bug in the
operating system."

I don't think so. First of all, newline mode (along with all the other
uses of ioPosMode and ioPosOffset) is a function of the file manager, not
the device manager; that they use the same read and write interface
calls is, in my view, not the most brilliant of design decisions--consider
the problems that can occur if the user creates a file called, say,
".AOut"!

Secondly, it sounds like a very limited function, considering the
wide, weird and wonderful variety of ways in which devices exchange
information over RS-232C connections (I assume you're not just
considering connecting a dumb terminal to your Mac)--packets terminated
with carriage returns, line feeds, carriage-return-line-feeds, or
even no terminator at all, but fixed-length packets beginning with a
distinctive initiator character. It's not that hard to build the
appropriate recognition logic into your application.

By the way, have you looked at the new Communications Toolbox? The
Connection Manager part of it includes a feature that could be
(very) loosely construed as a generalisation of newline mode, namely
search procedures. Basically, you can have the system watch the
input stream on a connection for one or more strings that you
specify, and as soon as it matches one of them in its entirety,
it will call an action routine that can do just about anything you
like. Much more fun than newline mode.

Lawrence D'Oliveiro
PC/networking hacker-in-residence, Computer Services Dept
University of Waikato, Hamilton, New Zealand
"CTBUtils.h: fixed BRC #51287 - misspelling of __cpluscplus
    (was spelled _cpluscplus)"