[comp.sys.amiga] serial.device

herr@calgary.UUCP (Charles Herr) (01/03/88)

 I am currently playing around with the serial device
and would like the following question answered. Can anyone help?
 This is the problem: How do you check for Carrier Detect?
Assuming I have opened the serial.device properly, would the
following code work?
   
  Serial->IORser.io_Command = SRCMD_QUERY;
  DoIO(Serial);
  if(Serial->io_Status & `\040`)
     then carrier_detected = 1;
     else carrier_detected = 0;

Maybe some of the variable names are wrong (I don't have my code
handy right now), but I am doing the right thing?

Trevor "The Geek" Paquette (via Charles "Non-Geek" Herr)

herr@calgary.UUCP

carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (01/12/88)

In article <1270@vaxb.calgary.UUCP> herr@calgary.UUCP (Charles Herr) writes:
>
> I am currently playing around with the serial device
>and would like the following question answered. Can anyone help?
> This is the problem: How do you check for Carrier Detect?
>Assuming I have opened the serial.device properly, would the
>following code work?
>   
>  Serial->IORser.io_Command = SRCMD_QUERY;
>  DoIO(Serial);
>  if(Serial->io_Status & `\040`)
>     then carrier_detected = 1;
>     else carrier_detected = 0;
>
>Maybe some of the variable names are wrong (I don't have my code
>handy right now), but I am doing the right thing?

Basic concept is correct, but

1. Serial.doc lists carrier detect status bit as ACTIVE LOW, so your test
   is probably backwards.  (at least if you want carrier_detected to be
   TRUE when carrier IS detected)

2. Serial request io_Status is a UWORD variable and you are &'ing it 
   with a character.  C might extend that properly (as long as bit7 isn't
   set in the character) but I certainly wouldn't do it that way.
   You should be &'ing with 0x0020  or even better, set up a #define like

#define SDF_ST_CARRIER  (1L<<5)

   and & with that.  

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CATS   >>Commodore Amiga Technical Support<<
                     UUCP  ...{allegra,ihnp4,rutgers}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

cks@radio.toronto.edu (Chris Siebenmann) (01/24/88)

 While we're on this topic, is there any way of getting the serial
device to send a message or a signal when the status of the carrier
drops? I'd rather not rely on the modem sending me some characters
when this happens.  Is setting up a timer message to ping the program
every so often so it can go off and check the approved way of doing
this?

-- 
	"I shall clasp my hands together and bow to the corners of the world."
			Number Ten Ox, "Bridge of Birds"
Chris Siebenmann		{allegra,mnetor,decvax,pyramid}!utgpu!radio!cks
cks@radio.toronto.edu	     or	...!utgpu!{chp!hak!ziebmef,ontmoh}!cks

dillon@CORY.BERKELEY.EDU (Matt Dillon) (01/25/88)

> While we're on this topic, is there any way of getting the serial
>device to send a message or a signal when the status of the carrier
>drops? I'd rather not rely on the modem sending me some characters
>when this happens.  Is setting up a timer message to ping the program
>every so often so it can go off and check the approved way of doing
>this?

	No, Yes.

	No, the serial.device does not have the capability.
	Yes, the easiest way (if you don't want to wait for a char) is to
	simply query it every so often.

				-Matt

rouaix@inria.UUCP (Francois Rouaix) (05/30/88)

I'm posting this for a friend. I realize that this should belong to
comp.sys.amiga.tech, but since my friend does not receive this group
at his site, here it is:

---------------------------------------------------------------------------
Titre: Testing for XOFF condition when using serial.device

 I Wanted to post, this to .tech, but since we haven't gotten that group
for the last month or so, and it looks like things won't change any time
soon now...

 I'm using the serial.device, and I need to know if transmission is stopped
due to having received XOFF.

 So I did the obvious:

   if( IOSTF_XOFFREAD & InSer->io_Status) {
      /* we're XOFF'ed */
   }
   else {
      /* No XOFF */
   }

 Now this didn't work, but I noticed that the value of io_Status seemed to
be 4 when an XOFF had been received.

 So I looked into devices/serial.h, and found

#define IOSTB_XOFFREAD 4L
#define IOSTF_XOFFREAD (1L<<4)

 So I started using:

 if( IOSTB_XOFFREAD==InSer->io_Status)

 and sure enough everything worked just fine.

 Now this is in complete contradiction with the documentation I have
(Mortimore's "Amiga Programmer's Handbook" vol. II p.144).

 So what I'd like to know, is: is io_Status used as a mask, or is it just
an error number, as my experience seems to indicate?

 If I get the answer on this one, I'll post a couple of diffs to the
moderators for my zmodem port which is still waiting at the moderators of
the binaries/sources groups.


  	Merci beaucoup

	   Frank
----------------------------------------------------------------------------


If you reply my e-mail, Frank's address is ...uunet!mcvax!inria!geocub!anthes
-- 
*- Francois Rouaix                 //       When the going gets tough,       *
*- rouaix@inria.inria.fr         \X/           the guru goes meditating...   *
*- SYSOP of Sgt. Flam's Lonely Amigas Club. (33) (1) 39-55-84-59 (Videotext) *

bryce@cbmvax.UUCP (Bryce Nesbitt) (06/01/88)

>I'm using the serial.device, and I need to know if transmission is stopped
>due to having received XOFF.
>
> So I did the obvious:
>
>   if( IOSTF_XOFFREAD & InSer->io_Status) {

The problem is that those bit definitions refer to the HIGH ORDER BYTE
of the io_Status WORD.  This is a bug, and will be fixed.


>#define IOSTB_XOFFREAD 4L
>#define IOSTF_XOFFREAD (1L<<4)

/* change to */
#define IOSTB_XOFFREAD (4+8)L
#define IOSTF_XOFFREAD (1L << IOSTB_XOFFREAD)

That will work.



> So I started using:
>
> if( IOSTB_XOFFREAD==InSer->io_Status)

NO!!!!!!!!!!!!!!! NO!!!!!!!!!!!!!!!!
NO!!!!!!!!!!!!!!! NO!!!!!!!!!!!!!!!!
NO!!!!!!!!!!!!!!! NO!!!!!!!!!!!!!!!!


>If you reply my e-mail, Frank's address is ...uunet!mcvax!inria!geocub!anthes
>rouaix@inria.inria.fr

papa@pollux.usc.edu (Marco Papa) (06/01/88)

In article <3898@cbmvax.UUCP> bryce@cbmvax.UUCP (Bryce Nesbitt) writes:
||I'm using the serial.device, and I need to know if transmission is stopped
||due to having received XOFF.
|| So I did the obvious:  if( IOSTF_XOFFREAD & InSer-|io_Status) {
|
|The problem is that those bit definitions refer to the HIGH ORDER BYTE
|of the io_Status WORD.  This is a bug, and will be fixed.
                                                 ^^^^^^^^
||#define IOSTB_XOFFREAD 4L
||#define IOSTF_XOFFREAD (1L<<4)
|
|/* change to */
|#define IOSTB_XOFFREAD (4+8)L
|#define IOSTF_XOFFREAD (1L << IOSTB_XOFFREAD)
|
|That will work.
      ^^^^^^^^^

Bryce,

What do you mean? Can we assume that the above fix will always work, even
in 1.4 and above?  That is, is the fix just properly documenting the
current situation?

-- Marco Papa 'Doc'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uucp:...!pollux!papa       BIX:papa       ARPAnet:pollux!papa@oberon.usc.edu
 "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=