brendan-w / python-OBD

OBD-II serial module for reading engine data
GNU General Public License v2.0
1.02k stars 360 forks source link

Async Readout Reads None for the first few queries, then returns value #231

Open LHeller01 opened 2 years ago

LHeller01 commented 2 years ago

as it states above, im trying to readout RPM in the async function, but it reads none for the first few times then catches up and gives a readout. Also I dont see in the docs how to return the value as an int or the RPMs only and not the revolutions_per_Minute part. For some reason it also returns none when the async query command is set to a variable. Any help would be appreciated. Code:

def StartAsyncOBDConnection
   global AsyncConnection

  AsyncConnection = obd.Async()
  AsyncConnection.watch(obd.commands.RPM)

  #AsyncRPM = AsyncConnection.query(obd.commands.RPM) (if you use this in place of just writing it out in the function below, it returns none no matter what...)

  count = 0

  #Simple counter, that way the while loop queries for information but eventually stops, good for testing
  while count < 300
   print(AsyncConnection.query(obd.commands.RPM)) 
   #for other issue, replace AsyncConnection.query(obd.commands.RPM)) with AsyncRPM Variable. 
   count += 1
   time.sleep(0.1)