[Python-Dev] Python vs. chat (conversation with modem)
b.scharpf at tesionmail.de
Wed Apr 7 15:46:14 EDT 2004
in simple serial communication, I found a problem that
doesn't arise, when I'm doing exactly the same with the
I admit my hardware is a little bit special and may have
problems itself. It is an ISDN telephone, Elmeg C200d at ta.
With a normal modem, everything works fine.
For a speech call, my telephone wants me to send a command
'at&b30' before dialing (otherwise the modem functionality
When I send the commands with `chat', the device is
dialing, but when I send them from a Python script, the
My code is (simplified):
def __init__( self, device = '/dev/ttyS0'):
self.modem = open( device, 'w+')
def send( self, cmd):
print >>self.modem, cmd + '\r'
def expect( self, patt):
def command( self, cmd):
def dial_orig( self, nr):
# On this request, the modem won't send an answer.
self.command( 'atdt,%s;h0z' % nr)
def dial_chat( self, nr):
script += [ repr( ''), 'atz',
chatcmd = '/usr/sbin/chat -vs -T %s %s <%s >%s' % \
(nr, ' '.join( script), self.modem.name, self.modem.name)
dial = dial_chat
(The full script is available at
On the 'atz' an answer of 'OK' is sent back, but not on the
'at&b30' request. `chat' receives an OK. Setting the
termcaps exactly to what chat would have chosen didn't help.
I have found this behaviour in the versions 2.1, 2.2 and 2.3.
$ uname -srmp
Linux 2.4.18-bs1 i586 unknown
Do I have any chance to find out what happens?
More information about the Python-Dev