FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
242 views 0 comments
by anonymous

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.

1 Answer

0 votes
by anonymous
Hello,

  

Apologies for the delayed response.

As this is quite a deep issue, we did not manage to find a solution in the short term, however, I can see that you are in contact with us via the Helpdesk platform, and the issue is being investigated there.

If you experience any issues on the Helpdesk, please contact me directly via private message.

  

Best regards,
DaumantasG