Beispiel #1
0
    def test_Upload_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x38

        address = 0x12345678
        address_extension = 0x00

        # data block is 4 unless we specify otherwise
        msg_upload = ccp._short_upload_CRO(CTR, address, address_extension)
        expected_msg = b'\x0F\x38\x04\x00\x12\x34\x56\x78'
        self.assertEqual(msg_upload, expected_msg)

        # if we specify a different data block, needs to be size 1-5
        with self.assertRaises(Exception) as context:
            mta_invalid = ccp._short_upload_CRO(CTR, address,
                                                address_extension, 0)

        self.assertTrue(
            "Data block size must bye 1-5 bytes" in str(context.exception))

        with self.assertRaises(Exception) as context:
            mta_invalid = ccp._short_upload_CRO(CTR, address,
                                                address_extension, 7)

        self.assertTrue(
            "Data block size must bye 1-5 bytes" in str(context.exception))
Beispiel #2
0
    def test_Connect_CRO(self):
        ccp = CCPLeader(c=None)
        msg = ccp._connect_CRO(0x22, 0x200)

        expected = b'\x01\x22\x00\x02\x90\x90\x90\x90'

        self.assertEqual(msg, expected)
Beispiel #3
0
    def test_constructCRO_fails_if_not_8_bytes_long(self):
        ccp = CCPLeader(c=None)

        with self.assertRaises(Exception) as context:
            ccp._constructCRO(0x01, 0x02, b'\x03\x04\x05\x06\x07\x08\x09')

        self.assertTrue('Invalid message length' in str(context.exception))
Beispiel #4
0
    def test_parse_Unlock_CRM(self):
        ccp = CCPLeader(c=None)

        Unlock_CRM = b'\xff\x00\x30\x03\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(Unlock_CRM, CCP_UNLOCK)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x30, \
                    'resource_mask': 0x3, }
        self.assertEqual(parsed, expected)
Beispiel #5
0
    def test_SetSStatus_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x40

        expected = b'\x0D\x40\x81\x90\x90\x90\x90\x90'
        msg = ccp._set_s_status_CRO(CTR, 0x81)
        self.assertEqual(msg, expected)
Beispiel #6
0
    def test_GetSStatus_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x39

        expected = b'\x0D\x39\x90\x90\x90\x90\x90\x90'
        msg = ccp._get_s_status_CRO(CTR)
        self.assertEqual(msg, expected)
Beispiel #7
0
    def test_parse_SetSStatus_CRM(self):
        ccp = CCPLeader(c=None)

        SetSStatus_CRM = b'\xff\x00\x31\x90\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(SetSStatus_CRM,
                                                   CCP_SET_S_STATUS)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x31}
        self.assertEqual(parsed, expected)
Beispiel #8
0
    def test_GetActiveCalPage_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x42

        expected = b'\x09\x42\x90\x90\x90\x90\x90\x90'
        msg = ccp._get_active_cal_page_CRO(CTR)

        self.assertEqual(msg, expected)
Beispiel #9
0
    def test_SelectCalPage_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x41

        expected = b'\x11\x41\x90\x90\x90\x90\x90\x90'
        msg = ccp._select_cal_page_CRO(CTR)

        self.assertEqual(msg, expected)
Beispiel #10
0
    def test_ExchangeId_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x33

        expected = b'\x17\x33\x90\x90\x90\x90\x90\x90'

        msg = ccp._exchangeID_CRO(CTR)

        self.assertEqual(msg, expected)
Beispiel #11
0
    def test_DiagService_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x44
        diag_service_num = 0x08

        expected = b'\x20\x44\x08\x90\x90\x90\x90\x90'
        msg = ccp._diag_service_CRO(CTR, diag_service_num)

        self.assertEqual(msg, expected)
Beispiel #12
0
    def test_parse_start_stop_all_CRM(self):
        ccp = CCPLeader(c=None)

        StartStopAll_CRM = b'\xff\x00\x41\x90\x90\x90\x90\x90'

        parsed = ccp._parse_start_stop_all_CRM(StartStopAll_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x41, \
                   }

        self.assertEqual(parsed, expected)
Beispiel #13
0
    def test_parse_action_service_CRM(self):
        ccp = CCPLeader(c=None)

        ActionService_CRM = b'\xff\x00\x36\x20\x00\x90\x90\x90'

        parsed = ccp._parse_action_service_CRM(ActionService_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x36, \
                    'length_of_return_info': 0x20, 'data_type_qual': 0}

        self.assertEqual(parsed, expected)
Beispiel #14
0
    def test_parse_select_cal_page_CRM(self):
        ccp = CCPLeader(c=None)

        SelectCalPage_CRM = b'\xff\x00\x33\x90\x90\x90\x90\x90'

        parsed = ccp._parse_select_cal_page_CRM(SelectCalPage_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x33, \
                   }

        self.assertEqual(parsed, expected)
Beispiel #15
0
    def test_parse_set_daq_ptr_CRM(self):
        ccp = CCPLeader(c=None)

        SetDaqPtr_CRM = b'\xff\x00\x38\x90\x90\x90\x90\x90'

        parsed = ccp._parse_set_daq_ptr_CRM(SetDaqPtr_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x38, \
                   }

        self.assertEqual(parsed, expected)
Beispiel #16
0
    def test_Test_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x32

        msg = ccp._test_CRO(CTR, 0x770)

        expected = b'\x05\x32\x70\x07\x90\x90\x90\x90'

        self.assertEqual(msg, expected)
Beispiel #17
0
    def test_parse_write_daq_CRM(self):
        ccp = CCPLeader(c=None)

        WriteDaq_CRM = b'\xff\x00\x39\x90\x90\x90\x90\x90'

        parsed = ccp._parse_write_daq_CRM(WriteDaq_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x39, \
                   }

        self.assertEqual(parsed, expected)
Beispiel #18
0
    def test_parse_CCPVersion_CRM(self):
        ccp = CCPLeader(c=None)

        CCPVersion_CRM = b'\xff\x00\x26\x02\x01\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(CCPVersion_CRM,
                                                   CCP_GET_CCP_VERSION)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x26, \
                    'main_protocol': 0x2, \
                    'minor_protocol': 0x1}
        self.assertEqual(parsed, expected)
Beispiel #19
0
    def test_ActionService_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x43
        action_service_num = 0x08
        params = 0x05

        expected = b'\x21\x43\x08\x05\x90\x90\x90\x90'
        msg = ccp._action_service_CRO(CTR, action_service_num, params)

        self.assertEqual(msg, expected)
Beispiel #20
0
    def test_parse_Upload_CRM(self):
        ccp = CCPLeader(c=None)

        Upload_CRM = b'\xff\x00\x23\x4e\xee\xee\xe7\x90'
        parsed = ccp._parse_Command_Return_Message(Upload_CRM, CCP_UPLOAD)
        expected = {
            'CRC': 'acknowledge / no error',
            'CTR': 0x23,
            'data': '0x4eeeeee7'
        }
        self.assertEqual(parsed, expected)
Beispiel #21
0
    def test_GetDaqSize_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x45
        daq_list_number = 0x3
        can_identifier = 0x01020304

        expected = b'\x14\x45\x03\x90\x01\x02\x03\x04'
        msg = ccp._get_daq_size_CRO(CTR, daq_list_number, can_identifier)

        self.assertEqual(msg, expected)
Beispiel #22
0
    def test_parse_get_active_cal_page_CRM(self):
        ccp = CCPLeader(c=None)

        GetActiveCalPage_CRM = b'\xff\x00\x34\x01\xde\xad\xbe\xef'

        parsed = ccp._parse_get_active_cal_page_CRM(GetActiveCalPage_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x34, \
                    'address_ext': 1, 'address': '0xdeadbeef'
                   }

        self.assertEqual(parsed, expected)
Beispiel #23
0
    def test_parse_get_daq_size_CRM(self):
        ccp = CCPLeader(c=None)

        GetDaqSize_CRM = b'\xff\x00\x37\x10\x08\x90\x90\x90'

        parsed = ccp._parse_get_daq_size_CRM(GetDaqSize_CRM)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x37, \
                    'daq_list_size': 0x10, 'first_pid': 0x8
                    }

        self.assertEqual(parsed, expected)
Beispiel #24
0
    def testStartStopAll_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x49

        start_or_stop = 0x01

        expected = b'\x08\x49\x01\x90\x90\x90\x90\x90'
        msg = ccp._start_stop_all_CRO(CTR, start_or_stop)

        self.assertEqual(msg, expected)
Beispiel #25
0
    def test_parse_Program_CRM(self):
        ccp = CCPLeader(c=None)

        Dnload_CRM = b'\xff\x00\x18\x02\x34\x00\x20\x04'
        parsed = ccp._parse_Command_Return_Message(Dnload_CRM, CCP_DNLOAD)
        expected = {
            'CRC': 'acknowledge / no error',
            'CTR': 0x18,
            'mta_extension': 0x2,
            'mta_address': '0x34002004'
        }
        self.assertEqual(parsed, expected)
Beispiel #26
0
    def test_parse_Short_Upload_CRM(self):
        # uses same function as UPLOAD
        ccp = CCPLeader(c=None)

        Upload_CRM = b'\xff\x00\x24\x4e\xee\xee\xe7\x90'
        parsed = ccp._parse_Command_Return_Message(Upload_CRM, CCP_SHORT_UP)
        expected = {
            'CRC': 'acknowledge / no error',
            'CTR': 0x24,
            'data': '0x4eeeeee7'
        }
        self.assertEqual(parsed, expected)
Beispiel #27
0
    def test_GetSeed_CRO(self):
        ccp = CCPLeader(c=None)

        CTR = 0x35

        requesting_pgm_resource = 0x32

        expected = b'\x12\x35\x32\x90\x90\x90\x90\x90'

        msg = ccp._get_seed_CRO(CTR, requesting_pgm_resource)

        self.assertEqual(msg, expected)
Beispiel #28
0
    def test_parse_ExchangeID_CRM(self):
        ccp = CCPLeader(c=None)

        ExchangeID_CRM = b'\xff\x00\x25\x04\x02\x03\x01\x90'
        parsed = ccp._parse_Command_Return_Message(ExchangeID_CRM,
                                                   CCP_EXCHANGE_ID)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x25, \
                    'follower_deviceID_length': 0x4, \
                    'follower_deviceID_data_type_qual': 0x2, \
                    'resource_availability_mask': 0x3, \
                    'resource_protection_mask': 0x1}
        self.assertEqual(parsed, expected)
Beispiel #29
0
    def test_parse_move_CRM(self):
        ccp = CCPLeader(c=None)

        Move_CRM = b'\xff\x00\x22\x90\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(Move_CRM, CCP_MOVE)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x22}
        self.assertEqual(parsed, expected)

        ClearMemory_CRM_busy = b'\xff\x10\x23\x90\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(ClearMemory_CRM_busy,
                                                   CCP_CLEAR_MEMORY)
        expected = {'CRC': 'command processor busy', 'CTR': 0x23}
        self.assertEqual(parsed, expected)
Beispiel #30
0
    def test_parse_Test_CRM(self):
        ccp = CCPLeader(c=None)

        Test_CRM = b'\xff\x00\x24\x90\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(Test_CRM, CCP_TEST)
        expected = {'CRC': 'acknowledge / no error', 'CTR': 0x24}
        self.assertEqual(parsed, expected)

        Test_CRM_timeout = b'\xff\x12\x25\x90\x90\x90\x90\x90'
        parsed = ccp._parse_Command_Return_Message(Test_CRM_timeout,
                                                   CCP_CLEAR_MEMORY)
        expected = {'CRC': 'internal timeout', 'CTR': 0x25}
        self.assertEqual(parsed, expected)