Auto dial for C-motech D-50 modem

This modem uses the 450 MHz band for wireless internet access. InScandinavia this mobile internet access network is operated by ice.net. The following rules andscripts constitute an auto-dialer: when the USB modem is inserted the system automatically connects to the network.

This is obsolete. Use the software that comes with the modem. There are versions for Debian, Red Hat and Suse.

The USB modem acts as a memory stick when first inserted into the PC. Thedevice may then be switched into a modem mode. The connection with the network server is via the PPPprotocol, so uses standard localhost pppd server.

I use the following scripts and rules to achieve this on my Kubuntulaptop.

I use one udev rule for acting when the modem is first inserted. Thisrule triggers a program that switch over from mass memory to modemmode.A second rule is triggered when the modem appears, this rule startsthe ppp dæmon via wvdial.

The rules are contained in the/etc/udev/rules.d/10-d50.rules file. Each rule must be aone-liner without any line breaks

SUBSYSTEM!="usb_device", ACTION!="add", GOTO="d50_end"

# C-motech modem

# First rule
SYSFS{idVendor}=="16d8", SYSFS{idProduct}=="6803", mode="666", \
SYMLINK="d50ms" RUN="/usr/local/sbin/d50-chdev.py"

# second rule
SYSFS{idVendor}=="16d8", SYSFS{idProduct}=="680a", mode="666", \
RUN="/usr/local/sbin/d50-call"

LABEL="d50_end"

When the modem is inserted it enumerates with the given vendor andproduct ID. The mass storage is linked to /dev/d50ms by the udevsystem, given all users read/write access and starting the programd50-chdev.py.

This program switches the device into a modem with another productID. After the new enumeration the second rule starts another programd50-call. The modem driver also creates the /dev/ttyACM0modem device.

So the first step to get a working automatic dial-up for this modem isto create the rule file as given above.

The next step is to create the two programs:

d50-chdev.py:

#!/usr/bin/python
import os
import struct
import fcntl
import time

def findusb(prod):
    return os.system("lsusb |grep -i 16d8:%s >/dev/null"%prod)
for i in range(0, 10):
    try:
       #print "try"
       fd= open("/dev/d50ms", "rw")
       break
    except IOError:
       #print "except"
       time.sleep(1)
       if i >= 9:
          #print "device /dev/d50ms did not appear"
           exit(1)

# we have the opened device, now change it into a modem

inlen= 9
outlen= 0
data= 0xff
datastr= "RDEVCHG1"
sic= struct.pack('IIB8sB', inlen, outlen, data, datastr,0)
fcntl.ioctl(fd, 1, sic)

and

d50-call:

#!/bin/sh
wvdial --config /etc/ppp/d-50config &

Now, generate the configuration file by running, as root:

echo "--> D-50 Linux Connection\n"
rm -rf /tmp/D-50config tmp/wvdialconf_log
wvdialconf /tmp/D-50config > /tmp/wvdialconf_log
echo "Carrier Check= no\nStupid Mode= yes" >> /tmp/D-50config
echo "Phone = #777\nUsername = cdma\nPassword = cdma" >> /tmp/D-50config
rm -rf /tmp/wvdialconf_log

and copy /tmp/D-50config to /etc/ppp.In my case this file contains:

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB ModemISDN = 0
Init1 = ATZModem = /dev/ttyACM0
Baud = 460800
Carrier Check= no
Stupid Mode= yes
Phone = #777
Username = cdma ; the same for all users
Password = cdma ; the same for all users

As always when editing or copying files into the /dev and /etc youmust have root permission, use sudo.

Now, if everything work you will see the /dev/d50ms and/dev/ttyACM0 files, and you should see the ppp-network whendoing a

cat /proc/net/dev

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

0 Responses to “Auto dial for C-motech D-50 modem”


  • No Comments

Leave a Reply