Created
July 24, 2018 11:47
-
-
Save allsey87/5a3554d4c08f47b344c1c1e721cd80d4 to your computer and use it in GitHub Desktop.
Print the configuration of a serial port from the Linux kernel in stty -g style
This file contains 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
static void dump_ktermios(struct device* dev, struct ktermios* ktermios, const char* func) { | |
char buf[128]; | |
unsigned int idx = 0; | |
size_t i = 0; | |
idx += snprintf(buf + idx, 128 - idx, "%lx:%lx:%lx:%lx", | |
(unsigned long int) ktermios->c_iflag, | |
(unsigned long int) ktermios->c_oflag, | |
(unsigned long int) ktermios->c_cflag, | |
(unsigned long int) ktermios->c_lflag); | |
for(i = 0; i < NCCS; ++i) | |
idx += snprintf(buf + idx, 128 - idx, ":%lx", (unsigned long int) ktermios->c_cc[i]); | |
dev_info(dev, "%s: %s", func, buf); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment