E220 problem - sms_send hangs

41 views
Skip to first unread message

KrX

unread,
Mar 4, 2010, 5:05:22 AM3/4/10
to pyhumod
Hi there

I've been looking around for a way to write a script to mass-send
smses through my Huawei E220 modem and chanced upon humod.

However, when I tried to run a simple script to send a message to my
other phone, humod just hangs

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)
>>> m.sms_send('***', 'Sherman here')

I even tried adding the country code at the start of the number, but
it still doesn't work.

Out of 20 attempts, only one worked. It returned a 3-digit integer but
I forgot what the value was.
I tried sending another message right after that and it hung.

I waited about 5 minutes for the modem to do its thing (initialize,
get its light blinking to blue, read SIM contacts) before attempting
to do those operations.

Any ideas?

Regards,
KrX

oozie

unread,
Mar 6, 2010, 8:59:23 AM3/6/10
to pyh...@googlegroups.com
Hi KrX!

On Thu, Mar 4, 2010 at 10:05 AM, KrX <krx...@gmail.com> wrote:
> Hi there
>
> I've been looking around for a way to write a script to mass-send
> smses through my Huawei E220 modem and chanced upon humod.
>
> However, when I tried to run a simple script to send a message to my
> other phone, humod just hangs
>
>>>> import humod
>>>> m = humod.Modem()
>>>> m.enable_textmode(True)
>>>> m.sms_send('***', 'Sherman here')
>
> I even tried adding the country code at the start of the number, but
> it still doesn't work.
>
> Out of 20 attempts, only one worked. It returned a 3-digit integer but
> I forgot what the value was.

The value is a sequence number of the text message just sent. Next
successful attempt will return an integer greater by one.

> I tried sending another message right after that and it hung.

I can see three possible reasons for this:
1. Your modem runs some latest incompatible firmware.
2. Your System does not communicate with the device properly.
3. Another process (another instance of PyHumod?) is attached to the
serial port and reads the data at the same time.

a) To rule out the 1st problem, use minicom to connect to the control
port (probably /dev/ttyUSB[12]) and enter the following:
--- snip ---
AT+CMGF=1
AT+CMGS=”<your number>"
> Test message!
> <CTRL+Z>
--- snip ---
[...]

b) To rule out the 2nd problem, try to use the modem with PyHumod from
another flavour of the OS or from a MacOS (I presume it's Linux).
Also, take a look at the output from

ls /dev/ttyUSB?

You should see 2 or 3 files. How many do you see and what are they called?

c) To rule out the 3rd option make sure no other processes are using
modem ports, so

lsof /dev/ttyUSB?

should return to the newline with no output.

--
best regards,
oozie
http://ooz.ie/

KrX

unread,
Mar 6, 2010, 9:50:15 AM3/6/10
to pyhumod
Oh, I'm using Mac OS X Snow Leopard.

I spent a few hours trying to troubleshoot and somehow, doing the
following works:

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> m.send_text('***', 'hi')

send_text will issue a deprecated warning AND then followed by the
integer. My phone receives the message a couple of seconds later.

Without quitting python, I tried it again.

>>> m.send_text('***', 'hi2')

It hung. No deprecated warning either.

Then I quit Terminal and unplug and plug in the modem.

So I tried it again:

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> m.send_text('***', 'new hi')
Deprecated warning, message sent.

But this time, I
>>> exit()

and then ran python and

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> m.send_text('***', 'hi')
Deprecated warning, message sent.

Hmm strange, I took a look at the source and it seems the only
difference was that send_text outputs some text and then calls
sms_send.

So I tried

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> print 'Modem details:', m.show_manufacturer, m.show_model, m.show_revision(), '\r\n'
Prints out as requested (I left my MacBook at work so I can't get the
exact details now)
>>> m.sms_send('***', 'new2 hi')
Returns the integer

Works. Hmm.
So I tried (without quitting python)

>>> print 'Modem details:', m.show_manufacturer, m.show_model, m.show_revision(), '\r\n'
Prints out as requested
>>> m.sms_send('***', 'new2 hi2')

Hangs, didn't work :(

So I unplugged and plugged in the modem again, ran

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> print 'Modem details:', m.show_manufacturer, m.show_model, m.show_revision(), '\r\n'
Prints out as requested
>>> m.sms_send('***', 'new3 hi')
Integer
>>> exit()

Works.

runs python again

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> print 'Modem details:', m.show_manufacturer, m.show_model, m.show_revision(), '\r\n'
Prints out as requested
>>> m.sms_send('***', 'new3 hi2')
Integer
>>> exit()

Works.

runs python again

>>> import humod
>>> m = humod.Modem()
>>> m.enable_textmode(True)

>>> print 'Modem details:', m.show_manufacturer, m.show_model, m.show_revision(), '\r\n'
Prints out as requested
>>> m.sms_send('***', 'new3 hi')
Integer
>>> exit()

WORKS! so yeah somehow hmm I'm not sure why.


As a side note, I did try:
>>> import humod
>>> from humod.at_commands import Command
>>> m = humod.Modem()
>>> m.enable_textmode(True) # this is basically Command(m, '+CMGF'); set('1'); right?
>>> s = Command(m, '+CMGS="***\rHi"')
>>> s.run()

It gave some error I think (did this as my first few attempts at
troubleshooting) but basically didn't work.


So my work-around was to make two separate scripts, one to handle the
sending itself which prints a whole set of stuff:
<code>
import sys
import humod
modem = humod.Modem()

(some sys.argv reading code here)

# Check for signal
rssi = modem.get_rssi()
if rssi == 99 or rssi == 0:
print 'Modem is not ready - No Signal [', rssi, ']\r\n'
exit()

# Modem Details
print '-Modem Details-'
print ' Manufacturer:\t\t', modem.show_manufacturer()
print ' Model:\t\t', modem.show_model(), modem.show_revision()
print ' IMEI:\t\t\t', modem.show_imei()
print ' Service Centre:\t', modem.get_service_center()
print ' Internal Clock:\t', modem.get_clock()
print ' Signal Strength:\t', rssi, 'out of 31 (',(float(rssi)/
31)*100,'%)\r\n'

modem.enable_textmode(True)
print 'Now attempting to send to', number, ':\r\n-Begin Message of',
len(message), 'Characters-\r\n', message, '\r\n-End Message-\r\n'
print modem.sms_send(number, message)
</code>

And another to read from a text file and send the message in the text
file to the numbers specified in the text file:
<code>
tmpcount = 0
for thisnum in numbers:
tmpcount = tmpcount + 1
print '#', tmpcount, '| Sending to', thisnum, '...'
command = 'python sendsms.py ' + thisnum + " '" + message + "'"
print '', command
print commands.getoutput(command)
if not tmpcount == numlength:
print ' Success. Delaying 2 seconds...'
time.sleep(2)
else:
print ' Success.'
</code>
There had to be a delay of about 2 seconds between each message being
sent, because it hangs if there isn't a delay.

Works fine so far with the exception of a couple of random hangs here
and there. But I've sent out about 100 messages today and all seems
fine.

Oh and the weird thing's that after messing around with this, I
couldn't connect my modem to the net, OSX tells me its some fatal
error. Had to reinstall the drivers and stuff before it worked again.
But pyhumod still exhibits the same behaviour.

Cheers,
KrX

KrX

unread,
Apr 29, 2010, 10:49:52 AM4/29/10
to pyhumod
Alright problems :/

My E220 seems to work for the first 5 or so messages that are sent
out. I made a script which delayed the sending of each message by 5
seconds. But it still jams out around the fifth message being sent
out.

It was a message with the same content throughout but to 144
recipients.

I had to slowly go through my list and manually delete those which the
modem has sent the message to.

Weird thing is the modem doesn't give any error whatsoever when it
hangs - it just, hangs. The modem light still blinks but the python
prompt just seems to be waiting for an output from humod.

Any idea what the cause could be?
--
You received this message because you are subscribed to the Google Groups "pyhumod" group.
To post to this group, send email to pyh...@googlegroups.com.
To unsubscribe from this group, send email to pyhumod+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyhumod?hl=en.

Reply all
Reply to author
Forward
0 new messages