C言語の低レベル入出力
ファイル入出力
Cygwin用UARTサンプル
#include<stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #define BUFSIZE 256 int main(int argc,char *argv[]) { int fd; char buf[BUFSIZE]; int size; fd = open("/dev/com2",O_RDWR); if(fd<0){ printf("OPEN ERR\n"); return 0; } write(fd,"TEST START",10); while(1){ memset(buf,0,BUFSIZE); size = read(fd,buf,1); write(fd,buf,strlen(buf)); // printf("%s",buf); if(buf[0]=='Q'){ close(fd); return 0; } } close(fd); return 0; }