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
diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
index 4f66733..7767945 100644
--- a/checkbox_support/parsers/udevadm.py
+++ b/checkbox_support/parsers/udevadm.py
@@ -454,6 +454,10 @@ class UdevadmDevice(object):
454 if self._environment["DRIVER"] == "floppy":454 if self._environment["DRIVER"] == "floppy":
455 return "FLOPPY"455 return "FLOPPY"
456456
457 if "DEVLINKS" in self._environment:
458 if "canbus" in self._environment["DEVLINKS"]:
459 return "CANBUS"
460
457 # Some audio and serial devices have a product but no vendor461 # Some audio and serial devices have a product but no vendor
458 # or product id. Special-case their categories for backwards-462 # or product id. Special-case their categories for backwards-
459 # compatibility.463 # compatibility.
@@ -555,6 +559,11 @@ class UdevadmDevice(object):
555 if self.driver == "nvme" and self.bus == 'pci' and self._stack:559 if self.driver == "nvme" and self.bus == 'pci' and self._stack:
556 parent = self._stack[-1]560 parent = self._stack[-1]
557 return parent.product_id561 return parent.product_id
562 # canbus
563 if "DEVLINKS" in self._environment:
564 if "canbus" in self._environment["DEVLINKS"]:
565 if "ID_MODEL_ID" in self._environment:
566 return decode_id(self._environment["ID_MODEL_ID"])
558 return None567 return None
559568
560 @product_id.setter569 @product_id.setter
@@ -587,6 +596,11 @@ class UdevadmDevice(object):
587 if self.driver == "nvme" and self.bus == 'pci' and self._stack:596 if self.driver == "nvme" and self.bus == 'pci' and self._stack:
588 parent = self._stack[-1]597 parent = self._stack[-1]
589 return parent.vendor_id598 return parent.vendor_id
599 # canbus
600 if "DEVLINKS" in self._environment:
601 if "canbus" in self._environment["DEVLINKS"]:
602 if "ID_VENDOR_ID" in self._environment:
603 return decode_id(self._environment["ID_VENDOR_ID"])
590 return None604 return None
591605
592 @vendor_id.setter606 @vendor_id.setter
@@ -725,6 +739,11 @@ class UdevadmDevice(object):
725 if element in self._environment:739 if element in self._environment:
726 return self._environment[element].strip('"')740 return self._environment[element].strip('"')
727741
742 if "DEVLINKS" in self._environment:
743 if "canbus" in self._environment["DEVLINKS"]:
744 if "ID_MODEL_ENC" in self._environment:
745 return decode_id(self._environment["ID_MODEL_ENC"])
746
728 return None747 return None
729748
730 @product.setter749 @product.setter
@@ -782,6 +801,11 @@ class UdevadmDevice(object):
782 if "ID_VENDOR_ENC" in self._environment:801 if "ID_VENDOR_ENC" in self._environment:
783 return decode_id(self._environment["ID_VENDOR_ENC"])802 return decode_id(self._environment["ID_VENDOR_ENC"])
784803
804 if "DEVLINKS" in self._environment:
805 if "canbus" in self._environment["DEVLINKS"]:
806 if "ID_VENDOR_ENC" in self._environment:
807 return decode_id(self._environment["ID_VENDOR_ENC"])
808
785 return None809 return None
786810
787 @vendor.setter811 @vendor.setter

Subscribers

People subscribed via source and target branches