Аппаратный поток управления RTS / CTS не работает в Linux (например, данные все еще могут передаваться по Tx, даже если CTS отключен)

Я использую SUSE Linux и пытаюсь общаться через последовательное устройство с потоком управления RTS / CTS. Мой код выглядит следующим образом:

#define _BSD_SOURCE
#define _SVID_SOURCE

#include <stdio.h>      // standard input / output functions
#include <stdlib.h>
#include <string.h>     // string function definitions
#include <unistd.h>     // UNIX standard function definitions
#include <fcntl.h>      // File control definitions
#include <errno.h>      // Error number definitions
#include <termios.h>    // POSIX terminal control definitions

#include <iostream>
using namespace std;

int main(){
// open port
int USB = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY );

// set parameters
struct termios tty;
struct termios tty_old;
memset (&tty, 0, sizeof tty);

/* Error Handling */
if ( tcgetattr ( USB, &tty ) != 0 )
{
cout << "Error " << errno << " from tcgetattr: " << strerror(errno) << endl;
}

/* Save old tty parameters */
tty_old = tty;

/* Set Baud Rate */
cfsetospeed (&tty, (speed_t)B9600);
cfsetispeed (&tty, (speed_t)B9600);

/* Setting other Port Stuff */
tty.c_cflag     &=  ~PARENB;        // Make 8n1
tty.c_cflag     &=  ~CSTOPB;
tty.c_cflag     &=  ~CSIZE;
tty.c_cflag     |=  CS8;
tty.c_cflag     |=  CRTSCTS;       // set RTS/CTS flow control

tty.c_cc[VMIN]      =   1;                  // read doesn't block
tty.c_cc[VTIME]     =   5;                  // 0.5 seconds read timeout

/* Make raw */
cfmakeraw(&tty);

/* Flush Port, then applies attributes */
tcflush( USB, TCIFLUSH );
if ( tcsetattr ( USB, TCSANOW, &tty ) != 0){
cout << "Error " << errno << " from tcsetattr" << endl;
}

// write
unsigned char cmd[] = "Message\r";
int n_written = 0;

do {
n_written += write( USB, &cmd[n_written], 1 );
}
while (cmd[n_written-1] != '\r' && n_written > 0);

return 0;
}

Я выполнил свой код и с помощью осциллографа измерил контакты CTS +, RTS + и Tx + подключенных разъемов RS422 последовательного порта к USB (http://www.easysync-ltd.com/product/645/usb2-h-6008-m.html), который я перепрыгнул через две клеммы, чтобы соединить вместе, используя перекрестный кабель. В результате напряжение на контактах CTS + и RTS + осталось неизменным после записи данных, даже если поток управления уже был включен в линии:

tty.c_cflag     |=  CRTSCTS;       // set RTS/CTS flow control

Другая неправильная ситуация состоит в том, что данные все еще проходят через Tx даже в случае, если CTS отключен.

Может ли кто-нибудь помочь мне с этой проблемой? Или, если кто-то раньше использовал последовательную связь с RTS / CTS, не могли бы вы подсказать, как вы это сделали?

1

Решение

Задача ещё не решена.

Другие решения