简体   繁体   English

USB2Serial的Linux IOCTL

[英]Linux IOCTLs for USB2Serial

I'm developing a program in C++ on Linux which interacts with a USB2Serial adapter to fetch some information from the remote terminal. 我正在Linux上用C ++开发一个程序,该程序可与USB2Serial适配器交互以从远程终端获取一些信息。 I was able to set it the IOCTL on windows using the following code: 我可以使用以下代码在Windows上将其设置为IOCTL:

 #define IOCTL_SERIAL_XOFF_COUNTER       CTL_CODE(FILE_DEVICE_SERIAL_PORT,28,METHOD_BUFFERED,FILE_ANY_ACCESS)

unsigned char xoff_counter[] = {0xd0,0x07,0x00,0x00,0x05,0x00,0x00,0x00,0x13,0x00,0x00,0x00};

        bool result = DeviceIoControl(file,IOCTL_SERIAL_XOFF_COUNTER,
                                        &xoff_counter, sizeof(xoff_counter),
                                        NULL,0,
                                        &junk,
                                        &o);

I tried doing the same on Linux using the following code: 我尝试使用以下代码在Linux上执行相同的操作:

#define SERIAL_XOFF_COUNTER 28

unsigned char xoff_counter[] = {0xd0,0x07,0x00,0x00,0x05,0x00,0x00,0x00,0x13,0x00,0x00,0x00};

int retVal = ioctl(fd,SERIAL_XOFF_COUNTER,xoff_counter);
            if(retVal < 0){
                cout << "Error while setting ioctl:"<<strerror(errno)<<endl;
            }

This is raising an error when I run the program: 当我运行程序时,这会引发错误:

Error while setting ioctl:Inappropriate ioctl for device

If anyone has worked in these ioctls before, please let me know what the Linux equivalents are for this flag. 如果以前有人在这些ioctl中工作过,请让我知道此标志的Linux等效版本。
TIA! TIA!

There's no serial ioctl for that in linux. 在Linux中没有用于此的串行ioctl。 That ioctl is specific of the windows serial driver. 该ioctl特定于Windows串行驱动程序。 XON/XOFF protocol has no counters defined, so I cannot imagine what is this being used for. XON / XOFF协议没有定义计数器,因此我无法想象这是用来做什么的。 (perhaps Windows is counting the number of XOFF characters received, but just a speculation) (也许Windows正在计算接收到的XOFF字符的数量,但这只是一种推测)

See termios(3) manual page of linux to see the ioctls defined for rs232 terminal control. 请参阅linux的termios(3)手册页,以查看为rs232终端控制定义的ioctl。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM