Girish Desai <dcgirish16@...> writes: > > Hi, > I am facing a strange issue.. in case any one has faced this kind of issue and have any suggestions, please let me know... > > if I would like to send and array of 8 bytes such as below through UART such as ttySAC1, ttySAC2 etc, the byte containing 'zero' is not transmitted.. below is the example... > > I have an array of unsigned char alph[] = {'a', 'b', 'c', 'd', 'e', 0x00, 'g', 'h'}; > > when this is transmitted over UART, the output would be "abcdegh" only seven characters and the zero is missing... > > > in the same way, one more.. try sending unsigned char reset[] = {0x01, 0x06, 0x00, 0x01, 0x00, 0x01, 0x19, 0xCA}; > > > I would only see "01 06 01 01 19 CA" only 6 bytes.. byte containing zeros are missing again.. > > > in case any one have had this kind of issue and have suggestions, please let me know... > > > Thanks, > Girish > >
You may not be setting serial in raw mode thus some text conversion are happening. Try some settings below (note to raw): struct termios options; fd = open("/dev/ttySAC1", O_RDWR | O_NOCTTY | O_NDELAY ); if (fd == -1) { perror("open_port: Unable to open /dev/ttyS0 - "); } else { fcntl(fd, F_SETFL, 0); } tcgetattr(fd, &options); // clear all struct termios elements memset(&options, 0, sizeof(options)); cfsetispeed(&options, B38400); cfsetospeed(&options, B38400); options.c_cflag |= (CLOCAL | CREAD); options.c_cflag &= ~PARENB; //options.c_cflag &= ~PARODD options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_cflag &= ~CRTSCTS; options.c_cflag &= ~CRTSCTS; options.c_oflag &= ~OPOST; //options.c_lflag |= (ICANON | ECHO | ECHOE); // canonical input not RAW options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); //raw input options.c_iflag &= ~(ICRNL | IXON | IXOFF | IXANY | INPCK | PARMRK); // disable xon xoff & no parity check*/ options.c_iflag |= IGNPAR; options.c_iflag &= ~ISTRIP; tcsetattr(fd, TCSANOW, &options); I hope this helps, Gilson