-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
Hi,
using the TCGETS2 ioctl on serial ports yields Inappropriate ioctl for device in Windows Version 10.0.16299.15. Attaching this small demo program here:
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <asm-generic/termbits.h>
#include <sys/ioctl.h>
int main(int argc, char *argv[])
{
struct termios2 old;
int fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);
int rc = ioctl(fd, TCGETS2, &old);
if (rc<0) {
perror("fail");
return rc;
}
close(fd);
printf("fine\n");
return 0;
}Which, when compiling with g++ main.cpp and running with sudo strace ./a.out /dev/ttyS7, produces the following output:
execve("./a.out", ["./a.out", "/dev/ttyS7"], [/* 15 vars */]) = 0
brk(0) = 0xc2d000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffd6e80000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=62066, ...}) = 0
mmap(NULL, 62066, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fffd6e70000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P \2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1857312, ...}) = 0
mmap(NULL, 3965632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fffd6830000
mprotect(0x7fffd69ee000, 2097152, PROT_NONE) = 0
mmap(0x7fffd6bee000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1be000) = 0x7fffd6bee000
mmap(0x7fffd6bf4000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fffd6bf4000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffd6e60000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffd6e50000
arch_prctl(ARCH_SET_FS, 0x7fffd6e50740) = 0
mprotect(0x7fffd6bee000, 16384, PROT_READ) = 0
mprotect(0x600000, 4096, PROT_READ) = 0
mprotect(0x7fffd6e22000, 4096, PROT_READ) = 0
munmap(0x7fffd6e70000, 62066) = 0
open("/dev/ttyS7", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3
ioctl(3, TCGETS2, 0x7fffdd40e0c0) = -1 ENOTTY (Inappropriate ioctl for device)
dup(2) = 4
fcntl(4, F_GETFL) = 0x1 (flags O_WRONLY)
close(4) = 0
write(2, "fail: Inappropriate ioctl for de"..., 37fail: Inappropriate ioctl for device
) = 37
exit_group(-1) = ?
+++ exited with 255 +++
Any plans on supporting this ioctl in later builds?
Greetings
kebien6020, raldone01, GregTheDev, artizirk, tomlogic and 2 more