hi mein problem: 0x00er-bytes werden bei der datenübertragung mittels UART weggelassen. vielleicht auch logisch, weil es ändert sich ja im udr nichts durch das reinschreiben einer null. muss man dem UART noch eine extra aufforderung geben dass er solche bytes sendet oder liegts an was anderem?
Vielleicht liegt es an deiner Einstellung im Terminal Programm das nur sichtbare ASCII Zeichen darstellt? Nein, es liegt sogar sicher daran! Dieses Problem hatte ich am Anfang auch. Ich schick dir hier ein Stück Code für Linux, mit dem es sicher geht: /* * This function opens the serial port for communicating with * NOBAQ RCS board. * Settings are: * Baudrate 9600 * 8 databits, no parity, one stop bit, flow control off * * Returns 0 is succeeded, else a negative integer * Parameter is a string to serial device (/dev/ttyS1) */ int open_serial(unsigned char *com) { // opens the serial port for reading/writing, no terminal // and nodelay if((portfd = open(com, O_RDWR | O_NOCTTY | O_NDELAY)) < 0) { return -1; } // check if file is a valid TTY (terminal line) if(! isatty(portfd)) { return -1; } // Write actual (old) settings from the serial port // to struct termios oldterm. if(tcgetattr(portfd, &oldterm) < 0) { return -1; } if((oldflags = fcntl(portfd, F_GETFL)) < 0) { return -1; } // save old terminal settings portterm = oldterm; portflags = oldflags; portterm.c_cflag &= ~PARENB; // remove old parity control portterm.c_cflag &= ~PARODD; // gerade parity portterm.c_cflag &= ~CSTOPB; // stop bit portterm.c_cflag &= ~CSIZE; // size setting // we need eight databits... portterm.c_cflag |= CS8; // eight databits (character size) portterm.c_cflag |= 0; // parity portterm.c_cflag |= CREAD | CLOCAL; // enable receiver, ignore modem // control chars. // Don't change ownership portterm.c_cflag &= ~CRTSCTS; // don't do hardware flow control // set delays and timeouts: we need data immedeately portterm.c_cc[VMIN] = 1; portterm.c_cc[VTIME] = 1; // set input and output baudrate cfsetispeed(&portterm, BAUDRATE); // input baudrate: 9600 cfsetospeed(&portterm, BAUDRATE); // output baudrate: 9600 // ignore breaks, make raw terminal portterm.c_lflag = 0; portterm.c_iflag = 0; portterm.c_iflag |= IGNBRK; portterm.c_oflag &= ~OPOST; // flush port, clean up the serial line tcflush(portfd, TCIOFLUSH); // apply new settings to port if(tcsetattr(portfd, TCSANOW, &portterm) < 0) { return -1; } // set non blocking if(fcntl(portfd, F_SETFL, (portflags |= O_NONBLOCK)) < 0) { return -1; } Den Filedescriptor für dein serielles Terminal findest du dann in "portfd". mfg Niki
uups, ich habe return 0; // return success } das oben noch vergessen dem Code beizufügen....
Danke, prob gelöst. terminal hat bloß die 0x00 ignoriert. Danke auch an http://www.avrfreaks.net (das dortige posting stammt von mir).
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.