0

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!

Nachiketh
  • 193
  • 2
  • 18

1 Answers1

1

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.

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31
  • does that mean this is not a mandatory requirement on the terminal side for the protocol to work? I'm able to interface with the terminal equipment from a Windows machine, however from Linux I'm unable to receive a response from the machine. I'm kind of stuck in a dead end trying to figure out what I might be doing wrong... not many USB2Serial protocol analysers as well on Linux, I tried Wireshark for USB packet capture, but it does not provide the protocol specific information. TIA! – Nachiketh Jul 27 '15 at 09:02
  • @Nachiketh, i don't know the details of the protocol you'll run on it. But XON/XOFF protocol is only a software handshake to flow control, and the count of xoff (or xon) characters sent is only useful to do statistics (either case). – Luis Colorado Jul 31 '15 at 09:03
  • Yup you are absolutely right, these control flags are not mandatory in the protocol and that pretty much worked for me without setting these control codes. I was able to finally interface with the machine using termios settings and IOCTLs for RTS and DTR. thanks! – Nachiketh Aug 07 '15 at 10:41