You Are Here:

Community: Developer Discussion Boards

#1 Old OBD reader symbian and bluetooth - 2009-03-09, 10:04

Join Date: Jan 2009
Posts: 5
owen-oxo
Offline
Registered User
Hi

I made a small proof of concept over the last 4 days: had to learn python

If one has a "modern" car, then it has an obd-ii connector ( http://en.wikipedia.org/wiki/On-Board_Diagnostics )

If one has a Symbian phone and a bluetooth obdii device based on an ELM device (http://www.elmelectronics.com/), it is possible to write a python script: for example to see what the warning engine red light means.

Here is my first attempt

Code:
# Bluetooth ELM
# first attempt
# by Owen Brotherwood, DK

import appuifw
import socket
import e32
import time

initELM = [  "atz\r", "ate0\r", "atl0\r", "ats0\r" ]
cmds = [ "atrv\r", "0100\r", "0101\r", "03\r" ]

def bt_connect():
    sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
    target=''
    if not target:
        address,services=socket.bt_discover()
        print "Discovered: %s, %s"%(address,services)
        if len(services)>1:
            choices=services.keys()
            choices.sort()
            choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                        for x in choices],u'Choose port:')
            target=(address,services[choices[choice]])
        else:
            target=(address,services.values()[0])
    print "Connecting to "+str(target)
    sock.connect(target)
    return sock
      
def readbt(prompt = ">" , time = 5):
    global sock, data, running, timer
    line = d = ""
    timer.after(time, subtout)
    while running == 1:
        d = sock.recv(1)
        if timeout != 1:
            timer.cancel()
        else:
            return ""
        if d == 0:
            continue
        if d == "?":
            return ""
        if d == prompt:
            return line
        else:
            line += d
    
def subtout():
    global sock, timeout, timer, running
    timer.cancel()
    timeout = 1
    if running == 1:
        sock.send("atz\r")
  
def start():
    global timer, sock, timeout
    
    for init in initELM:
      sock.send( init )
      line = readbt()  # and throw away ...
      
    for cmd in cmds:
        if running == 1:
            sock.send( cmd )
        else: 
            return
        line = ""
        line = readbt()
        if timeout == 0:  
            print line,  # or put in a dictionary ...
        else:
            print "T-T-TIMEOUT"
            timeout = 0
            start()
            
def quit():
    global sock, running, script_lock
    running = 0
    script_lock.signal()
    #appuifw.app.set_exit()

# Symbian setup
script_lock = e32.Ao_lock()    
timer = e32.Ao_timer()
appuifw.app.exit_key_handler = quit
appuifw.app.title = u"BT ELM DTC Reader"

# some globals 
running = 1
timeout = sock = 0

sock = bt_connect()

if sock != 0:
    start()
    sock.close()

script_lock.wait()
#==========================================
This basically throws up the error's found in the engine.

I doubt the app will ever be really graphical with graphs etc.: just data to aid if one is driving on holiday and the light goes on.
Another branch would be that the app can send an sms when the wife is driving the car: then I can say "stop" if it is a bad error ...

If you "need this" and can python and want to help: post.

I'll probably make a sourceforge project if there is anybody intrested.


Referance to elm : http://www.elmelectronics.com/DSheets/ELM327DS.pdf
Reply With Quote

#2 Old Re: OBD reader symbian and bluetooth - 2009-03-09, 10:15

Join Date: Jan 2009
Posts: 5
owen-oxo
Offline
Registered User
https://sourceforge.net/projects/symbtelm/
Reply With Quote

#3 Old Re: OBD reader symbian and bluetooth - 2009-03-09, 14:08

Join Date: Jan 2009
Posts: 5
owen-oxo
Offline
Registered User
http://www.cs.unm.edu/~donour/cars/pyobd/ contains some nice work in python that only needs a small change from serial I/O to Bluetooth I/0

However ... my 4 days py60 experience is not enough in finding out how to use a module/file.

I copied some files over into the python script dir on my phone: obd_io.py wants to import obd_sensors but I get an error.
I think I need some library/module path but don't know how ...
I don't want to make one big script file: but if there is no other way ...

Any help would be aprieciated

Code:
import obd_sensors
from powertrain_codes import pcodes
from network_codes    import ucodes

Edit: reading http://docs.python.org/tutorial/modu...tandardmodules

Edit: solved @ http://www.johnny-lin.com/cdat_tips/...lang/path.html
import sys
sys.path.append("e:\python")

Edit:
pys60 doesn't seem to cwd to the dir of the script
- it is e:\private\<something>
=> sucks

http://www.webdotdev.com/nvd/article...n-867-204.html
Last edited by owen-oxo : 2009-03-09 at 18:55. Reason: HOWEVERr
Reply With Quote

#4 Old Announce: OBD-II reader for symbian via bluetooth - 2009-03-12, 07:07

Join Date: Jan 2009
Posts: 5
owen-oxo
Offline
Registered User
https://apps.sourceforge.net/mediawiki/symbtelm
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Q: How to use NCF 1.2 bluetooth with S60 3rd Edition for Symbian C++ MR jimgilmour1 Bluetooth Technology 35 2009-04-11 15:36
Bluetooth on Symbian S60 3rd Edition FP1 Emulator Shilpa_Walvekar Bluetooth Technology 0 2009-03-04 10:08
ans: here is Symbian Error codes whilst using bluetooth debug and porting jimgilmour1 Bluetooth Technology 0 2006-07-30 08:50
Q: How do I program bluetooth using S60 symbian C++ A:documents here jimgilmour1 Bluetooth Technology 0 2006-07-25 16:45
whic version of symbian is required for bluetooth application development venkatareddy Bluetooth Technology 3 2005-04-07 14:55

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ