Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct identification of ttyUSB #171

Open
AlexanderZhirov opened this issue Jul 1, 2023 · 8 comments
Open

Correct identification of ttyUSB #171

AlexanderZhirov opened this issue Jul 1, 2023 · 8 comments

Comments

@AlexanderZhirov
Copy link

AlexanderZhirov commented Jul 1, 2023

I have several ttyUSB* devices that I use in Dongle. The bottom line is that after the system is rebooted, they switch places, and they connect incorrectly in Asterisk. The whole dial plan does not work correctly because of this. Is there a way to correctly identify the devices according to the dongle.conf file? Or at least by the specified IMEI or serial number to connect this or that ttyUSB* device correctly?

P.S. If possible, provide a link to the code snippet when the connection occurs. I'll try to check something in the interval before connecting, is the specified device in the dongle.conf file the one we attached in /dev/ttyUSB*?

UPD1:
I understand that reading the installed devices is here?

UPD2:
Hmm, would it be correct to make an AT request to check the IMEI, does it correspond to what is specified in the configuration file? How correct is it to use this way?

@nobody43
Copy link

nobody43 commented Jul 2, 2023

The bottom line is that after the system is rebooted, they switch places, and they connect incorrectly in Asterisk.

udev rules to make the names consistent?

@AlexanderZhirov
Copy link
Author

The bottom line is that after the system is rebooted, they switch places, and they connect incorrectly in Asterisk.

udev rules to make the names consistent?

In any case, i will have to call a third-party utility to access the ttyUSB device to pull out information about the modem from there, because this can only be found out through the AT command. Therefore, I am looking for a more correct and at the same time simple way.

@AlexanderZhirov
Copy link
Author

Guys, I have found a solution to this problem. Alas, we will have to use third-party mechanisms. I am currently writing a utility in C that will work as a daemon and, when connecting devices, will create symbolic links to devices in the form of identifiers unique to the modem (for example, IMEI). Thus, regardless of the sequence in which the devices are connected, links will be created with a static name, and thus you will not have to reconnect modems in the right order for correct identification inside Asterisk.

I will notify you about further work.

@AlexanderZhirov
Copy link
Author

That's what happened. Regardless of the order in which USB modems are connected, symbolic links with the correct device IMEI indexes will be created. Thus, there will be no need to reconnect them in the event of a PC reboot.

изображение

@AlexanderZhirov
Copy link
Author

Guys, I'm sharing my development. I checked and tested the calls at home - everything is OK. If you have any suggestions for improvement or participation, please welcome.

https://github.com/AlexanderZhirov/MPortLink

@wdoekes
Copy link
Owner

wdoekes commented Dec 21, 2023

Looks nice.

I would suggest placing the IMEI links in a subpath though, e.g.:
/dev/gsm/by-imei/342...17-0 -> ../../ttyUSB0

(gsm might be preferable to modem or dongle)

See /dev/disk/by-* for a similar example.

@AlexanderZhirov
Copy link
Author

@wdoekes

Dec 21 13:51:02 solus mportlink[17764]: main: starting the mportlink daemon
Dec 21 13:51:26 solus mportlink[17764]: mpl_symlink_ports, dst_path: the symbolic link has been successfully created [/dev/dongle/358**********26-0 -> /dev/ttyUSB0]
Dec 21 13:51:26 solus mportlink[17764]: mpl_symlink_ports, dst_path: the symbolic link has been successfully created [/dev/dongle/358**********26-1 -> /dev/ttyUSB1]
Dec 21 13:51:41 solus mportlink[17764]: mpl_unlink_ports, dst_path: link was successfully deleted [/dev/dongle/358**********26-0]
Dec 21 13:51:41 solus mportlink[17764]: mpl_unlink_ports, dst_path: link was successfully deleted [/dev/dongle/358**********26-1]
Dec 21 13:51:48 solus mportlink[17764]: signals_handler: cancelling the operation...
Dec 21 13:51:48 solus mportlink[17764]: signals_handler: cancelling the main loop...
Dec 21 13:51:48 solus mportlink[17764]: main: stopping the mportlink daemon

@AlexanderZhirov
Copy link
Author

I still have ideas for creating a cli and unbinding from the original ModemManager, because it blocks ports and Asterisk (dongle) throws errors on the busy device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants