Das bedeutet 8 Datenbits, Keine (No) Parity, 1 Stop-Bit. Diese Einstellung ist in jedem Fall erforderlich und geht wie folgt (siehe auch mein Link, daher hier die Zeilennummern):
Code:00025 #include <errno.h> 00026 #include <fcntl.h> 00027 #include <math.h> 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include <string.h> 00031 #include <termios.h> 00032 #include <unistd.h> 00033 #include <sys/types.h> 00034 #include <sys/ioctl.h> 00035 #include <sys/stat.h> 00036 #include <sys/time.h> 00045 #include <linux/serial.h> 00050 #define READ_TIMEOUT 250000 /* less than 1e6 */ 00037 struct termios options; 00072 // Get current port settings 00073 tcgetattr(mDev_fd, &options); 00074 00075 // this setting is needed for Mac OS! But works under Linux, too! 00076 options.c_cflag |= CLOCAL; 00077 00078 // 8N1 00079 options.c_cflag &= ~PARENB; // Parity = N 00080 options.c_cflag &= ~CSTOPB; // 1 Stop Bit 00081 options.c_cflag &= ~CSIZE; // hm, wofür ist das eigentlich? 00082 options.c_cflag |= CS8; // 8 Datenbits // Da man in der Regel kein Hardware-Flow-Control hat / nutzt, ist es auch wichtig, dieses für den seriellen Port abzuschalten: 00084 // Disable hardware flow control: 00085 options.c_cflag &= ~CRTSCTS; 00167 // Cause the new options to take effect immediately. 00168 tcsetattr(mDev_fd, TCSANOW, &options);







Zitieren

Lesezeichen