Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
initscript e udev rules VS modem 3G usb
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sat Oct 31, 2009 12:45 pm    Post subject: initscript e udev rules VS modem 3G usb Reply with quote

Ho un modem 3G usb che funge egregiamente sulla mia gentoo/box.
Quello che voglio ottenere è gestire l'avvio e lo stop della connessione attraverso le regole di udev.
Ho configurato felicemente /etc/conf.d/net per gestire l'interfaccia ppp0 attraverso l'initscript /etc/init.d/net.ppp0.
Ho creato le seguenti regole:
Code:
#> cat /etc/udev/rules.d/91-usb_modeswitch.rules                                                             
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="f000", RUN+="/usr/local/bin/modem.sh"
ACTION=="remove", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9000", RUN+="/etc/init.d/net.ppp0 stop"

e questo è lo script che viene eseguito quando collego la periferica:
Code:
#> cat /usr/local/bin/modem.sh
#!/bin/bash
sleep 2
/usr/sbin/usb_modeswitch
sleep 2
/sbin/modprobe usbserial vendor=0x1c9e product=0x9000
sleep 5
/etc/init.d/net.ppp0 restart

ma ahimè c'è qualcosa che non sembra funzionare a puntino, infatti la connessione non viene avviata. Questo di seguito è il risultato di dmesg quando collego la perifierca:
Code:
Oct 31 13:37:54 jarod usb 1-2: new high speed USB device using ehci_hcd and address 23
Oct 31 13:37:55 jarod usb 1-2: configuration #1 chosen from 1 choice
Oct 31 13:37:55 jarod scsi26 : SCSI emulation for USB Mass Storage devices
Oct 31 13:37:55 jarod usb-storage: device found at 23
Oct 31 13:37:55 jarod usb-storage: waiting for device to settle before scanning
Oct 31 13:37:58 jarod usb 1-2: USB disconnect, address 23
Oct 31 13:37:58 jarod usb 1-2: new high speed USB device using ehci_hcd and address 24
Oct 31 13:37:58 jarod usb 1-2: configuration #1 chosen from 1 choice
Oct 31 13:37:58 jarod usbserial_generic 1-2:1.0: generic converter detected
Oct 31 13:37:58 jarod usb 1-2: generic converter now attached to ttyUSB0   
Oct 31 13:37:58 jarod usbserial_generic 1-2:1.1: generic converter detected
Oct 31 13:37:58 jarod usb 1-2: generic converter now attached to ttyUSB1   
Oct 31 13:37:58 jarod scsi27 : SCSI emulation for USB Mass Storage devices
Oct 31 13:37:58 jarod usb-storage: device found at 24
Oct 31 13:37:58 jarod usb-storage: waiting for device to settle before scanning
Oct 31 13:37:58 jarod usbserial_generic 1-2:1.3: generic converter detected
Oct 31 13:37:58 jarod usb 1-2: generic converter now attached to ttyUSB2   
Oct 31 13:38:03 jarod usb-storage: device scan complete
Oct 31 13:38:03 jarod scsi 27:0:0:0: Direct-Access     USBModem Disk             2.31 PQ: 0 ANSI: 2
Oct 31 13:38:03 jarod sd 27:0:0:0: [sdb] Attached SCSI removable disk
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15131]: /dev/ttyUSB2 does not exist
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15132]: Please verify hardware or kernel module (driver)
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15082]: ERROR: net.ppp0 failed to start
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15142]: WARNING: net.ppp0 is already stopped 
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15141]: ERROR: net.ppp0 stopped by something else
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15146]: WARNING: net.ppp0 is already stopped 
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15148]: ERROR: net.ppp0 stopped by something else
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15145]: WARNING: net.ppp0 is already stopped 
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15150]: WARNING: net.ppp0 is already stopped
Oct 31 13:38:04 jarod /etc/init.d/net.ppp0[15152]: WARNING: net.ppp0 is already stopped

Non capisco, l'initscript non sembra riconoscere il device /dev/ttyUSB2, ma se successivamente avvio l'initscript a manina tutto funziona bene. Ho provato anche ad aumentare da 5 a 10 secondi l'ultimo sleep, ma il risultato è lo stesso.
Dove commeto l'errore?
_________________
LP
Back to top
View user's profile Send private message
cloc3
Advocate
Advocate


Joined: 13 Jan 2004
Posts: 4788
Location: http://www.gentoo-users.org/user/cloc3/

PostPosted: Sat Oct 31, 2009 2:13 pm    Post subject: Re: initscript e udev rules VS modem 3G usb Reply with quote

lucapost wrote:

Dove commeto l'errore?

la dopia t.

prova a sostituire lo sleep 5 con qualcosa del tipo:
Code:

while [[ ! -f /dev/ttyUSB]];do {
   /etc/init.d/net.ppp0 restart
   sleep 3
} done

poi aggiungi dei check nello script per capire meglio cosa accade.

una cosa che non capisco, del tuo log è l'ordine con cui si verifica il restart di net.ppp0.
_________________
vu vu vu
gentù
mi piaci tu
Back to top
View user's profile Send private message
zolar czakl
Apprentice
Apprentice


Joined: 25 Sep 2004
Posts: 162
Location: UMRK

PostPosted: Sat Oct 31, 2009 5:52 pm    Post subject: Re: initscript e udev rules VS modem 3G usb Reply with quote

ATTRS{idProduct}=="f000"
ATTRS{idProduct}=="9000"
:?:
Back to top
View user's profile Send private message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sat Oct 31, 2009 6:01 pm    Post subject: Re: initscript e udev rules VS modem 3G usb Reply with quote

non cambia nulla anche se ho sostituito l'ultimo sleep con
Code:
while [[ ! -f /dev/ttyUSB2]];do {
   /etc/init.d/net.ppp0 restart
   sleep 3
} done



zolar czakl wrote:
ATTRS{idProduct}=="f000"
ATTRS{idProduct}=="9000"
:?:

colpa di usb_modeswitch!
_________________
LP
Back to top
View user's profile Send private message
zolar czakl
Apprentice
Apprentice


Joined: 25 Sep 2004
Posts: 162
Location: UMRK

PostPosted: Sat Oct 31, 2009 6:46 pm    Post subject: Reply with quote

Mai usato dispositivi del genere ma ho litigato con udev :)

Se elimini /etc/init.d/net.ppp0 restart dallo script e crei una regola udev che punta /dev/ttyUSB2?

Code:
ACTION=="add", KERNEL=="ttyUSB2", RUN+="/etc/init.d/net.ppp0 restart"
o qualcosa del genere?

Last edited by zolar czakl on Sat Oct 31, 2009 10:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
cloc3
Advocate
Advocate


Joined: 13 Jan 2004
Posts: 4788
Location: http://www.gentoo-users.org/user/cloc3/

PostPosted: Sat Oct 31, 2009 7:16 pm    Post subject: Re: initscript e udev rules VS modem 3G usb Reply with quote

lucapost wrote:
non cambia nulla anche se ho sostituito l'ultimo sleep con
Code:
while [[ ! -f /dev/ttyUSB2]];do {
   /etc/init.d/net.ppp0 restart
   sleep 3
} done


in effetti lo scriptino era un po' scemo.
sarebbe stato molto meglio una cosa così:
Code:

while [[ ! -f /dev/ttyUSB2 ]];do sleep 3; done
/etc/init.d/net.ppp0 restart

lo scopo è mantenere attivo il ciclo che lancia net.ppp0 fino a quando non viene creato il dispositivo.
so bene che questo non risolve il tuo problema, ma ti offre uno strumento per indagare.
magari il dispositivo viene creto, ma con ipermessi sbaglaiti.

mi chiedo se il comando /usr/sbin/usb_modeswitch non richieda qualche impostazione d'ambiente che, all'interno di /usr/local/bin/modem.sh, per qualche ragione arcana, non è presente.
_________________
vu vu vu
gentù
mi piaci tu
Back to top
View user's profile Send private message
lucapost
Veteran
Veteran


Joined: 24 Nov 2005
Posts: 1419
Location: <ud|me|ts> - Italy

PostPosted: Sun Nov 01, 2009 12:50 pm    Post subject: Reply with quote

zolar czakl wrote:
Code:
ACTION=="add", KERNEL=="ttyUSB2", RUN+="/etc/init.d/net.ppp0 restart"
o qualcosa del genere?

grande! questo funziona! per ora questa sembra essere la strada migliore...
utilizzo diversi dispositivi che sfruttano la conversione usb/seriale, ora devo trovare i modo di associare quest'ultima regola al dispositivo giusto. cioè, mi darebbe fastidio che partisse net.ppp0 quando ttyUSB2 non è l'interfaccia del modem...
_________________
LP
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum