gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Debugging serial I/O to USB RS232 port


From: Bernd Paysan
Subject: Re: [gforth] Debugging serial I/O to USB RS232 port
Date: Sat, 08 Nov 2014 02:45:40 +0100
User-agent: KMail/4.14.2 (Linux/3.16.6-2-desktop; KDE/4.14.2; x86_64; ; )

Am Freitag, 7. November 2014, 15:09:29 schrieb Jerry DeLisle:
> Attached is a small patch that fixes a bug in serial.fs I found, adds close,
> and a couple constants I am using.  I am still learning my way around git. 
> You may have updated since I did this.  I plan to do more, I have just been
> sick with head cold for last week or so.

Thanks.

> I also have some words to set and clr some control bits if interested:
> 
> variable result
> 0 result !
> 
> HEX
> 5415 CONSTANT TIOCMGET
> 5418 CONSTANT TIOCMSET
> 002  CONSTANT TIOCM_DTR
> 004  CONSTANT TIOCM_RTS
> 020  CONSTANT TIOCM_CTS
> 100  CONSTANT TIOCM_DSR
> DECIMAL
> 
> : get-ioctl  ( fd -- n )
> 
>      TIOCMGET result ioctl 0< abort" IOCTL GET Failed." result @ ;
> 
> : set-ioctl  ( fd n -- )
> 
>      result ! TIOCMSET result ioctl 0< abort" IOCTL SET Failed." ;
> 
> : set-dtr  ( fd -- )
> 
>      dup get-ioctl TIOCM_DTR or set-ioctl ;
> 
> : clr-dtr  ( fd -- )
> 
>      dup get-ioctl TIOCM_DTR invert and set-ioctl ;
> 
> : set-rts  ( fd -- )
> 
>      dup get-ioctl TIOCM_RTS or set-ioctl ;
> 
> : clr-rts  ( fd -- )
> 
>      dup get-ioctl TIOCM_RTS invert and set-ioctl ;
> 
> : get-cts  ( fd -- n )
> 
>      get-ioctl TIOCM_CTS and ;
> 
> : get-dsr  ( fd -- n )
> 
>      get-ioctl TIOCM_DSR and ;
> 
> I have tested most of these and I am using them for an application i am
> working on.  They seemed useful to me.  I hope the factoring looks OK.

The factoring is ok, but you should use number prefixes instead of HEX .. 
DECIMAL.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]