Created
October 18, 2023 02:58
-
-
Save ckurtz22/8d8c6060a595cc8e60325c81b5ff981f to your computer and use it in GitHub Desktop.
Read diagnostic data from Polestar 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Must install doipclient and udsoncan for Python: | |
# pip install doipclient udsoncan | |
import udsoncan | |
from doipclient import DoIPClient | |
from doipclient.connectors import DoIPClientUDSConnector | |
from udsoncan.client import Client | |
from udsoncan.exceptions import * | |
from udsoncan.services import * | |
from struct import pack, unpack | |
udsoncan.setup_logging() | |
ecu_ip = '169.254.218.223' # have to find out what IP the polestar is communicating on from wireshark or something | |
# can probably use something in doipclient to automatically grab the polestar's IP | |
ecu_logical_address = 0x1635 # this is the address for the BECM (hv battery control module) | |
tester_logical_address = 0x0e80 # this is the only tester address the polestar seems to accept | |
config = dict(udsoncan.configs.default_client_config) | |
config["data_identifiers"] = { | |
0x4a88: ">h", # Battery power (kW) | |
0x496d: ">i", # Battery SOH (0.01%) | |
0x4028: ">I", # Battery SOC (0.000001%) | |
0x489C: ">I", # Charging Power limit? (0.001W) | |
} | |
doip_client = DoIPClient(ecu_ip, ecu_logical_address, client_logical_address=tester_logical_address) | |
conn = DoIPClientUDSConnector(doip_client) | |
with Client(conn, request_timeout=2, config=config) as client: | |
print(client.read_data_by_identifier_first(0x496d) / 100) | |
# client.send_request(udsoncan.Request(service=ReadDataByIdentifier, data=b'\x48\x9c')) | |
client.tester_present() | |
doip_client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There was a routine I ran when I had my VIDA license for 3 days that did this. From what I understood when I looked into Orbit is that VIDA will do the seed and key for you, and Orbit can crack the key generator if it just has a correct seed/key pair (and alternatively the guy seems to have a way to also just crack it from your VIN). So even if I could trigger diagnostics from the OBD port for seed and key it wouldn't help unless I already knew the seed&key algorithm.
Doing it in VIDA is pretty easy though. Just need a 70$ 3 day license, and then the diagnostic check thing for it costs 5$. I captured everything in Wireshark so if I end up getting Orbit later I can use it later.