def test_from_byte(self):
        comtype = CommunicationType.from_byte(b'\x01')
        self.assertEqual(comtype.get_byte(), b'\x01')

        comtype = CommunicationType.from_byte(b'\xF1')
        self.assertEqual(comtype.get_byte(), b'\xF1')

        comtype = CommunicationType.from_byte(b'\x33')
        self.assertEqual(comtype.get_byte(), b'\x33')
Beispiel #2
0
    def normalize_communication_type(self, communication_type):
        from udsoncan import CommunicationType

        if not isinstance(communication_type, CommunicationType) and not isinstance(communication_type, (int, long)) and not isinstance(communication_type, str):
            raise ValueError(u'communication_type must either be a CommunicationType object or an integer')

        if isinstance(communication_type, (int, long)) or isinstance(communication_type, str):
            communication_type = CommunicationType.from_byte(communication_type)

        return communication_type