📄 com0t.c
字号:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#define BUFSIZE 1000
int main(void)
{
FILE *fp;
int fd,result;
int i=0;
// char read_buf[BUFSIZE];
char write_buf[BUFSIZE]; //={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'};
// int read_count=BUFSIZE;
int write_count=BUFSIZE;
/*
Open modem device for reading and writing and not as controlling tty
because we don't want to get killed if linenoise sends CTRL-C.
*/
fd = open("/dev/uart0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0){
printf("Error in open COM0\n");
exit(-1);
}
// printf("open ok\n");
if((fp=fopen("/home/boa.conf", "r"))==NULL){
printf("cannot open file boa.conf\n");
return 0;
}
if(fread(&write_buf, BUFSIZE, 1, fp)!=1){
printf("file boa.conf read error\n");
return 0;
}
fclose(fp);
// write_buf[BUFSIZE-1]='\0';
// printf("write:\n%s\n\n", write_buf);
while(write_count!=0){
#if 0
if(read_count!=0){
result=read(fd, &read_buf[BUFSIZE-read_count], read_count);
read_count-=result;
}
#endif
#if 1
result=write(fd,&write_buf[BUFSIZE-write_count],write_count);
write_count-=result;
#endif
}
close(fd);
#if 0
printf("read:\n");
for(i=0;i<BUFSIZE;i++){
printf("%c", read_buf[i]);
}
printf("\n");
// printf("write:\n%s\n\n", write_buf);
#endif
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -