State of CTS line is not being reported correctly.
| Originator: | jszakmeister | ||
| Number: | rdar://23820354 | Date Originated: | 12/9/2015 |
| Status: | Open | Resolved: | |
| Product: | OS X | Product Version: | 10.11 |
| Classification: | Reproducible: | Always |
Summary:
I'm an engineer and need to interact with serial ports all the time. I was testing a device and expected to see the CTS line change when I filled its buffer, but it did not. Instead, it always reports CTS as being asserted. It could be the Apple FTDI driver, but it could be elsewhere in the system too.
Steps to Reproduce:
1. Obtain an FTDI-based USB-to-Serial cable. I've used two different ones, the UT232R and the US232R.
2. Attach a loopback device to the cable. Be sure that it connects pins 7 and 8 of the DB9 together.
3. Run the attached script. It's a python script that will toggle the RTS line, and we should see the CTS line change. It does not though. It always (incorrectly) reports that CTS is asserted.
Expected Results:
I expect to see the CTS line report back as being de-asserted in the scenario I gave above. The script output should be:
:: python check-rtscts.py /dev/tty.usbserial-FTXPLBFQ
RTS:4 CTS:32
RTS set correctly
CTS set correctly
RTS:0 CTS:0
RTS set correctly
CTS set correctly
Actual Results:
CTS is not set correctly.
:: python check-rtscts.py /dev/tty.usbserial-FTXPLBFQ
RTS:4 CTS:32
RTS set correctly
CTS set correctly
RTS:0 CTS:32
RTS set correctly
CTS is NOT set correctly
Version:
Tested with both 10.11.1 and 10.11.2.
Notes:
Configuration:
Attachments:
'check-rtscts.py' was successfully uploaded.
For those interested, this is the contents of the script:
import termios
import fcntl
import os
import struct
import sys
def dump_state(state):
print "RTS:%r CTS:%r" % (state & termios.TIOCM_RTS,
state & termios.TIOCM_CTS)
def read_state(fd):
result = fcntl.ioctl(fd, termios.TIOCMGET, struct.pack('I', 0))
bits = struct.unpack('I', result)[0]
dump_state(bits)
return bits
def set_rts(fd, level):
if level:
fcntl.ioctl(fd, termios.TIOCMBIS, struct.pack('I', termios.TIOCM_RTS))
else:
fcntl.ioctl(fd, termios.TIOCMBIC, struct.pack('I', termios.TIOCM_RTS))
fd = os.open(sys.argv[1], os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
set_rts(fd, True)
state = read_state(fd)
if state & termios.TIOCM_RTS:
print "RTS set correctly"
else:
print "RTS is NOT set correctly"
if state & termios.TIOCM_CTS:
print "CTS set correctly"
else:
print "CTS is NOT set correctly"
set_rts(fd, False)
state = read_state(fd)
# RTS should be off...
if state & termios.TIOCM_RTS:
print "RTS is NOT set correctly"
else:
print "RTS set correctly"
# And so should CTS...
if state & termios.TIOCM_CTS:
print "CTS is NOT set correctly"
else:
print "CTS set correctly"
os.close(fd)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!