简体   繁体   中英

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. I was able to set it the IOCTL on windows using the following code:

 #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:

#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.
TIA!

There's no serial ioctl for that in linux. That ioctl is specific of the windows serial driver. XON/XOFF protocol has no counters defined, so I cannot imagine what is this being used for. (perhaps Windows is counting the number of XOFF characters received, but just a speculation)

See termios(3) manual page of linux to see the ioctls defined for rs232 terminal control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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