This patch adds a new option "-k" to modem_run.  When used with this
option, modem_run will signal the kernel mode driver (if loaded) when
the modem's line state changes.  This eliminates the need for Alcatel's
closed source speedmgmt program.  Please apply so we can all be free!

Thanks,

Duncan.


diff -u -r user_mode.orig/src/modem_run.c user_mode/src/modem_run.c
--- user_mode.orig/src/modem_run.c      2003-01-31 09:28:20.000000000 +0100
+++ user_mode/src/modem_run.c   2003-01-31 10:14:36.000000000 +0100
@@ -92,6 +92,7 @@
 static int dl_512_first = 1; /* Try to download 512 bytes before first op */
 static int link_up = 0;      /* Used to gives link state between 2 processes */
 static int sb = 0;           /* Software buffering */
+static int signal_kernel = 0;/* Kernel driver notification */
 
 static unsigned char data1[] = {
 
@@ -297,6 +298,8 @@
                        verbose = atoi(argv[++i]);
                else if (strcmp(argv[i],"-b")==0)
                        sb = 1;
+               else if (strcmp(argv[i],"-k")==0)
+                       signal_kernel = 1;
                else if (strcmp(argv[i],"-m")==0)
                        monitoring = 1;
                else if (strcmp(argv[i],"-s")==0)
@@ -399,15 +402,28 @@
                return(-1);
        }
        
-       /*
-        * We use alternate 1 so both "classic" and new SpeedTouch USB 330
-        * can be initialised.
-        *
-        * NB: Historically we used alternate 2 (before 2002-12-13)
-        */
-       if (pusb_set_interface(fdusb, 1, 1) < 0) {
-               report(0, REPORT_ERROR, "pusb_set_interface");
-               return(-1);
+       if (pusb_claim_interface(fdusb,1) < 0) {
+               if (!signal_kernel) {
+                       report(0, REPORT_ERROR, "Another program/driver is already 
+accessing the modem (interface 1 cannot be claimed)...\n");
+                       return(-1);
+               }
+               report(1, REPORT_INFO, "Found kernel mode driver\n");
+       } else { /* claimed interface 1 */
+               if (signal_kernel) {
+                       report(0, REPORT_ERROR, "Kernel mode driver not found\n"); 
+                       signal_kernel = 0;
+               }
+
+               /*
+                * We use alternate 1 so both "classic" and new SpeedTouch USB 330
+                * can be initialised.
+                *
+                * NB: Historically we used alternate 2 (before 2002-12-13)
+                */
+               if (pusb_set_interface(fdusb, 1, 1) < 0) {
+                       report(0, REPORT_ERROR, "pusb_set_interface");
+                       return(-1);
+               }
        }
 
        /* Enable software buffering - Courtesy of Thomson Multimedia */
@@ -450,6 +466,9 @@
        if (pusb_release_interface(fdusb,0) < 0)
                report(0, REPORT_ERROR, "pusb_release_interface 0 failed");
 
+       if (!signal_kernel && pusb_release_interface(fdusb,1) < 0)
+               report(0, REPORT_ERROR, "pusb_release_interface 1 failed");
+
        if (pusb_release_interface(fdusb,2) < 0)
                report(0, REPORT_ERROR, "pusb_release_interface 2 failed");
        
@@ -480,6 +499,7 @@
        fprintf(stderr, "  -s           : skip the first 512 bytes read\n");
        fprintf(stderr, "  -f microcode : upload this microcode file first\n");
        fprintf(stderr, "  -d device    : defines the device to use\n");
+       fprintf(stderr, "  -k           : using the kernel mode driver\n");
        fprintf(stderr, "  --help       : this message\n");
        exit(-1);
 
@@ -931,12 +951,22 @@
 
                                /* The magic interrupt for "up state" */
                                char up_int[6] = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00};
+                               /* The magic interrupt for "down state" */
+                               char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 
+0x00};
+
+                               if(!memcmp(up_int, lbuf, 6)) {
+                                       /* We only signal the parent process the first 
+time */
+                                       if (!up) {
+                                               report(1, REPORT_INFO, "Sending a 
+signal to notify the adsl up state\n");
+                                               kill(parent, SIGUSR2);
+                                               up = 1;
+                                       }
+                                       if (signal_kernel)
+                                               pusb_ioctl(fdusb, 1, 1, NULL);
+                               }
 
-                               /* We send a signal only the first time */
-                               if(!memcmp(up_int, lbuf, 6) && !up) {
-                                       report(1, REPORT_INFO, "Sending a signal to 
notify the adsl up state\n");
-                                       kill(parent, SIGUSR2);
-                                       up = 1;
+                               if(!memcmp(down_int, lbuf, 6) && signal_kernel) {
+                                       pusb_ioctl(fdusb, 1, 2, NULL);
                                }
        
                        }
diff -u -r user_mode.orig/src/pusb-bsd.c user_mode/src/pusb-bsd.c
--- user_mode.orig/src/pusb-bsd.c       2002-11-18 05:52:16.000000000 +0100
+++ user_mode/src/pusb-bsd.c    2003-01-31 09:13:57.000000000 +0100
@@ -421,3 +421,9 @@
 {
        return 0;
 }
+
+/* Function not existing in this USB stack */
+int pusb_ioctl (pusb_device_t dev,int interface,int code,void *data)
+{
+       return -ENOTTY;
+}
diff -u -r user_mode.orig/src/pusb-linux.c user_mode/src/pusb-linux.c
--- user_mode.orig/src/pusb-linux.c     2002-07-02 14:58:12.000000000 +0200
+++ user_mode/src/pusb-linux.c  2003-01-20 20:47:24.000000000 +0100
@@ -392,6 +392,17 @@
        return(ioctl(dev->fd,USBDEVFS_RELEASEINTERFACE,&interface));
 
 }
+ 
+int pusb_ioctl (pusb_device_t dev,int interface,int code,void *data)
+{
+       struct usbdevfs_ioctl ctrl;
+
+       ctrl.ifno = interface;
+       ctrl.ioctl_code = code;
+       ctrl.data = data;
+
+       return(ioctl(dev->fd,USBDEVFS_IOCTL,&ctrl));
+}
 
 /*****************************************************************************
 *      Local functions
diff -u -r user_mode.orig/src/pusb.h user_mode/src/pusb.h
--- user_mode.orig/src/pusb.h   2003-01-31 09:19:24.000000000 +0100
+++ user_mode/src/pusb.h        2003-01-31 09:17:45.000000000 +0100
@@ -44,6 +44,8 @@
 int pusb_claim_interface(pusb_device_t dev,int interface);
 int pusb_release_interface(pusb_device_t dev,int interface);
 
+int pusb_ioctl (pusb_device_t dev,int interface,int code,void *data);
+
 pusb_endpoint_t pusb_endpoint_open(pusb_device_t dev, int epnum, int flags);
 int pusb_endpoint_read(pusb_endpoint_t ep, 
                       unsigned char *buf, int size, int timeout);


Liste de diffusion modem ALCATEL SpeedTouch USB
Pour se désinscrire : mailto:[EMAIL PROTECTED]?subject=unsubscribe

        

Reply via email to