David Lonie
2008-07-13 16:54:19 UTC
I'm using the python script below (much of it adapted from WebSVN -
kryogenix.org - Rev 8 -
/gnome-bluetooth-phones/trunk/backend.py<http://svn.kryogenix.org/filedetails.php?repname=kryogenix.org&path=%2Fgnome-bluetooth-phones%2Ftrunk%2Fbackend.py&sc=1>)
to try to discover the AT+ codes for my samsung a900 in the eventual
goal
of being able to access the calendar. The script works beautifully,
generating AT+XXXX codes and displaying the phone's response, but after a
couple hundred queries the phone stops responding and has to be restarted to
continue. Is there a linux command or a know AT+ code that will reset the
connection without restarting the phone? Having to restart the phone every
couple of minutes is really slowing this down. I'm new to working with
serial tty communications, so even if something should seem obvious, I
probably didn't try it :)
Also, I noticed that Stephen Wood wrote the existing framework for the A900
in trunk. Do you (or anyone else) have any suggestions for getting into the
guts of the phone?
Here's the hacky little python script. It's not well commented, but it's not
that complex either :) Feel free to modify or use it as you see fit:
# samsungATProbe.py
#
#
import
serial
start = 'GMM' # Set the string to start at. 'GMM' is the first
code in the for loops below, since it is known to get a response from the
phone.
active = False
#initialize phone
def talk(send):
ph = serial.Serial('/dev/ttyUSB2', 115200, timeout=0.03)
ph.flushOutput()
ph.flushInput()
# send = 'at+gmm\r'
ph.write(send)
# print "s = " + send
eol, receive_data,blank_line = False, [], 0
while eol != True:
receive=ph.readline().strip()
# print "r = " + receive
if len(receive) > 0:
if receive == send.strip() or receive =='OK' or
receive == 'ERROR':
print receive
continue
else:
print
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + send
print receive
else:
blank_line=blank_line+1
if blank_line > 2: # Some output has a single blank line
within it, so we wait until we get two blank lines before assuming the end
of the output
eol = True
ph.close()
if 1:
for a in ['G', 'P', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
for b in ['M', 'C', 'A', 'B', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W','X', 'Y',
'Z']:
for c in ['M', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z']:
for d in ['', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z']:# No 'R'!!!
if a+b+c+d == start:
active = True
if active:
talk("AT+"+a+b+c+d+'\r')
kryogenix.org - Rev 8 -
/gnome-bluetooth-phones/trunk/backend.py<http://svn.kryogenix.org/filedetails.php?repname=kryogenix.org&path=%2Fgnome-bluetooth-phones%2Ftrunk%2Fbackend.py&sc=1>)
to try to discover the AT+ codes for my samsung a900 in the eventual
goal
of being able to access the calendar. The script works beautifully,
generating AT+XXXX codes and displaying the phone's response, but after a
couple hundred queries the phone stops responding and has to be restarted to
continue. Is there a linux command or a know AT+ code that will reset the
connection without restarting the phone? Having to restart the phone every
couple of minutes is really slowing this down. I'm new to working with
serial tty communications, so even if something should seem obvious, I
probably didn't try it :)
Also, I noticed that Stephen Wood wrote the existing framework for the A900
in trunk. Do you (or anyone else) have any suggestions for getting into the
guts of the phone?
Here's the hacky little python script. It's not well commented, but it's not
that complex either :) Feel free to modify or use it as you see fit:
# samsungATProbe.py
#
#
import
serial
start = 'GMM' # Set the string to start at. 'GMM' is the first
code in the for loops below, since it is known to get a response from the
phone.
active = False
#initialize phone
def talk(send):
ph = serial.Serial('/dev/ttyUSB2', 115200, timeout=0.03)
ph.flushOutput()
ph.flushInput()
# send = 'at+gmm\r'
ph.write(send)
# print "s = " + send
eol, receive_data,blank_line = False, [], 0
while eol != True:
receive=ph.readline().strip()
# print "r = " + receive
if len(receive) > 0:
if receive == send.strip() or receive =='OK' or
receive == 'ERROR':
print receive
continue
else:
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + send
print receive
else:
blank_line=blank_line+1
if blank_line > 2: # Some output has a single blank line
within it, so we wait until we get two blank lines before assuming the end
of the output
eol = True
ph.close()
if 1:
for a in ['G', 'P', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
for b in ['M', 'C', 'A', 'B', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W','X', 'Y',
'Z']:
for c in ['M', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z']:
for d in ['', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z']:# No 'R'!!!
if a+b+c+d == start:
active = True
if active:
talk("AT+"+a+b+c+d+'\r')