[ltp] Linksys ethernet+modem card

Thomas Porter linux-thinkpad@www.bm-soft.com
Wed, 19 Jul 2000 16:13:13 -0400


This is a multi-part message in MIME format.
--------------3375940CEB76D87A5123B953
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Mark Alford wrote:
> 
> Has anyone been able to get the modem to work on a
> Linksys combined ethernet + modem card?
> 
> I have a Linksys EtherFast 10&100 + 56K PC Card (PCMLM56).
> The ethernet part works fine, but the modem does not.

Yes I have, but initially had problems when using modem only, as the
ethernet side got into a hard loop of some kind and hung the card.  I
eventually needed to write a program to rewrite /etc/pcmcia/config to
make the card look like it had only the modem or both ethernet and modem
depending on my situation.

FWIW  I have attached my cardstat perl script

-- 
Tom Porter                                   txporter@mindspring.com
--------------------------------------------------------------------
"On two occasions I have been asked [by members of Parliament], 
'Pray, Mr. Babbage, if you put into the machine wrong figures, will 
the right answers come out?'  I am not able rightly to apprehend the 
kind of confusion of ideas that could provoke such a question."
--------------3375940CEB76D87A5123B953
Content-Type: text/plain; charset=us-ascii;
 name="cardstat"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cardstat"

#!/usr/bin/perl -w
###
### CARDSTAT
###
### this allows the ethernet portion of the PCMLM56 card to be turned on and off
### the /etc/pcmcia/config file defaults to setting up both functions, but
### the serial line response tanks if there is not a network connected to the
### ethernet side when the card is activated.
###
### to fix this, I created three versions of /etc/pcmcia/config:
### one with both modules configured.
### one with serial only, and one with ethernet only.
### realistically the both and serial only are all that is used.
###
### I check the options, and if needed copy the needed file to the 'real' one,
### then must shut down card before sending cardmgr the -HUP to cause it to 
### reread /etc/pcmcia/config.
###
### Finally I restart the card.
###
### THIS IS SUID, be careful with it!!
###
use File::Copy;
$ENV{PATH} = "/sbin:/usr/bin";
delete $ENV{BASH_ENV};
$arg = shift;				# get new setting, if any
open (IN,'/etc/pcmcia/config');		# read current config file
while (<IN>) {				# get current setting
	if (/### this is config/) {
	($front,$setting) = split /\./;
	$front = '';
	chomp $setting;
	}
}
close IN;
if (!defined($arg)) {			# if no new setting, just report.
	print "Linksys card is set up for $setting.\n";
} elsif ($arg =~ /^(modem|both|off)$/) {
	$arg = $1;			# $arg now untainted,
					# set to modem or both
	if ($arg eq $setting) {
		print "Already set to $arg, no action taken.\n";
		exit;			# no change needed.
	}
	if ($arg eq 'off') {		# easy case, turn it off
	print "Ejecting...\n";
	system ('/sbin/cardctl eject');
	sleep 5;
	print "You can remove card now.\n";
	exit;
	}
### OK, serious work now:
### first warn user that cards will be ejected and give him chance to bail.
	print "Will reset card before changeing mode,\n";
	print "Enter 'y' to continue, anything else to quit: ";
	$resp = <>;
	chomp $resp;
	unless ($resp =~ /^(y|Y)/) {
		print "No change made, left set to $setting.\n";
		exit;
	}	
### eject card
	print "Ejecting...\n";
	system ('/sbin/cardctl eject');
	sleep 5;
	if ($arg eq 'modem') {
		copy ('/etc/pcmcia/config.ppp_only','/etc/pcmcia/config')
			|| die "copy failed.";
	}	
	if ($arg eq 'both') {
		copy ('/etc/pcmcia/config.both','/etc/pcmcia/config')
			|| die "copy failed.";
	}	
	system ('/usr/bin/killall -HUP cardmgr');
	print "switching from $setting to $arg....\n";
	print "Restarting...\n";
	system ('/sbin/cardctl insert');
	sleep 5;
	print "Done!\n";
} else {print "bad option, must be 'both', 'modem' or 'off'.\n"; exit;}

--------------3375940CEB76D87A5123B953--

----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html