help! use pyhumod in RHEL 4.2 with EC325

38 views
Skip to first unread message

mistletoe

unread,
Aug 12, 2009, 6:11:30 AM8/12/09
to pyhumod
I am Chinese . I want to send message with EC325 in CDMA network. I
find the pyhumod with google. It is seemed to be good. But i got
some problems.

First, my linux is RHEL 4.2. Dbus version in it is dbus-0.22-12.EL.
9. When I ran the script: find_huawei_iface. I got the error:

AttributeError: SystemBus instance has no attribute 'get_object'.

I tried my best to solve it but I failed.


Second, because ec325 is a cdma device, I change the pyhumod-0.02/
default.py :

DATA_PORT = '/dev/ttyUSB0'
CONTROL_PORT = '/dev/ttyUSB1'
PPPD_PATH = '/usr/sbin/pppd'
PROBER_TIMEOUT = 0.5
BAUDRATE = '115200'
DIALNUM = '#777'
PPPD_PARAMS = ['modem', 'crtscts', 'defaultroute', 'usehostname', '-
detach',
'noipdefault', 'call', 'humod', 'user', 'card',
'usepeerdns',
'idle', '0', 'logfd', '8']

in the /etc/ppp/pap-secrets file:
card pdsn card

when I entered this code in python:

>>> import humod
>>> m = humod.Modem()
>>> model = m.show_model()

I waited and waited, but nothing happened. In the end I ended the
command with "Ctrl + C", the messaged I got was:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
239, in show_model
return _common_run_unprefixed(self, '+GMM')[0]
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
72, in _common_run_unprefixed
info = modem.ctrl_port.return_data()
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 180,
in return_data
input_line = self.readline().rstrip()
File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
60, in readline
c = self.read(1)
File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line
317, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt

by the way, I show the message that I success to get when I use the
wvdial and pppd.

my /etc/wvdial.conf:
[Modem0]
Modem = /dev/ttyUSB0
Baud = 115200
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
FlowControl = Hardware (CRTSCTS)
[Dialer cdma]
Username = CARD
Password = CARD
Phone = #777
Stupid Mode = 1
Inherits = Modem0

when I enter in:
# wvdial cdma&

--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 230400
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Wed Aug 12 18:08:43 2009
--> pid of pppd: 31981
--> Using interface ppp0


can you help me? Thank you.

mistletoe

unread,
Aug 13, 2009, 4:53:13 AM8/13/09
to pyhumod
I try it again.

>>> m.show_sn()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
231, in show_sn
return _common_run_prefixed(self, '^SN')[0]
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
92, in _common_run_prefixed
data = data_cmd.run()
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
32, in run
return self.modem.ctrl_port.send(self.cmd, should_wait,
at_cmd=self.cmd)
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 161,
in send
return self.return_data(at_cmd)
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 180,
in return_data
input_line = self.readline().rstrip()
File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
60, in readline
c = self.read(1)
File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line
317, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt

>>> m.show_revision()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
243, in show_revision
return _common_run_unprefixed(self, '+GMR')[0]
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
72, in _common_run_unprefixed
info = modem.ctrl_port.return_data()
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 180,
in return_data
input_line = self.readline().rstrip()
File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
60, in readline
c = self.read(1)
File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line
317, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt

It seemed that EC325 AT command is different from other HUAWEI card.
Isn't it? Why does select function wait for forever even that I add
the line: self._timeout = 5 before "ready,_,_ = select.select
([self.fd],[],[], self._timeout)" ?

mistletoe

unread,
Aug 14, 2009, 5:36:19 AM8/14/09
to pyhumod
I find the answer of Question 2. I changed the number of serials.

>>> m = humod.Modem('/dev/ttyUSB1', '/dev/ttyUSB0')
>>> m.show_imei()
'+GSN: 81F41C00'

but I find the AT command in EC325 is different from others (E220,
E200...).

>>> m.enter_text_mode()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
298, in enter_text_mode
_common_set(self, '+CMGF', '1')
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
111, in _common_set
data = Command(modem, at_cmd).set(value)
File "/usr/lib/python2.3/site-packages/humod/at_commands.py", line
52, in set
value), should_wait, at_cmd=self.cmd)
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 161,
in send
return self.return_data(at_cmd)
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 182,
in return_data
errors.check_for_errors(input_line)
File "/usr/lib/python2.3/site-packages/humod/errors.py", line 35, in
check_for_errors
raise AtCommandError, input_line
humod.errors.AtCommandError: ERROR

In the Google, I find the AT command to send message:
http://www.unpackstudio.com/printer_friendly_posts.asp?TID=1

AT$HSMSD=<PH>,<LENGTH>,0,1

the command is strange, how can i enter the message text ?
Thank you for the Pyhumod. Do you have the at commands with EC325 or
EC321?
And how can i use the ppp connect function in Pyhumod ? Because when I
enter:

>>> m.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 258,
in connect
data_port.send('ATZ\r')
File "/usr/lib/python2.3/site-packages/humod/humodem.py", line 154,
in send
input_line = self.readline()
File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
60, in readline
c = self.read(1)
File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line
317, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt

It sleeps forever !!

oozie

unread,
Aug 22, 2009, 5:43:16 AM8/22/09
to pyh...@googlegroups.com
Hi mistletoe,

My apologies for a very late answer, I was on 3-week holidays with no
access to Internet.

I tried to get hold of EC325 but, unfortunately, none of my friends
was in a possession of the device, so I can't really confirm if a
different set of commands applies, but I suspect it shouldn't be much
different from e.g. E220.

In your first posting you mentioned that you were using an outdated
Linux version issued in 2005 with an even older dbus subsystem (which
is probably a reason why find_huawei_iface.py fails). Can you please
try something more recent?

It seems that the modem device (/dev/ttyUSB0) is recognized correctly,
but the control device (/dev/ttyUSB1?) does not allow serial port
communication and hence pyhumod hangs forever on it.

Please try the following, it would be best if you could answer the
questions on some recent Linux distribution (with a kernel issued at
latest in 2008):

What is the output of 'ls -al /dev/ttyUSB*' command?
Do you see 2, 3 or more ttyUSB* interfaces?

Use minicom to connect to the ports that have been listed and try
typing in the minicom window the following command:

AT+GMI <press enter>
AT+GMM <press enter>

They should display the manufacturer and device model on the ttyUSB?
ports that are correctly recognized.

[...]

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

mistletoe

unread,
Aug 27, 2009, 9:22:06 PM8/27/09
to pyhumod
OOZie:
Thank for your message.
first, In my RHEL 4.2, I got the error message:

File "find_huawei_iface.py", line 74, in ?
main()
File "find_huawei_iface.py", line 64, in main
devices = find_huawei_devices()
File "find_huawei_iface.py", line 42, in find_huawei_devices
hal_mgr_obj = bus.get_object(BUS_NAME, MGR_OBJ)
AttributeError: SystemBus instance has no attribute 'get_object'

I only find that there isn't get_object function in dbus-0.22. The
version of dbus is too old.
second, I try my best but I can't find the reference of EC325. But
in the end I find the at commmand of EC325. the url is:
http://www.sangrong.com/download/cm300.pdf
I have test the AT command of send message, ppp connection and
telphone number. It successes. I think it may be useful for you. Then
I will try to change your pyhumod to send message, visit the wap site
through ppp connection etc. It will be a large work for a junior.
Thank you again for your code.

mistletoe

unread,
Aug 28, 2009, 5:47:10 AM8/28/09
to pyhumod
why did you make pyhumod have a function -- sendATCommand() ?

then we can send all at commmand with this interface.

mistletoe

unread,
Aug 28, 2009, 5:47:29 AM8/28/09
to pyhumod

oozie

unread,
Aug 28, 2009, 6:37:15 AM8/28/09
to pyh...@googlegroups.com
Hi Mistletoe,

On Fri, Aug 28, 2009 at 10:47 AM, mistletoe<mistle...@gmail.com> wrote:
>
> why did you make pyhumod have a function  -- sendATCommand() ?
>
> then we can send all at commmand with this interface.

I understand that the question is why I didn't implement that function
or method.

This is where a developer guide would come in handy - I will try to
publish something on the project wiki this weekend.

Anyway, I implemented something else - the Command class.

Here is a short description of how it works:

In general, you can pass an AT command to the modem in 4 ways:

- "AT+CMD" - to tell the modem do something, (run)
- "AT+CMD?" - to query the current setting in the memory or the
current state, (get)
- "AT+CMD=?" - to see what are the possible values to set, (dsc for describe)
- "AT+CMD=value" - to set a value for the given command/setting. (set)

For instance, if you want to see who is the manufacturer and use an
"AT+GMI" command to do that you can do the following:

>>> import humod
>>> from humod.at_commands import Command as Cmd
>>> m=humod.Modem()
>>> show_manufacturer = Cmd(m, '+GMI')
>>> show_manufacturer.run()

If you want to get a list of networks with the "AT+COPS=?" command,
you will do the following:

>>> networks = Cmd(m, '+COPS')
>>> networks.dsc()

and so on...

mistletoe

unread,
Sep 1, 2009, 4:10:35 AM9/1/09
to pyhumod
I think there is some problem in your code. For example:

In the huawei AT Command: http://www.sangrong.com/download/cm300.pdf

Send message command is : AT$HSMSSD=13300133110, 11, 1, 1

it will be sure that I can't send message with function "dec". I
suggest that you would make a moderm class: it acts like the command
minicom. After connecting I enter the whole AT command and the result
returns.

I find the similar perl package in the CPAN.
http://search.cpan.org/~cosimo/Device-Modem-1.51/docs/Device-Modem.pod

I think it is useful for you. Thank for your code.

oozie

unread,
Sep 1, 2009, 7:58:18 PM9/1/09
to pyh...@googlegroups.com
Hi

On Tue, Sep 1, 2009 at 9:10 AM, mistletoe<mistle...@gmail.com> wrote:
>
> I think there is some problem in your code. For example:
>
> In the huawei AT Command:   http://www.sangrong.com/download/cm300.pdf
>
> Send message command is :   AT$HSMSSD=13300133110, 11, 1, 1
>
> it will be sure that I can't send message with function "dec". I
> suggest that you would make a moderm class: it acts like the command
> minicom. After connecting I enter the whole AT command and the result
> returns.

I can't disagree with the fact that there is a bunch of problems in my code :)
However, the functionality that you are looking for is probably
already in there. You can use one of the serial port methods
(inherited from serial.Serial) to send strings to the modem
minicom-style.

For instance:
m = humod.Modem()
m.ctrl_port.write('ATZ\r\n')

Also, it's not the dec() but dsc() method. And I agree, you can not
set values with the dsc() methods (dsc is there for querying). You can
do it with the set() method. Just in case you would like to do that I
have redesigned some of the internals and updated the Developers
Guide:

http://code.google.com/p/pyhumod/wiki/DevelGuide

Obviously, I'm not stopping you from hacking PyHumod minicom-style.
Please make sure that you use the latest source version from the
mercurial repository.

> I find the similar perl package in the CPAN.
> http://search.cpan.org/~cosimo/Device-Modem-1.51/docs/Device-Modem.pod

Thanks for the link.

It's probably a good idea to close this thread as it went a bit off topic.

Reply all
Reply to author
Forward
0 new messages