4
Linux를 사용하는 직렬 인터페이스에서 일부 데이터를 읽습니다. 때때로 데이터 스트림 내에 0x0D가 있습니다. 수신 측에서는이 값이 0x0A로 대체됩니다. 이것은 원하는 동작처럼 보이는 - 불행하게도 내 경우에 요구되지 않고, 나는 그것이 포트를 여는시 설정 한 옵션 중 하나를 함께 할 수 있다고 생각 :직렬 통신 : 0x0D는 0x0A로 대체됩니다.
struct termios options;
struct serial_struct sStruct;
*fd= open(serialParams->port, O_RDWR|O_NOCTTY);// | O_NDELAY);
if (*fd == -1) return OAPC_ERROR_DEVICE;
fcntl(*fd, F_SETFL,FNDELAY);
tcgetattr(*fd, &options);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~CSIZE; // Mask the character size bits
options.c_cflag |= CS8;
options.c_cflag &= ~(PARENB|PARODD);
options.c_iflag &= ~(INPCK | ISTRIP);
options.c_iflag |=IGNPAR;
options.c_cflag&=~CSTOPB;
options.c_iflag |= (IXON | IXOFF | IXANY);
options.c_cflag &= ~CRTSCTS;
options.c_lflag &= ~(ICANON | ECHO | ECHOE |ECHOK|ISIG|IEXTEN|ECHONL);
options.c_iflag&=~(IGNCR|IUTF8);
options.c_oflag&=~(ONLCR|OCRNL);
ioctl(*fd, TIOCGSERIAL, &sStruct);
sStruct.flags &= ~ASYNC_SPD_MASK;
ioctl(*fd, TIOCSSERIAL, &sStruct);
int speed;
speed=1000000;
ioctl(*fd, TIOCGSERIAL, &sStruct);
sStruct.flags = (sStruct.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST;
sStruct.custom_divisor = (sStruct.baud_base + (speed/2))/speed;
ioctl(*fd, TIOCSSERIAL, &sStruct);
cfsetispeed(&options, B38400);
cfsetospeed(&options, B38400);
if (tcsetattr(*fd, TCSANOW, &options)!=0) return OAPC_ERROR_DEVICE;
이 데이터 변환의 원인이 옵션 중 어떤 생각 리셉션 중?
텍스트 필터를 찾으십시오. 개행/cr 번역. – Yakk
_sender_가 0xD에서 0xA로 바꾸는 것이 가능합니까? – chux