From: rketcham <Ric...@gm...> - 2009-03-04 16:54:50
|
Hello, I'm trying to employ RTS and CTS through the BTUART. Unfortunately, it looks like something is amiss. When I write to the serial port, the RTS line is always brought low regardless if RTSCTS has been set or not. Also, I don't have to be sending anything for RTS to be driven low; I just have to open the port. Is this normal operation? I wouldn't think so... After observing these two features I tried communicating with my external device anyway. The external device would see RTS driven low and respond with driving CTS low but the serial driver never sees CTS change and so gets hung up waiting to send the data. I tried doing this myself by disabling RTSCTS, driving RTS low manually (ioctl) and waiting for CTS to be driven low in a while loop. However, the ioctl never returns with CTS as other than 0. Is there a known problem with the serial driver that causes this? Is there a simple way for me to fix this without getting into driver programming? If not, do you have any advice on what I need to edit? My buildroot revision is 1633. I have RTS on the Gumstix connected to RTS on my external device. I also have CTS on the Gumstix connected to CTS on my external device. Thanks, Rich Here is my code for setting up the serial port _fileDescriptor = open(devicePath.c_str(), O_RDWR | O_NOCTTY);//Open the port if (_fileDescriptor== -1) //Opening of port failed { fprintf(stderr,"open_port: Unable to open %s.\n", devicePath.c_str()); } int databits = 8;//Number of data bytes in packet. //Initialize to the default value. int BAUD = B115200; //115200 bits per sec int DATABITS = CS8;//8 data bits per packet int STOPBITS = ~CSTOPB; //1 stop bit int PARITY = 0; // 0 parity int PARITYON = ~PARENB;//Parity is not enabled. int status = 0; //Assume the port is set with the new comm settings. //Get the current options for the port... tcgetattr(_fileDescriptor, &_options); //Sellect the baud rate. switch(baudRate) { //115200: //Most likely according to the SDK. case baudRate_115200: BAUD = B115200; break; case baudRate_2400: BAUD = B2400; break; case baudRate_4800: BAUD = B4800; break; case baudRate_9600: BAUD = B9600; break; case baudRate_19200: BAUD = B19200; break; case baudRate_38400: BAUD = B38400; break; case baudRate_57600: BAUD = B57600; break; default: BAUD = B115200; //Default to the baud in the SDK } cfsetospeed(&_options, BAUD); cfsetispeed(&_options, BAUD); //Assign the number of data bits. switch(databits) { case 8: DATABITS = CS8; break; case 7: DATABITS = CS7; break; case 6: DATABITS = CS6; break; //Not likely but available. case 5: DATABITS = CS5; break; //Not likely but available. default: DATABITS = CS8; //Default to SDK value } _options.c_cflag &= ~CSIZE; /* Mask the character size bits */ _options.c_cflag |= DATABITS;/* Select 8 data bits */ //Assign the number of stop bits. switch(stopBits) { case stopBits__1_0: STOPBITS = ~CSTOPB;//Not 2 --> 1 stop bit _options.c_cflag &= STOPBITS;// stop bits break; case stopBits__2_0: STOPBITS = CSTOPB; //2 stop bits _options.c_cflag |= STOPBITS;// stop bits break; default: STOPBITS = ~CSTOPB; //Default to SDK value _options.c_cflag &= STOPBITS;// stop bits } //Set parity. switch(parity) { case parity_none: //No parity. PARITYON = ~PARENB; _options.c_cflag &=PARITYON; PARITY = 0; //Doesn't matter break; case parity_odd://Odd parity. PARITYON = PARENB; _options.c_cflag |=PARITYON; PARITY = PARODD; _options.c_cflag |= PARITY;//Odd Parity break; case parity_even://Even parity. PARITYON = PARENB; _options.c_cflag |=PARITYON; PARITY = ~PARODD; _options.c_cflag &= PARITY;//Even Parity break; default: //Default setting doesn't have parity checking. PARITYON = ~PARENB;//No parity _options.c_cflag &=PARITYON; PARITY = 0;//Doesn't matter } //set for non-canonical (raw processing, no echo, etc.) _options.c_iflag = IGNPAR; // ignore parity check close_port(int _options.c_oflag = 0; // raw output _options.c_lflag = 0; // raw input //Time-Outs -- won't work with NDELAY option in the call to open _options.c_cc[VMIN] = 0; // block reading until RX x characers. If x = 0, it is non-blocking. _options.c_cc[VTIME] = 1; // Inter-Character Timer -- i.e. timeout= x*.1 s //Set local mode and enable the receiver _options.c_cflag |= (CLOCAL | CREAD); _options.c_cflag |= CRTSCTS; //Turn on flow control //_options.c_cflag &= ~CRTSCTS; //Turn off flow control //Purge serial port buffers Purge(); //Set the new options for the port... status=tcsetattr(_fileDescriptor, TCSANOW, &_options); if (status != 0) //For error message printf("Setting com port didn't work!\n"); //else //printf("Setting com port did work!\n"); //Get the current options for theRead port... tcgetattr(_fileDescriptor, &_options); //Purge serial port buffers Purge(); -- View this message in context: http://www.nabble.com/Serial-Driver%2C-BTUART%2C--RTS-is-always-driven-low-and-CTS-is-never-seen-tp22334238p22334238.html Sent from the Gumstix mailing list archive at Nabble.com. |