Merge ~sylvain-pineau/checkbox-support:canbus_udev into checkbox-support:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: a254ddd8c42c1212a63b1a48e74c0382186af945
Merged at revision: b6bd31e361ec47a33bedfb29fff2fa5296ef6423
Proposed branch: ~sylvain-pineau/checkbox-support:canbus_udev
Merge into: checkbox-support:master
Diff against target: 63 lines (+24/-0)
1 file modified
checkbox_support/parsers/udevadm.py (+24/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+315746@code.launchpad.net

Description of the change

Add support for CANBUS devices to the udev parser (tested on two different SKU, using serial and hidraw)

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Self-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
2index 4f66733..7767945 100644
3--- a/checkbox_support/parsers/udevadm.py
4+++ b/checkbox_support/parsers/udevadm.py
5@@ -454,6 +454,10 @@ class UdevadmDevice(object):
6 if self._environment["DRIVER"] == "floppy":
7 return "FLOPPY"
8
9+ if "DEVLINKS" in self._environment:
10+ if "canbus" in self._environment["DEVLINKS"]:
11+ return "CANBUS"
12+
13 # Some audio and serial devices have a product but no vendor
14 # or product id. Special-case their categories for backwards-
15 # compatibility.
16@@ -555,6 +559,11 @@ class UdevadmDevice(object):
17 if self.driver == "nvme" and self.bus == 'pci' and self._stack:
18 parent = self._stack[-1]
19 return parent.product_id
20+ # canbus
21+ if "DEVLINKS" in self._environment:
22+ if "canbus" in self._environment["DEVLINKS"]:
23+ if "ID_MODEL_ID" in self._environment:
24+ return decode_id(self._environment["ID_MODEL_ID"])
25 return None
26
27 @product_id.setter
28@@ -587,6 +596,11 @@ class UdevadmDevice(object):
29 if self.driver == "nvme" and self.bus == 'pci' and self._stack:
30 parent = self._stack[-1]
31 return parent.vendor_id
32+ # canbus
33+ if "DEVLINKS" in self._environment:
34+ if "canbus" in self._environment["DEVLINKS"]:
35+ if "ID_VENDOR_ID" in self._environment:
36+ return decode_id(self._environment["ID_VENDOR_ID"])
37 return None
38
39 @vendor_id.setter
40@@ -725,6 +739,11 @@ class UdevadmDevice(object):
41 if element in self._environment:
42 return self._environment[element].strip('"')
43
44+ if "DEVLINKS" in self._environment:
45+ if "canbus" in self._environment["DEVLINKS"]:
46+ if "ID_MODEL_ENC" in self._environment:
47+ return decode_id(self._environment["ID_MODEL_ENC"])
48+
49 return None
50
51 @product.setter
52@@ -782,6 +801,11 @@ class UdevadmDevice(object):
53 if "ID_VENDOR_ENC" in self._environment:
54 return decode_id(self._environment["ID_VENDOR_ENC"])
55
56+ if "DEVLINKS" in self._environment:
57+ if "canbus" in self._environment["DEVLINKS"]:
58+ if "ID_VENDOR_ENC" in self._environment:
59+ return decode_id(self._environment["ID_VENDOR_ENC"])
60+
61 return None
62
63 @vendor.setter

Subscribers

People subscribed via source and target branches