linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: llandre <r&d@wawnet.biz>
To: "yhxing" <xyuhua_telecom@hotmail.com>
Cc: "linuxppc-embedded@lists.linuxppc.org"
	<linuxppc-embedded@lists.linuxppc.org>
Subject: Re: How to control RTS signal ?
Date: Tue, 23 Dec 2003 14:36:45 +0100	[thread overview]
Message-ID: <6.0.0.22.0.20031223142940.01e57ae0@192.168.2.1> (raw)
In-Reply-To: <Sea1-DAV34kO1dJFUuS0000e1ba@hotmail.com>


>
>Hi,
>
>    Now we are using a mpc823 embedded system, and there is some trouble.
>We need to use SCC3 UART to control RS485 tranceiver. TXD3 is connected
>to RS485 tranceiver's D pin, RXD3 is connected to RS485 tranceiver's R
>pin, and RTS3 is connected to RS485 tranceiver's RE# and DE pin. Then
>when transmitting data, we hope RTS3 signal can keep low to enble D.
>When receiving data, we hope RTS3 signal can keep high to enble R.
>    So my question is, how can I program to control RTS3 signal in ppclinux.

Hi,

the simplest solution I found so far is to control the RTS signal in the
application, like this:

                 int mcs = TIOCM_RTS;
                 /* clear RTS */
                 ioctl(fd, TIOCMBIC, &mcs);
                 ...

                 /* Before starting a transmission, we must set the RTS
signal */
                 ioctl(fd, TIOCMBIS, &mcs);


                 /* Now we can safely transmit the message with the usual
write system call */
                 write(fd, buf, strlen(buf));

                 /* Before switching back to receiving mode, we must
ascertain the trasmission is actually completed by reading the Line Status
Register */
                 do {
                         ioctl (fd, TIOCSERGETLSR, &lsr);
                 } while (!(lsr & TIOCSER_TEMT));

                 /* clear RTS */
                 ioctl(fd, TIOCMBIC, &mcs);

Otherwise you can modify the serial driver in order to manage the direction
pin internally inside it. Even if this technique is discouraged by kernel
maintainers, there are several examples available (I think the CRIS
architecture serial driver implements this solution).





Hope this helps,

llandre


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

  parent reply	other threads:[~2003-12-23 13:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-19  4:50 How to control RTS signal ? yhxing
2003-12-19 20:37 ` Wolfgang Denk
2003-12-23 13:36 ` llandre [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-26  9:32 邢 渝华
2004-01-01 17:29 ` llandre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6.0.0.22.0.20031223142940.01e57ae0@192.168.2.1 \
    --to=r&d@wawnet.biz \
    --cc=linuxppc-embedded@lists.linuxppc.org \
    --cc=xyuhua_telecom@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).