Skip to content

Commit 8b894a7

Browse files
authored
Merge pull request #162 from openxc/get-vin-heartbeat
Get vin heartbeat
2 parents 1339794 + 26275d9 commit 8b894a7

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/python-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24+
sudo apt-get update
2425
sudo apt-get install python-bluetooth -qq -y
2526
python -m pip install --upgrade pip
2627
python -m pip install pytest pyserial==3.1.1 coveralls

openxc/controllers/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,14 @@ def device_id(self):
430430
}
431431
return self._check_command_response_message(request)
432432

433+
def get_vin(self):
434+
"""Request vehicle VIN
435+
"""
436+
request = {
437+
"command": "get_vin"
438+
}
439+
return self._check_command_response_message(request)
440+
433441
def write(self, **kwargs):
434442
"""Serialize a raw or translated write request and send it to the VI,
435443
following the OpenXC message format.

openxc/tools/control.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def sd_mount_status(interface):
3131
def device_id(interface):
3232
print(("Device ID is %s" % interface.device_id()))
3333

34+
def get_vin(interface):
35+
print(("Vehicle VIN is %s" % interface.get_vin()))
36+
3437
def passthrough(interface, bus, passthrough_enabled):
3538
if interface.set_passthrough(bus, passthrough_enabled):
3639
print(("Bus %u passthrough set to %s" % (bus, passthrough_enabled)))
@@ -93,7 +96,7 @@ def parse_options():
9396
parser = argparse.ArgumentParser(description="Send control messages to an "
9497
"attached OpenXC vehicle interface", parents=[device_options()])
9598
parser.add_argument("command", type=str,
96-
choices=['version', 'platform', 'write', 'id', 'set', 'sd_mount_status'])
99+
choices=['version', 'platform', 'write', 'id', 'set', 'sd_mount_status', 'get_vin'])
97100
write_group = parser.add_mutually_exclusive_group()
98101
write_group.add_argument("--name", action="store", dest="write_name",
99102
help="name for message write request")
@@ -184,6 +187,8 @@ def main():
184187
sd_mount_status(interface)
185188
elif arguments.command == "id":
186189
device_id(interface)
190+
elif arguments.command == "get_vin":
191+
get_vin(interface)
187192
elif arguments.command == "set":
188193
handle_set_command(arguments, interface)
189194
elif arguments.command == "write":

0 commit comments

Comments
 (0)