Hello,
When I use ioctl() function to read modem signal line status of device "/dev/rs232" (which is an alias of /dev/ttyUSB1), the function returns error #22 "Invalid argument". I have created a minimum reproducible example program which I have attached.
When compiling on Ubuntu 20.04.06 (running on WSL2) and running this application on the TRB245 it produces the following output:
root@Teltonika-TRB245:~# ttmodem /dev/rs232
Opening device '/dev/rs232' ...
Opened device '/dev/rs232'. File descriptor = 3
Getting status of modem bits using request value = TIOCMGET = 0x741D.
ERROR: Failed to get status of modem bits. ioctl() returned -1. Error was (22) Invalid argument
Closing device '/dev/rs232'...
Closed
I get the same error when attempting to use devices "/dev/rs485", "/dev/ttyUSB0" & "/dev/ttyUSB1"
However, I do not get an error when using /dev/ttyUSB2,3,4 & 5. e.g.
root@Teltonika-TRB245:~# ttmodem /dev/ttyUSB2
Opening device '/dev/ttyUSB2' ...
Opened device '/dev/ttyUSB2'. File descriptor = 3
Getting status of modem bits using request value = TIOCMGET = 0x741D.
Modem status bits = 0x06
Closing device '/dev/ttyUSB2'...
Closed
When compiling on Ubuntu 20.04.06 (running on WSL2) and running this application on Ubuntu 20.04.06 (running on WSL2) it produces the following output. Note that I have aliased /dev/ttyUSB1 to /dev/rs232 in this environment.
engdev1@TTENG01:~/ttmodem$ sudo ./ttmodem /dev/rs232
Opening device '/dev/rs232' ...
Opened device '/dev/rs232'. File descriptor = 3
Getting status of modem bits using request value = TIOCMGET = 0x5415.
Modem status bits = 0x06
Closing device '/dev/rs232'...
Closed
Note that I can succesfully set modem signal line values using ioctl() with request "TIOCMSET" but I have not shown this in the ttmodem.c example provided. It is just the reading/getting of the values that is not working.
I have made sure that all services and serial utilities that are likely to use this port have been disabled.
On the face of it, it appears like the the usb serial driver the TRB245 is running does not support the TIOCMGET command but for /dev/ttyUSB0 (rs485) and /dev/ttyUSB1 (rs232) but this seems to be quite a limitation if true.
I am using SDK "TRB2_R_GPL_00.07.04.tar.gz".
Any help would be greatly appreciated.
Thanks,
Mark.