baxter@zola.ICS.UCI.EDU (Ira Baxter) (08/28/90)
I have 3 serial ports, /dev/tty00, tty01, tty02 under ISC 2.0.2. I want to use /tty02 as a simple serial I/O device to move files to/from an ancient Z80 CP(shudder)M system at 9600 baud. I assume that UNIX on my 20Mhz 386 can catch any stream of characters I pitch at it without losing anything [if it can't, I'll just lower the baud rate some] and am hoping to do a simple "cat /dev/tty02 > FILENAME" to capture a file from the Z80. The tty manager under SYSADM thinks that tty02 is "disabled", i.e., not a user, but that its default baud rate is 9600. Trying "stty -a < /dev/tty02" tells me the baud rate is 300 baud. Why is that inconsistent with what SYSADM tells me? Trying "stty 9600 < /dev/tty02 & stty -a /dev/tty02" also tells me the baud rate is 300, but "stty 9600 < /dev/tty02 & cat FILENAME /dev/tty02" moves FILENAME to the Z80 at 9600 baud. Par for the course is that "stty 9600 < /dev/tty02 & cat /dev/tty02" seems to pick up garbage when the Z80 transmits at 9600; I'm guessing, but I highly suspect the "cat" is reading at 300 baud. TFM says that stty sets the line characteristics, but it doesn't say how long they stay set; it implies that after *every* open, the baud rate is set to 300 baud. This is confusing, to say the least. How should I go about this task? IDB (714) 856-6693 ICS Dept/ UC Irvine, Irvine CA 92717
ggw@wolves.uucp (Gregory G. Woodbury) (08/28/90)
In <9008280005.aa24338@PARIS.ICS.UCI.EDU> baxter@zola.ICS.UCI.EDU (Ira Baxter) writes: > >Trying "stty 9600 < /dev/tty02 & stty -a /dev/tty02" also tells >me the baud rate is 300, but "stty 9600 < /dev/tty02 & cat FILENAME /dev/tty02" >moves FILENAME to the Z80 at 9600 baud. >Par for the course is that "stty 9600 < /dev/tty02 & cat /dev/tty02" >seems to pick up garbage when the Z80 transmits at 9600; >I'm guessing, but I highly suspect the "cat" is reading at 300 baud. >TFM says that stty sets the line characteristics, but it doesn't say >how long they stay set; it implies that after *every* open, the baud rate >is set to 300 baud. This is confusing, to say the least. The key is that the stty command opens the post, sets it, then closes the port (automagically) which resets it to defaults. The "Fine Manual" actuall has the answer embedded in discussions about the Line Printer Spooler where it talks about keeping the port characteristics active while the rest of the shell scripts do their magic. The answer is to have a command like: sleep 10000 >/dev/tty02 & preceed your stty 9600 </dev/tty02 >/dev/tty02 cat /dev/tty02 >file commands. The sleep keeps the port open but inactive. For technical completeness you should probably get the pid of the sleep command from the variable "$!" and kill the sleep process after your transfer is done. -- Gregory G. Woodbury @ The Wolves Den UNIX, Durham NC UUCP: ...dukcds!wolves!ggw ...mcnc!wolves!ggw [use the maps!] Domain: ggw@cds.duke.edu ggw%wolves@mcnc.mcnc.org [The line eater is a boojum snark! ] <standard disclaimers apply>
cpcahil@virtech.uucp (Conor P. Cahill) (08/29/90)
In article <9008280005.aa24338@PARIS.ICS.UCI.EDU> baxter@zola.ICS.UCI.EDU (Ira Baxter) writes: > >an ancient Z80 CP(shudder)M system at 9600 baud. I assume that UNIX >on my 20Mhz 386 can catch any stream of characters I pitch at it >without losing anything [if it can't, I'll just lower the baud rate This isn't necessarily true (especially when the machine has other work to do). >Trying "stty 9600 < /dev/tty02 & stty -a /dev/tty02" also tells The correct way to do this is as follows: (stty 9600; stty -a) < /dev/tty02 Or, for your data capture: (stty 9600; cat > capture_file) < /dev/tty02 >Par for the course is that "stty 9600 < /dev/tty02 & cat /dev/tty02" >seems to pick up garbage when the Z80 transmits at 9600; Describe garbage. I mean, do some of the characters get garbled, or do you get additional junk data or do you loose some data? This may be a simptom of flow control not being correctly set between the system and your Z80 (on either side). -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170
pim@cti-software.nl (Pim Zandbergen) (08/29/90)
ggw@wolves.uucp (Gregory G. Woodbury) writes: >The answer is to have a command like: > sleep 10000 >/dev/tty02 & >preceed your > stty 9600 </dev/tty02 >/dev/tty02 > cat /dev/tty02 >file Much simpler is: { stty 9600 0<&1 cat } < /dev/tty02 > file >For technical >completeness you should probably get the pid of the sleep command from >the variable "$!" and kill the sleep process after your transfer is done. This will then not be necessary anymore. -- Pim Zandbergen domain : pim@cti-software.nl CTI Software BV uucp : uunet!mcsun!hp4nl!ctisbv!pim Laan Copes van Cattenburch 70 phone : +31 70 3542302 2585 GD The Hague, The Netherlands fax : +31 70 3512837
scottc@bnlux0.bnl.gov (david scott coburn) (08/29/90)
In article <1990Aug28.145215.29143@wolves.uucp>, ggw@wolves.uucp (Gregory G. Woodbury) writes: > In <9008280005.aa24338@PARIS.ICS.UCI.EDU> > baxter@zola.ICS.UCI.EDU (Ira Baxter) writes: > > > >Trying "stty 9600 < /dev/tty02 & stty -a /dev/tty02" also tells > >me the baud rate is 300, but "stty 9600 < /dev/tty02 & cat FILENAME /dev/tty02" > >moves FILENAME to the Z80 at 9600 baud. [snip] > The key is that the stty command opens the post, sets it, then closes > the port (automagically) which resets it to defaults. The "Fine Manual" > actuall has the answer embedded in discussions about the Line Printer > Spooler where it talks about keeping the port characteristics active > while the rest of the shell scripts do their magic. > The answer is to have a command like: > sleep 10000 >/dev/tty02 & > preceed your > stty 9600 </dev/tty02 >/dev/tty02 > cat /dev/tty02 >file > commands. The sleep keeps the port open but inactive. For technical [snip] > Gregory G. Woodbury @ The Wolves Den UNIX, Durham NC I have the following file in my /etc/rc.d directory: # fudge to keep printer port open echo starting printer fudge routine while [ "/dev/tty00" ] do sleep 30000 > /dev/tty00 done & stty 9600 < /dev/tty00 This enables us to copy to an epson printer on the port by simply copying to the device /dev/tty00. The loop causes problems if you happen to be writing to the port when the 30000 seconds runs out and there is a brief time that the baud rate goes back to the default (300). I have always felt that there should be a better way... scott coburn brookhaven national laboratory scottc@max.bnl.gov [130.199.128.6] upton, ny, usa Define the Universe. Give three examples.
petej@ssg0.pharmacia.com (Peter M. Jansson) (08/29/90)
A reasonably safe way to do what you are trying to do is to run both commands in a subshell. It should work in sh and csh. You do something like this: (stty 4800; cat) < /dev/ttyxx > blechen
walter@mecky.UUCP (Walter Mecky) (08/30/90)
In article <1990Aug28.145215.29143@wolves.uucp> ggw@wolves.uucp (Gregory G. Woodbury) writes:
< The answer is to have a command like:
< sleep 10000 >/dev/tty02 &
< preceed your
< stty 9600 </dev/tty02 >/dev/tty02
< cat /dev/tty02 >file
< commands. The sleep keeps the port open but inactive. For technical
< completeness you should probably get the pid of the sleep command from
< the variable "$!" and kill the sleep process after your transfer is
< done.
Why bother with the sleep command, its time value and killing it?
I suggest:
( stty 9600
cat >file ) </dev/tty02
Now the port is open exactly in the time is must be. Not longer,
not shorter.
--
Walter Mecky [ walter@mecky.uucp or ...uunet!unido!mecky!walter ]