Skip to content

Instantly share code, notes, and snippets.

@munro
Created July 17, 2017 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save munro/05de5436e39cda662d2a171dc0f17ab5 to your computer and use it in GitHub Desktop.
Save munro/05de5436e39cda662d2a171dc0f17ab5 to your computer and use it in GitHub Desktop.
async def _on_message(message : Message):
print(f'[received message] {message}')
print((message.arbitration_id, binascii.hexlify(message.data)))
if message.arbitration_id == 0x0241 and binascii.hexlify(message.data) == b'0008021a90':
print(f'FOUND MESSAGE! {message}')
found_message.set_result((True, binascii.hexlify(message.data)))
async with pcan.listen_message(_on_message):
print('Listening for messages!')
print('Sending obd_driver')
await run_in_thread(adb.execute, '/data/tests/obd_driver -t 0 -c 2 -q 577 -r 1601 -p 0 -o 5000 -d 0x08021A90')
# print(f'AAAAAAAAAAAA {a}')
# a = adb.execute('/data/tests/obd_driver -t 0 -c 2 -q 577 -r 1601 -p 0 -o 10000 -d 0x08021A90')
print('Done, waiting for message ...')
resp = await found_message
print(f'\n\nISFOUND: {resp[0]}\nDATERS: {resp[1]}')
print('WOO FOUND MESSAGE!!!')
############ AFTER WE FIND MESSAGE=ID, I WANT TO SEND THE MESSAGE BELOW###################
###### but also... await run_in_thread(adb.execute, '/data/tests/obd_driver -t 0 -c 2 -q 577 -r 1601 -p 0 -o 5000 -d 0x08021A90')
###### this shouldn't finish until we send a can messsage back.
print('sending response')
pcan.send_message(0x241, [0x03, 0x5A, 0x90, 0x22, 0xFF ,0xFF ,0xFF ,0xFF])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment