Hi,I want monitoring a Nissans Leaf NV200 using this python script and obd2 bluetooth adapter:
It works but how can I change it to get more pid at the same time? After sending the ATMA command the connection is closed.
Code:
import serial
elm = serial.Serial("/dev/rfcomm0", 38400, timeout=5)
elm.write(b"ATZ\r\n") # reset all
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATE0\r\n") # print version ID
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATH1\r\n") # headers on
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATAL\r\n") # allow long messages
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATSP6\r\n") # set protocol ISO 15765-4 CAN (11/500)
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATCM 55B \r\n") # SOC
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATCF 7FF \r\n") #
print(elm.read_until(b"\r\n>").decode())
elm.write(b"ATMA\r\n") # monitor all messages
print(elm.read_until(b"\r"))
elm.close()