Fehler 11 Lesen aus Com Port: Ressource vorübergehend nicht verfügbarLinux

Linux verstehen
Anonymous
 Fehler 11 Lesen aus Com Port: Ressource vorübergehend nicht verfügbar

Post by Anonymous »

Ich studiere die Interaktion mit COM -Ports in C ++ auf einer virtuellen Maschine mit Ubuntu 24.04.2. Ich sehe also, dass ich in den COM-Port schreiben kann.#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);
}

void sendData(int fd, const char* message)
{
ssize_t bytesWritten = write(fd, message, strlen(message));

if (bytesWritten < 0)
{
std::cerr

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post