Hello modeswitch forum! This is my first question
I've been using a python script to listen udev events, when a ttyUSB* device is attached I try to send AT commands to every port, trying to gess which port should I use to communicate with AT commands. But it is not reliable as sometimes the modem responds to AT on two ports, but only one is fully funciontal (fo send SMS), and sometimes I fail to determine the appropiate port
Recently I noticed a /dev/gsmmodem* link is generated for the appropiate port by usb_modeswitch. Is there a way to trigger some command when this link is generated? and another one if the the device is detached? (i noticed the symbolic link is also removed)
Re: How to launch a program after gsmmodem link is generated
What you are referring to is triggered by an udev 'rule'.
Have a look at the file "/lib/udev/rules.d/40-usb_modeswitch.rules". The rule line in question is close to the top.
The symlink procedure is called once for every ttyUSB port created when a new modem is plugged in, but only in one case the return value is not empty. In that case the udev daemon creates the symlink, watches over the port, and removes the symlink if the port (along with the USB device) is gone.
You might try to edit the usb_modeswitch wrapper script to trigger any action if the likely modem port is found.
You could add your own udev rule that checks for the removal of the modem. It's not as hard as it may look and there is plenty of information around.
Have a look at the file "/lib/udev/rules.d/40-usb_modeswitch.rules". The rule line in question is close to the top.
The symlink procedure is called once for every ttyUSB port created when a new modem is plugged in, but only in one case the return value is not empty. In that case the udev daemon creates the symlink, watches over the port, and removes the symlink if the port (along with the USB device) is gone.
You might try to edit the usb_modeswitch wrapper script to trigger any action if the likely modem port is found.
You could add your own udev rule that checks for the removal of the modem. It's not as hard as it may look and there is plenty of information around.