[comp.sys.mac.programmer] Serial driver: Why is CTSHold being set?

rang@cs.wisc.edu (Anton Rang) (06/06/90)

I'm starting my first project using the serial driver soon, and was
playing around with a simple test program.  Unfortunately, I soon
became stuck.  I can get the driver open, but then nothing else
happens.  It seems to think that the handshaking isn't right.

  What I do:

   1.  Call RAMSDOpen (on port A).
   2.  Call SerReset for the port A input and output drivers.
   3.  At this point, I want to do a write.
       But it just hangs.

Calling SerStatus reports that 'holdCTS' is on.  Presumably, this
means that the driver is convinced my modem isn't ready.  But (1) my
modem has CTS forced on, and (2) all the communications software I
have works fine.

  I've tried calling SerHShake to disable handshaking (which I thought
was the default), and it doesn't change anything, which is pretty much
what I expected.

  I'm sure I must be missing something obvious.  Anyone have
suggestions or sample code?  Many thanks in advance!

	Anton (rang@cs.wisc.edu)

P.S.  I'd like to wind up with an application which can handle
      incoming data while in the background under MultiFinder.
      Anyone have any suggestions on the best (or worst) ways
      to go about this?  I've thought about setting up a big
      input buffer and periodically checking how many characters
      are in the buffer, using PBRead to extract them, and either
      queueing them for later or processing them.  Will this work?

P.P.S.  OK, so I'm curious.  Is there a trap which will display the
        about box for the communications toolbox?  :-)
   
+---------------------------+------------------+-------------+
| Anton Rang (grad student) | rang@cs.wisc.edu | UW--Madison |
+---------------------------+------------------+-------------+

chesley@goofy.apple.com (Harry Chesley) (06/07/90)

In article <RANG.90Jun5232240@derby.cs.wisc.edu> rang@cs.wisc.edu (Anton 
Rang) writes:
>   What I do:
> 
>    1.  Call RAMSDOpen (on port A).

According to a recent tech note, it's now better to do just an OpenDriver, 
rather than RAMSDOpen. RAMSDOpen was needed to load the RAM driver in the 
original Macs, but now that driver is standard. I don't believe this could 
cause any problems at this point, but OpenDriver is better for the future.

>    2.  Call SerReset for the port A input and output drivers.

Triple check the parameters to this call. It's quite possible that 
something is off, and so you're sending at the wrong baud-rate, number of 
data bits, or something.

> Calling SerStatus reports that 'holdCTS' is on.  Presumably, this
> means that the driver is convinced my modem isn't ready.  But (1) my
> modem has CTS forced on, and (2) all the communications software I
> have works fine.

CTS is used for signal flow control. However, I'm quite sure the driver 
doesn't listen to it unless you explicitly turn it on via SerHShake, so 
the problem should be earlier than that. If you are trying to talk to a 
modem, it's possible that the modem isn't listening until some modem 
signal is asserted (like DTR), though other comm software working suggests 
that's not it. Don't, however, count on the modem wires going through from 
the modem to the Mac, as there are as many different cables out there as 
there are permutations of the wires in the cables (unless you've buzzed 
your cable out yourself).

> P.S.  I'd like to wind up with an application which can handle
>       incoming data while in the background under MultiFinder.
>       Anyone have any suggestions on the best (or worst) ways
>       to go about this?  I've thought about setting up a big
>       input buffer and periodically checking how many characters
>       are in the buffer, using PBRead to extract them, and either
>       queueing them for later or processing them.  Will this work?

That's the way I'd do it. You can also set up an asynchronous read.