0
シリアルのパラメータの設定には少し問題があります。プログラムでは、+ +私は構成: - ボーレート - > 38400 - データビット - > 8 - パリティ - なしなし - ストップビット - > 1 - ハンドシェーク - >なし。 しかし、シリアルから読み取るためのバッファーが汚れています、それはより多くのメッセージを含んでいます。 1つのバッファに1つのメッセージが必要です。手伝って頂けますか?私は答えを待つ。 は、これはコードです:C++でのシリアルポートの読み取りの設定
speed=B38400;
cfsetospeed (&tty, speed);
cfsetispeed (&tty, speed);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break
// as \000 chars
tty.c_iflag &= ~IGNBRK; // disable break processing
tty.c_lflag = 0; // no signaling chars, no echo,
// no canonical processing
tty.c_oflag = 0; // no remapping, no delays
tty.c_cc[VMIN] = 0; // read doesn't block
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl
tty.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
tty.c_cflag |= parity;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
を使うのか?シリアルポート用の標準C++コードはありません。それらはすべてプラットフォームに依存しています。 –