Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 28 Jul 2014, 10:52
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Read SMS on SIM CARD
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Thu 07 Jun 2012, 15:18    Post subject:  Read SMS on SIM CARD
Subject description: script to get content of SIM Card
 

I am working on a script to fetch all possible stored data from the SIM card of my broadband usb modem .

It goes something like this :

1) create a database file with the current supported AT commands by sending ' " AT+CLAC" |tr ',' '\n' |sort -d >database.file ' .

2) read the databasefile line for line and send
"AT${line}?" to show the current setting
and
"AT${line}=?" to show the supported settings .

Sending the AT commands i came up using the /usr/sbin/modem-stats binary , which is the best tool i have found so far .

Now i have the problem to locate the source for "modem-stats" .

I can not find it on google, debian, ubuntu, bkhome.org/sources or inside woof tarball .

Could anyone point me there ?
Back to top
View user's profile Send private message Visit poster's website 
PANZERKOPF

Joined: 16 Dec 2009
Posts: 280
Location: Earth

PostPosted: Thu 07 Jun 2012, 15:34    Post subject: Re: Read SMS on SIM CARD
Subject description: script to get content of SIM Card
 

Karl Godt wrote:

Could anyone point me there ?

I hope that is what you want.
modem-stats-1.0.1.src.elf.tar.gz
Description 
gz

 Download 
Filename  modem-stats-1.0.1.src.elf.tar.gz 
Filesize  49.47 KB 
Downloaded  186 Time(s) 

_________________
SUUM CUIQUE.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Thu 07 Jun 2012, 16:40    Post subject:  

WOW ! From 1995 !! Not found even on archive.debian.net ..

At least the second time you've helped me out Panzerkopf !

Now i've something to chew on !

The problem is i have overstepped my 5GB limit and my second provider had apparently cut me off while dl win8 preview 64bit .iso . They apparently wanted me to confirm to order some GB more at UMTS speed while looking for /usr/bin/defaultbrowser, which was of course not available ..

My first provider squeezed the speed to 8KB/s without problems, which my second provider also did in former days (did not happen many times) .

So i got me a 2,5GB win.iso.part and a 750MB win.iso and want to wget -c it .

Somehow i was not able to connect anymore with Puppy to internet and also not able in windows .

Now the month from 6th to 5th is a new month and i can connect with windows, but pgprs-connect does still not work anymore, nor pupdial .. Grrrrr ...

Installed hyperterminal from xp to vista and here not much garbage output, but also a short CONNECTED 7200000 and "NO CARRIER" ..

Posting from racy with my first provider ...

Cannot get the SMS from the card :

AT+CMGF=1

AT+CMGL='"ALL"'
[empty space here]
OK

Seems that the SMS gets directly somewhere to c:\USERS\USER\AppData\Roaming\Vodafone ...

Some people say linux has a complicated folder structure , haha ..
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Sat 09 Jun 2012, 19:32    Post subject:  

Now my provider has turned up the download speed again and i can connect with pgprs-connect . Will take me some time to figure out settings to connect in isdn mode ..

So here's my get_modem_values.sh script :
It works pretty well at my 2 years old and grown 5GB+ Puppy-4.3x full installations,
while on Puppy-5.1.1 it got me a bunch of crap as answers to modem-stats -c AT$COMMAND $DEVICE

Code:
#!/bin/bash

DEV_MODEM=/dev/ttyUSB0
CLAC_FILE=/modem-stats_AT+CLAC.sort_d.txt
VALUE_FILE=/get_modem_values.txt

Version=1.0-Puppy-4.3x

usage(){
MSG="
$0 [help|version] [force|/dev/MODEM|pin=3210]

"
if [ "$2" ];then
MSG="$MSG

$2
"
fi
echo "$MSG"
[ "$DISPLAY" ] && xmessage -bg cyan "$MSG"
exit $1
}

while [ "$1" ];do
case $1 in
help) usage 0;;
version) usage 0 "Version=$Version";;
force) rm $CLAC_FILE;shift;;
pin=*) PIN=${1##*=};modem-stats -c AT+CPIN=$PIN $DEV_MODEM;shift;;
/dev/*) DEV_MODEM=$1;shift;;
*|'') shift;;
esac;done

modem-stats ${DEV_MODEM}

if ! [ -f ${CLAC_FILE} ];then
modem-stats -c AT+CLAC ${DEV_MODEM} |tr ',' '\n' |sort -d >${CLAC_FILE}
fi

un_b_lock_function(){

PIN=3210      ##Change as needed/required to your PIN
PUK=76543210  ##Change as needed/required to your PUK

if [ "$1" = 'unlock' ];then
modem-stats -c "AT+CPIN=${PIN}" ${DEV_MODEM}
shift
fi

if [ "$1" = 'unblock' ];then
modem-stats -c AT+CPIN=${PUK},${PIN} ${DEV_MODEM}
shift
fi
}
#un_b_lock_function

[ -f ${VALUE_FILE} ] && cp --remove-destination ${VALUE_FILE} ${VALUE_FILE}.bak

date >${VALUE_FILE}
uname -a >>${VALUE_FILE}
. /etc/DISTRO_SPECS
echo "${DISTRO_NAME}*${DISTRO_VERSION}" >> ${VALUE_FILE}

modem-stats ${DEV_MODEM} >>${VALUE_FILE}

while read line;do
echo "'$line'"
[ "$line" ] || continue
line=`echo "${line}" |awk '{print $1}'`
STATUS=0
echo '#-------#' >>${VALUE_FILE}
echo "CMD=AT${line} [? & =? |'']" >>${VALUE_FILE}
echo '##CURRENT------#' >>${VALUE_FILE}
timeout -t 6 modem-stats -c "AT${line}?" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
STATUS=$((STATUS+$?))
echo '##------#' >>${VALUE_FILE}
echo '###POSSIBLE-----#' >>${VALUE_FILE}
timeout -t 6 modem-stats -c "AT${line}=?" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
STATUS=$((STATUS+$?))
echo '###-----#' >>${VALUE_FILE}

log_error_func(){
if [ "$STATUS" -ge 2 ];then
echo "'$line'" >>/at_commands_wo_output.txt
fi
}
log_error_func

display_func(){

if [ "$STATUS" -ge 2 ];then
 if [ "`echo "$line" |grep -Ew '\+GMR|\+GSN|\+CGMI|\+CGMM|\+CGMR|\+CGSN|\+CERR|&V|I|\+GCAP|\+GMI|\+GMM'`" ];then
 echo '####INFO --#'  >>${VALUE_FILE}
timeout -t 6 modem-stats -c "AT${line}" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
 echo '####INFO --#'  >>${VALUE_FILE}
 fi
fi
}
display_func

own_possibles_func(){

if [ "$STATUS" -ge 2 ];then
 if [ "`echo "$line" |grep -Ew '\^SYSINFO|\+CLAC'`" ];then
  echo '####SYS ---#'  >>${VALUE_FILE}
 timeout -t 6 modem-stats -c "AT${line}" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
  echo '####SYS ---#'  >>${VALUE_FILE}
 fi
fi
}
own_possibles_func

sms_func(){

if [ "$STATUS" -ge 2 ];then
 if [ "`echo "$line" |grep -w '\+CMGL'`" ];then
  echo '####SMS ---#'  >>${VALUE_FILE}
 timeout -t 6 modem-stats -c "AT${line}=\"ALL\"" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
  echo '####SMS ---#'  >>${VALUE_FILE}
 fi
fi
}
sms_func

dangerous_func(){  #enable it if you know what your doing
if [ "$STATUS" -ge 2 ];then ##coreutils timeout returns 124 when timeout occurs;still have to check busybox for this
echo '####SIMPLE----#' >>${VALUE_FILE}
 if [ "${line} " != '&F' ];then  #warn:loads factory profile
  if [ ! "`echo "$line" |grep -Ew '\+CSAS|\+CRES|A|D|;|H1|L0|M0|M1|M2|M3|\\G|\\G0|\\G1|&K|&K0|&K3|&K4|&K5|&K6|S'`" ];then  #TODO:make list more proof, or: grep only proofed commands
timeout -t 6 modem-stats -c "AT${line}" ${DEV_MODEM} >>${VALUE_FILE} 2>&1
  else
  echo '####OMITTED----#'
  fi
 else
 echo '####NOT SETTING FACTORY DEFAULT----#'
 fi
echo '####----#' >>${VALUE_FILE}
fi
}
#dangerous_func #enable it if you know what your doing

echo "CMD=AT${line} [? & =? |'']" >>${VALUE_FILE}
echo '#-------#' >>${VALUE_FILE}

done << EOF
$(cat ${CLAC_FILE})
EOF

mkdir -p /etc/ppp/modem_info.d
cp -ai $CLAC_FILE /etc/ppp/modem_info.d/
cp -ai $VALUE_FILE /etc/ppp/modem_info.d/

exit 0


Note 1 : Every MODEM seems to have its own registers and commands, so it is probably the best to adjust to the needs, especially the "dangerous_func" .
Note 2 : googling "AT COMMANDS" gives a large amount of hits with a lot of PDFs .
Note 3 : My modem needs to be unlocked with pin=$MYPIN to answer the at+clac command to build the database .
Back to top
View user's profile Send private message Visit poster's website 
PANZERKOPF

Joined: 16 Dec 2009
Posts: 280
Location: Earth

PostPosted: Sun 10 Jun 2012, 13:29    Post subject:  

Karl Godt wrote:

Note 1 : Every MODEM seems to have its own registers and commands, so it is probably the best to adjust to the needs, especially the "dangerous_func" .

Hi Karl !
As far as I know, every modem has Hayes compatibile commands and as option - some extended commands.
Also, some modems have own additional vendor specific commands.
This should be described in these standards: TIA/EIA-602, V.250 and GSM07.07

_________________
SUUM CUIQUE.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0721s ][ Queries: 13 (0.0061s) ][ GZIP on ]