I tried to open serial port via fopen("serial port path", "+w")
And get the file descriptor by fileno()
.
After that, i call tcsetattr()
but it generate an error showing Inappropriate ioctl for device
(perror()
print the error message)
I Know i can just use open()
but fopen()
and it was working with same code.
But i am curious what is a problem.
FILE* file = fopen("serialDevice", "w+");
fd = fileno(file);
if(fd < 0){
perror("fileno error");
}
struct termios conf;
//setting conf.....
if(tcsetattr(fd, TCSANOW, &conf) != 0){
perror("tcsetattr() failed");
exit(1);
}