|
From: | Jerry DeLisle |
Subject: | Re: [gforth] Debugging serial I/O to USB RS232 port |
Date: | Fri, 07 Nov 2014 15:09:29 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 10/31/2014 06:17 PM, Bernd Paysan wrote:
Am Freitag, 31. Oktober 2014, 18:13:58 schrieb Jerry DeLisle:On 10/31/2014 05:57 PM, Bernd Paysan wrote: ---snip---No, if you want to have direct access to open, use a special C interface. I think I should add open and fdopen (to get an fd) to the serial.fs code, so that you can use open directly, and try different flags. We also found that on some serial ports, you don't even want to use fdopen, because it sets some things which the serial port driver can't handle... this means, you also need read/write to access the port.If you like, I will attempt to add some things to serial.fs and send to you for a look. It should not take too much.Yes, do so; check out the current git; I've already added open, fdopen, read, and write. You'll have to define the macros, and modify open-port (probably factoring into an open-port-fd, which will give you a fd for read/write, and open-port gives you the FILE*, to be backward compatible).
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.
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.
Regards, Jerry
serial.diff
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |