[futurebasic] Re: [FB] Serial Communications BRK command

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2000 : Group Archive : Group : All Groups

From: "Bill Sanford" <bill@...>
Date: Thu, 02 Mar 2000 17:17:57 -0600
> On 2/29/00 at 12:26 PM, bill@... wrote:
> 
> :Does anyone know how to send a break command (BRK) via a RS-422 serial
> link.
> :The link is just TX+ & - and RX+ & -.  No handshake lines...
> :
> :Do you just toggle the state of the TX lines for a period of time??
> :
> :If so, how can I do this with low level serial commands.
> :
> :I'm using the communications toolbox serial code example done by Greg
> Neagle
> :several years back.
>
> If you are using my code as a starting point, these should work:
>
> CLEAR LOCAL MODE
> LOCAL FN serialSetBreak(port&)
>   '
>   'asserts a break signal
>   '
>   DIM pBlk.50
>   DIM err
>
>   DEF BLOCKFILL(@pBlk, 50, 0)
>   pBlk.ioRefNum% = port&.iRefNum%
>   pBlk.csCode% = 12
>   err = FN CONTROL(@pBlk)
>   err = err OR pBlk.ioResult%
>
> END FN = err

Thanks Greg!  Before you sent this code to me, I did some digging and wrote
(but didn't test) the following code:

CLEAR LOCAL MODE
DIM pBlk.50
LOCAL FN DoBreak(port&, msDuration&)
  DEF BLOCKFILL(@pBlk, 50, 0)
  pBlk.ioRefNum% = port&.oRefNum%
  pBlk.csCode%   = 12
  err = FN CONTROL(@pBlk)
  err = err OR pBlk.ioResult%
  LONG IF err = _nil
    DELAY msDuration&
    DEF BLOCKFILL(@pBlk, 50, 0)
    pBlk.ioRefNum% = port&.oRefNum%
    pBlk.csCode%   = 11
    err = FN CONTROL(@pBlk)
    err = err OR pBlk.ioResult%
  END IF
END FN = err


Since you're the serial comm guru, I assume that your code will work great
and mine won't work because I used the oRefNum% rather than the iRefNum% (as
your code specifies)!  Just one question?  Can you tell me why you used the
iRefNum% rather than the oRefNum%.

Common sense would make you think that since you want to change the status
of the TX lines to initiate a break, you would use the oRefNum% ?  (Not that
the Comm Toolbox always makes sense...)

Bill Sanford