[comp.sys.m68k] Need help connecting m68k to a UNIX box.

henry@ginger.sri.com (Henry Pasternack) (07/31/90)

   This is technically a UNIX question, but I have this paranoid 
feeling that posting to a UNIX bulletin board would be an exercise
in futility.  Perhaps someone over here can help me out.

   Problem: My 68000 board is running now, and I'm successfully
programming it in C using the Sun3 compiler.  I've written a two-part
communications program for the purpose of downloading S-record code
from a SPARCStation to the 68000.  I use kermit to provide terminal
emulation over the Sun's 'ttya' port.  The 'ttyb' port is driven by
my communications program which listens for file requests from the 
client and dumps S-records on command.

   I'm having a lot of trouble getting the interface to '/dev/ttyb'
to work.  I admit to knowing virtually nothing about UNIX I/O, and
the reference manuals aren't much help.  The port already seems to be
configured for 9600 baud, which is convenient.  I do an 'fopen' on
'/dev/ttyb' and use 'gets' and 'fprintf' to perform I/O.  The Sun
has no problem receiving command lines from the client, but when the
client begins polling for a response after sending a request, it gets
a garbled copy of its request back.  It seems as though the buffer
UNIX is creating is bidirectional, rather than dual-unidirectional.

   Can anyone give me an understandable explanation of how to set
up my SPARCStation to do simple and effective I/O to the serial ports?

   Thanks.

-Henry

stevem@sauron.Columbia.NCR.COM (Steve McClure) (07/31/90)

In article <14703@unix.SRI.COM> henry@ginger.sri.com (Henry Pasternack) writes:
+
+   This is technically a UNIX question, but I have this paranoid 
+feeling that posting to a UNIX bulletin board would be an exercise
+in futility.  Perhaps someone over here can help me out.
+
+   Problem: My 68000 board is running now, and I'm successfully
+programming it in C using the Sun3 compiler.  I've written a two-part
+communications program for the purpose of downloading S-record code
+from a SPARCStation to the 68000.  I use kermit to provide terminal
+emulation over the Sun's 'ttya' port.  The 'ttyb' port is driven by
+my communications program which listens for file requests from the 
+client and dumps S-records on command.
+
+   I'm having a lot of trouble getting the interface to '/dev/ttyb'
+to work.  I admit to knowing virtually nothing about UNIX I/O, and
+the reference manuals aren't much help.  The port already seems to be
+configured for 9600 baud, which is convenient.  I do an 'fopen' on
+'/dev/ttyb' and use 'gets' and 'fprintf' to perform I/O.  The Sun
+has no problem receiving command lines from the client, but when the
+client begins polling for a response after sending a request, it gets
+a garbled copy of its request back.  It seems as though the buffer
+UNIX is creating is bidirectional, rather than dual-unidirectional.
+
+   Can anyone give me an understandable explanation of how to set
+up my SPARCStation to do simple and effective I/O to the serial ports?
+

I wrote some PROM Programmer software for a Unix box and ended up opening
a read-only file and a write-open file on the same port.  This same technique
is used in the Unix cu command so I assume it is pretty much standard.  Hope
this helps.

-- 
----------------------------------------------------------------------
Steve		email: Steve.McClure@Columbia.NCR.COM	803-791-7054
The above are my opinions, which NCR doesn't really care about anyway!
CAUSER's Amiga BBS! | 803-796-3127 | 8pm-8am 8n1 | 300/1200/2400

mason@Unify.Com (Mark Mason) (08/02/90)

In article <2254@sauron.Columbia.NCR.COM> stevem@sauron.UUCP (Steve McClure) writes:
>In article <14703@unix.SRI.COM> henry@ginger.sri.com (Henry Pasternack) writes:
[del...]
>+   I'm having a lot of trouble getting the interface to '/dev/ttyb'
>+to work.  I admit to knowing virtually nothing about UNIX I/O, and
>+the reference manuals aren't much help.  The port already seems to be
>+configured for 9600 baud, which is convenient.  I do an 'fopen' on
>+'/dev/ttyb' and use 'gets' and 'fprintf' to perform I/O.  The Sun
>+has no problem receiving command lines from the client, but when the
>+client begins polling for a response after sending a request, it gets
>+a garbled copy of its request back.  It seems as though the buffer
>+UNIX is creating is bidirectional, rather than dual-unidirectional.
>+
>+   Can anyone give me an understandable explanation of how to set
>+up my SPARCStation to do simple and effective I/O to the serial ports?
>+
[del...]

you need to do a fflush() on the stream before "changing direction"
(reading -> writing or writing -> reading).

like:
	fgets()
-->	fflush()
	fprintf()
-->	fflush()
	fgets()

etc.

Hope this helps.
mason
pyramid!unify!mason for 1 more week...
mason@reed.bitnet forever!

-- 
{{ucdavis,csun,lll-crg}!csusac,pyramid,sequent}!unify!mason
-or- mason@reed.bitnet
The above opinions/falsehoods/misconceptions are my own....