unable to loopback RTS to CTS

View: New views
9 Messages — Rating Filter:   Alert me  

unable to loopback RTS to CTS

by cdaviduik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
I am using a gumstix verdex XL6P with a consoleLCD16 board and via the BTUART (/dev/ttyS1) am attempting to loopback RTS to CTS. So far I have been successful in looping Tx back to Rx but, using the same setup, cannot reproduce the results using RTS and CTS. Although the RTS can be seen (via oscilloscope) to change value, there is no change received in the CTS line. My code for getting/setting the serial lines:

--------------------------------------------------
        tcgetattr(fd, &options);
        options.c_cflag &= ~CRTSCTS;
        options.c_oflag = 0;
        tcsetattr(fd, TCSANOW, &options);
       
        // set RTS high
        ioctl(fd, TIOCMGET, &controlbits);
        controlbits |= TIOCM_RTS;
        ioctl(fd, TIOCMSET, &controlbits);
       
        sleep(1);
       
        // get CTS
        ioctl(fd, TIOCMGET, &controlbits);
        cts_state = controlbits & TIOCM_CTS;
        printf("CTS: %s\n", cts_state ? "on" : "off");
--------------------------------------------------

From what I understand after setting RTS high then the controlbits received via ioctl(f, TIOCMGET, &controlbits) should indicate CTS is high if RTS is loopback to CTS (i.e. connected together). Unfortunately this is not the case as CTS is always read as "off".

Any help would be much appreciated.
Thank you.

Re: unable to loopback RTS to CTS

by cdaviduik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When RTS is looped back to CTS and hardware flow control is set to "on", communication is frozen when RTS/CTS goes high. Unfortunately in this state the program reading and setting the serial lines is also frozen and thus unable to read that CTS is high. If hardware flow control is set to "off", then RTS can be toggled high or low however CTS is always read as low.

I am attempting to edit the serial drivers such that CTS will still read high or low even when hardware flow control is turned off and noticed there is a function "uart_handle_cts_change(struct uart_port *port, unsigned int status)" in serial_core.h that appears to handle when CTS changes state. After making some small changes, adding some "printk" messages, I created a patch, edited my bitbake file, rebuilt it, and then put it on the gumstix. Navigating to "/lib/modules/2.6.21/kernel/drivers/serial", I noticed the size of the 8250.ko had increased in size slightly, which I assume is due to my changes, but when I run my program there does not appear to be any change in behavior nor do any of my printk messages appear on the console.

I do not mind spending some time determining what changes need to be made to the drivers, however at this point it does not appear that the changes I am making are having any impact at all. Are there perhaps some steps I am missing? Has anyone attempted a similar task?

Thank You


cdaviduik wrote:
Hello,
I am using a gumstix verdex XL6P with a consoleLCD16 board and via the BTUART (/dev/ttyS1) am attempting to loopback RTS to CTS. So far I have been successful in looping Tx back to Rx but, using the same setup, cannot reproduce the results using RTS and CTS. Although the RTS can be seen (via oscilloscope) to change value, there is no change received in the CTS line. My code for getting/setting the serial lines:

--------------------------------------------------
        tcgetattr(fd, &options);
        options.c_cflag &= ~CRTSCTS;
        options.c_oflag = 0;
        tcsetattr(fd, TCSANOW, &options);
       
        // set RTS high
        ioctl(fd, TIOCMGET, &controlbits);
        controlbits |= TIOCM_RTS;
        ioctl(fd, TIOCMSET, &controlbits);
       
        sleep(1);
       
        // get CTS
        ioctl(fd, TIOCMGET, &controlbits);
        cts_state = controlbits & TIOCM_CTS;
        printf("CTS: %s\n", cts_state ? "on" : "off");
--------------------------------------------------

From what I understand after setting RTS high then the controlbits received via ioctl(f, TIOCMGET, &controlbits) should indicate CTS is high if RTS is loopback to CTS (i.e. connected together). Unfortunately this is not the case as CTS is always read as "off".

Any help would be much appreciated.
Thank you.

Re: unable to loopback RTS to CTS

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> When RTS is looped back to CTS and hardware flow control is set to "on",
> communication is frozen when RTS/CTS goes high. Unfortunately in this state
> the program reading and setting the serial lines is also frozen and thus
> unable to read that CTS is high. If hardware flow control is set to "off",
> then RTS can be toggled high or low however CTS is always read as low.

Which port are you referring to?

Only the BTUART port has a CTS/RTS signal present. On the FFUART, the
CTS and RTS pins are hooked up the USB circuitry, and the STUART has
no CTS/RTS line.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by Ned Forrester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

cdaviduik wrote:
> Navigating to "/lib/modules/2.6.21/kernel/drivers/serial", I noticed the
> size of the 8250.ko had increased in size slightly, which I assume is due to
> my changes, but when I run my program there does not appear to be any change
> in behavior nor do any of my printk messages appear on the console.

I can't directly address your problem, other than to say that I have
made changes to the serial driver under buildroot without any problems.

If you are not seeing your printks, make sure that you are issuing them
at a level that is currently enabled for printing (KERN_ERR, KERN_DEBUG,
KERN_INFO, etc.).  The current printk level can be changed with

echo n > /proc/sys/kernel/printk

where 1<n<8.  Setting n to 8 enables all messages.  The current log
level can be read as the first digit reported by:

cat /proc/sys/kernel/printk

The order of printk levels, from most severe (always printed) to least is:

KERN_EMERG
KERN_ALERT
KERN_CRIT
KERN_ERR
KERN_WARNING
KERN_NOTICE
KERN_INFO
KERN_DEBUG

--
Ned Forrester                                       nforrester@...
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by cdaviduik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using the BTUART on /dev/ttyS1 and am issuing my printk's with KERN_ALERT. The first digit of "cat /proc/sys/kernel/printk" is 7 so I imagine I should be seeing my messages if the code is in fact reaching them.

Thanks

Ned Forrester wrote:
cdaviduik wrote:
> Navigating to "/lib/modules/2.6.21/kernel/drivers/serial", I noticed the
> size of the 8250.ko had increased in size slightly, which I assume is due to
> my changes, but when I run my program there does not appear to be any change
> in behavior nor do any of my printk messages appear on the console.

I can't directly address your problem, other than to say that I have
made changes to the serial driver under buildroot without any problems.

If you are not seeing your printks, make sure that you are issuing them
at a level that is currently enabled for printing (KERN_ERR, KERN_DEBUG,
KERN_INFO, etc.).  The current printk level can be changed with

echo n > /proc/sys/kernel/printk

where 1<n<8.  Setting n to 8 enables all messages.  The current log
level can be read as the first digit reported by:

cat /proc/sys/kernel/printk

The order of printk levels, from most severe (always printed) to least is:

KERN_EMERG
KERN_ALERT
KERN_CRIT
KERN_ERR
KERN_WARNING
KERN_NOTICE
KERN_INFO
KERN_DEBUG

--
Ned Forrester                                       nforrester@whoi.edu
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by Ned Forrester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

cdaviduik wrote:
> I am using the BTUART on /dev/ttyS1 and am issuing my printk's with
> KERN_ALERT. The first digit of "cat /proc/sys/kernel/printk" is 7 so I
> imagine I should be seeing my messages if the code is in fact reaching them.

Sounds right.

--
Ned Forrester                                       nforrester@...
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by cdaviduik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is anyone sure exactly which functions are getting called in which files (drivers) when I am communication via the BTUART? Perhaps I just do not have my printk messages where they can be reached.

Any amount of pointing in the right (or nearby) direction would be very helpful.

Thanks

Ned Forrester wrote:
cdaviduik wrote:
> I am using the BTUART on /dev/ttyS1 and am issuing my printk's with
> KERN_ALERT. The first digit of "cat /proc/sys/kernel/printk" is 7 so I
> imagine I should be seeing my messages if the code is in fact reaching them.

Sounds right.

--
Ned Forrester                                       nforrester@whoi.edu
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> Is anyone sure exactly which functions are getting called in which files
> (drivers) when I am communication via the BTUART? Perhaps I just do not have
> my printk messages where they can be reached.

The low level file, which talks to the hardware, is in drivers/serial/pxa.c

The functions: serial_pxa_get_mctrl and serial_pxa_set_mctrl are the
ones which query CTS and set RTS.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: unable to loopback RTS to CTS

by Ned Forrester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

cdaviduik wrote:
> Is anyone sure exactly which functions are getting called in which files
> (drivers) when I am communication via the BTUART? Perhaps I just do not have
> my printk messages where they can be reached.
>
> Any amount of pointing in the right (or nearby) direction would be very
> helpful.

The file I edited to change the serial driver was in the kernel tree at:

drivers/serial/pxa.c

Remember that I am using buildroot with a 2.6.20 kernel, so your setup
may be different, but I doubt it.

--
Ned Forrester                                       nforrester@...
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users