📄 setuart.c
字号:
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdlib.h>int main(int argc, char** argv){ int type, dip_sw, i; int fd = open("/dev/ttyS1",O_RDWR); if(argc < 2){ /* display current UART type */ if(ioctl(fd, 0xe001, &type) == 0){ printf("Port1 Type:%d\n",type); ioctl(fd, 0xe003, &type); printf("Port1 Mode9:%d\n", type); } else printf("Port1 Type:Unknown!\n"); close(fd); return 0; } else if(argc >= 2){ type = atoi(argv[1]); if(ioctl(fd, 0xe002, &type) == 0) printf("Set UART Type to %d.\n", type); if(argc > 2){ type = atoi(argv[2]); if(type == 1) ioctl(fd, 0xe004, &type); else { type = 0; ioctl(fd, 0xe004, &type); } printf("Set UART MODE9 to %d.\n", type); } close(fd); return 1; } printf("Usage: setuart type mode9, type:232,422 or 485 mode9:1 or 0\n"); close(fd); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -