ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Среда
18 марта
1576637 Топик полностью
IBAH (Сегодня, 15:09, просмотров: 314)
ХЕЛП! спасите от долбаного линукса!!!!! При приеме бинарных данных по сом порту (ttyUSB0) система меняет байт 0x0D на 0х0А!!!! Символ возврата каретки на символ перевода строки!!!!! 

Открываю порт так

//

int OpenComPort(ComPort_t* s)

{

s->fd = open(s->Port, O_RDWR | O_NOCTTY);

if(s->fd<0) { return s->fd; }

struct termios SerialPortSettings; /* Create the structure */

tcgetattr(s->fd, &SerialPortSettings); /* Get the current attributes of the Serial port */

/* Setting the Baud rate */

int TmpSpeed=0;

switch(s->Speed)

{

case 2400: TmpSpeed=B2400; break;

case 4800: TmpSpeed=B4800; break;

case 9600: TmpSpeed=B9600; break;

case 19200: TmpSpeed=B19200; break;

case 38400: TmpSpeed=B38400; break;

case 57600: TmpSpeed=B57600; break;

case 115200: TmpSpeed=B115200; break;

default: close(s->fd); return -1;

}

cfsetispeed(&SerialPortSettings,TmpSpeed); /* Set Read Speed */

cfsetospeed(&SerialPortSettings,TmpSpeed); /* Set Write Speed */

/* 8N1 Mode */

SerialPortSettings.c_cflag &= ~PARENB; /* Disables the Parity Enable bit(PARENB),So No Parity */

SerialPortSettings.c_cflag &= ~CSTOPB; /* CSTOPB = 2 Stop bits,here it is cleared so 1 Stop bit */

SerialPortSettings.c_cflag &= ~CSIZE; /* Clears the mask for setting the data size */

SerialPortSettings.c_cflag |= CS8; /* Set the data bits = 8 */

SerialPortSettings.c_cflag &= ~CRTSCTS; /* No Hardware flow Control */

SerialPortSettings.c_cflag |= CREAD | CLOCAL; /* Enable receiver,Ignore Modem Control lines */

SerialPortSettings.c_iflag &= ~(IXON | IXOFF | IXANY); /* Disable XON/XOFF flow control both i/p and o/p */

SerialPortSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* Non Cannonical mode */

SerialPortSettings.c_oflag &= ~OPOST;/*No Output Processing*/

/* Setting Time outs */

SerialPortSettings.c_cc[VMIN] = 1; /* Read at least 10 characters */

SerialPortSettings.c_cc[VTIME] = 1; /* Wait indefinetly */

if((tcsetattr(s->fd,TCSANOW,&SerialPortSettings)) != 0) /* Set the attributes to the termios structure*/

{

return -1;

}

return 0;

}


//

Читаю так

unsigned short InkeyComPort(ComPort_t* s)

{

int bytes;

if( ioctl(s->fd, FIONREAD, &bytes) != 0 ) { return 0; }

if(bytes > 0)

{

unsigned char read_buffer; // Buffer to store the data received

read(s->fd, &read_buffer, 1); // Read the data

return 0x0100|(read_buffer);

}

return 0;

}


//



Что делаю не так?!