Hello, could someone tell me why I am obliged to start a terminal emulation program (eg minicom) to communicate with my arduino board (using a C program and a serial connection / usb)
Fix line 28.
uart0_filestream = open("/dev/ttyACM0",O_RDWR | O_NOCTTY); if (uart0_filestream == -1) { //ERROR - CAN'T OPEN SERIAL PORT printf("Error - Unable to open UART. Ensure it is not in use by another application\n"); } struct termios options; tcgetattr(uart0_filestream, &options); cfsetispeed(&options, B9600); //<Set baud rate cfsetospeed(&options, B9600); //<Set baud rate options.c_cflag = B9600 | CS8 | CLOCAL | CREAD; //<Set baud rate options.c_iflag = IGNPAR | ICRNL; options.c_oflag = 0; tcflush(uart0_filestream, TCIFLUSH); tcsetattr(uart0_filestream, TCSANOW, &options);fcntl(uart0_filestream, F_SETFL, 0);
for ( count=0; count<5;){ rx_length = -1; char recevchar; while (rx_length < 1){ errno = 0; rx_length = read(uart0_filestream,&recevchar,1); printf("rx_length : %d\n", rx_length); printf("errno : %d\n", errno); printf("caractere : %c\n",recevchar); if (errno == EAGAIN){ //printf("%d\n", errno); rx_length = -1; sleep(1); } } rx_buffer[count] = recevchar; ++count }
i'am not understand what you mean.