Best way to do scans ,,,

#1

Since recording the bus doesn’t work for me, I figured I could write some custom code to do some queries, save the resulting hex dumps for later off-line analysis.

So sarting with Support for electric vehicles I have some custom code that calls obd.query and logs the data (to minion.log) for later upload -

for mode in ['21']:
    for pid in ['01','02','f2']:
        args = ['scan '+mode+pid]
        kwargs = {
            'mode': mode,
            'pid': pid,
            'header': '7E2',
            'baudrate': 500000,
            'protocol': '6',
            'verify': False,
            'force': True,
        }
        log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))

However I noticed this is pretty slow - about one query per second. I thought the OBD port was much faster than this.

So is there a better/faster/more efficient way to scan multiple PID’s for recording purposes ?

Thanks.

OBD request frequency
#2

Still curious about this …

#3

Hi Peter

Can you try using the obd.send method instead?
http://docs.autopi.io/commands/obd/#obd-send

Something like:

obd.send 7E2#01 auto_format=true expect_response=true

Best regards
/Malte

#4

Thanks.

Would this still need the __salt__ wrapper in custom code ?

Does this return a Message object ( the docs don’t mention return data )

#5

Hi Peter

Yes, you still need to use __salt__ to execute the module.
The return value is more raw than the obd.query, it returns a string array with the response(s).

And remember that obd.send does not take a formula like obd.query.

Best regards
/Malte

#6

Thanks. So I’ve been trying -

args = ['7E4#220101']
kwargs = {
    'auto_format': True,
    'expect_response': True,
    'baudrate': 500000,
    'protocol': '6'
}

res = __salt__['obd.send'](*args, **kwargs)

Example return is -

{'_type': 'raw', 'values': ['7EC 10 3E 62 01 01 FF F7 E7', '7EC 21 FF B3 1B 80 3F C0 03', '7EC 22 FF E6 0F 8C 07 06 06', '7EC 23 06 06 06 00 00 06 CB', '7EC 24 4B CA 46 00 00 94 00', '7EC 25 00 86 1C 00 00 83 52', '7EC 26 00 00 32 E7 00 00 2F', '7EC 27 F5 00 17 2C 28 09 01', '7EC 28 8E 00 00 00 00 03 E8], '_stamp': '2019-04-04T16:41:34.937725'}

So it looks to me that values is a stringified version of the raw data, rather than the raw data itself.

So, where are we?