-
-
Save matteyeux/4859ed5a29994bb335f4274cb457cd56 to your computer and use it in GitHub Desktop.
Setting up /dev/uart.debug-console output for DCSD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/file.h> | |
#include <assert.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <termios.h> | |
#include <unistd.h> | |
#include <sys/event.h> | |
int main(){ | |
struct termios tty; | |
int serial_fd = open ("/dev/tty.debug-console", O_RDWR | O_NOCTTY | O_SYNC); | |
memset (&tty, 0, sizeof tty); | |
if (tcgetattr (serial_fd, &tty) != 0) | |
return -1; | |
// set speed | |
cfsetospeed (&tty, B115200); | |
// set control options | |
tty.c_cflag &= ~CRTSCTS; // disable hardware flow control | |
tty.c_cflag |= CLOCAL; // local line - do not change "owner" of port | |
tty.c_cflag &= ~CSIZE; // clean data bits | |
tty.c_cflag |= CS8; // set 8 data bits | |
tty.c_cflag &= ~PARENB; // clean parity bit | |
tty.c_cflag &= ~CSTOPB; // set 1 stop bits by cleaning CSTOPB | |
// set output options | |
tty.c_oflag &= ~OPOST; // set raw output | |
if (tcsetattr (serial_fd, TCSANOW, &tty) != 0) | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment