Режим порта установлен для Raw Fille в виртуальной машине. Поэтому я вижу, что я могу писать в COM -порт. < /P>
Но чтение из порта каждый раз с ошибкой -11. < /P>
Код моей программы: < /p>
Код: Выделить всё
#include
#include
#include
#include
#include
void configurePort(int fd)
{
struct termios options;
// Get current port parameters
tcgetattr(fd, &options);
// Set data rate
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
// Set 8 data bits, no parity, 1 stop bit
options.c_cflag &= ~PARENB; // No parity
options.c_cflag &= ~CSTOPB; // 1 stop bit
options.c_cflag &= ~CSIZE; // Reset data size
options.c_cflag |= CS8; // 8 bits of data
// Set non-canonical input mode and disable flow control
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_iflag &= ~(IXON | IXOFF | IXANY);
// Apply settings
tcsetattr(fd, TCSANOW, &options);
}
< /code>
void sendData(int fd, const char* message)
{
ssize_t bytesWritten = write(fd, message, strlen(message));
if (bytesWritten < 0)
{
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79549430/error-11-reading-from-com-port-resource-temporarily-unavailable-c-linux[/url]
Мобильная версия