Trying to work on Raspberry Pi 3, Model B V1.2 with several serial ports with C++ code. Previously I should say that when I use only one ports everything works like a charm, so ports configuration is correct. Termios is used with appropriate speeds, stop bits and so on. Timings are configured by
tty.c_cc[VMIN] = 0;
tty.c_cc[VTIME] = 5;
My program uses vector of pointers on my own serial port class. In the loop I ask every port from vector and if timing (0.5 s) is over, program continues. If only one serial port is pushed pack, everything is OK. When I add at least one more port, looks like that timings become broken and 0.5 seconds transform to something much more faster and no one byte could be read. I tested my program with several ports on PC with 4.15.0-46-generic #49-Ubuntu and there was not any problem, so I decided that the root of my issue is on Raspberry (or Raspbian). What can I do to find correct workaround?
Short version of my code:
for (tx_uart* port: uarts) {
// Work with port while getting info
while (frame_asked.at(port->getID())) {
bool processed = false;
// Read buffer while first zero byte
while (!processed) {
uint8_t buffer[MY_BUFFER_SIZE];
size_t readed = port->readBytes(buffer, MY_BUFFER_SIZE);
if (readed == 0) {
std::cout << "nothing" << std::endl;
continue;
}
// Reading until whole pkg got
}
// Processing
}
}
So problem is occured when I try to ready bytes in
size_t readed = port->readBytes(buffer, MY_BUFFER_SIZE);
all timing are skipping and always I get readed = 0
.
Edit 1: I use serial ports with /dev/ttyUSB* and USB-RS232 convertors.