How to use the udsoncan.DataFormatIdentifier function in udsoncan

To help you get started, we’ve selected a few udsoncan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylessard / python-udsoncan / test / client / test_request_download.py View on Github external
def _test_request_download_success_dfi(self):
        memloc = MemoryLocation(address=0x1234, memorysize=0xFF, address_format=16, memorysize_format=8)
        dfi  =DataFormatIdentifier(compression=5, encryption=2)
        response = self.udsclient.request_download(memory_location=memloc, dfi=dfi)
        self.assertEqual(response.service_data.max_length,0xabcd)
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_read_file_bad_moop_echo(self):
        with self.assertRaises(UnexpectedResponseException):
            self.udsclient.read_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2))
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_read_file_bad_dfi(self):
        with self.assertRaises(UnexpectedResponseException):
            self.udsclient.read_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2))
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_add_file_bad_dfi(self):
        with self.assertRaises(UnexpectedResponseException):
            self.udsclient.add_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2), filesize = 0x100)
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_replace_file_extra_bytes_response_zero_padding_ok(self):
        self.udsclient.config['tolerate_zero_padding'] = True
        response = self.udsclient.replace_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2), filesize = Filesize(uncompressed=0x222, compressed=0x111, width=4))              
        self.assertTrue(response.valid)
        self.assertTrue(response.positive)
        self.assertEqual(response.service_data.moop_echo, 3)
        self.assertEqual(response.service_data.max_length, 0xabcd)
        self.assertEqual(response.service_data.dfi.compression, 5)
        self.assertEqual(response.service_data.dfi.encryption, 2)
        self.assertIsNone(response.service_data.filesize)     # No filesize info when doing AddFile. Only for ReadFile
        self.assertIsNone(response.service_data.dirinfo_length)
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_replace_file_negative_response_no_exception(self):
        self.udsclient.config['exception_on_negative_response'] = False
        response = self.udsclient.replace_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2), filesize = Filesize(uncompressed=0x222, compressed=0x111, width=4))
        self.assertTrue(response.valid)
        self.assertFalse(response.positive)
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_read_file_extra_bytes_response(self):
        with self.assertRaises(InvalidResponseException):
            self.udsclient.read_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2))
github pylessard / python-udsoncan / test / client / test_request_file_transfer.py View on Github external
def _test_read_file_extra_bytes_response_zero_padding_ok(self):
        self.udsclient.config['tolerate_zero_padding'] = True
        response = self.udsclient.read_file("my_file.txt", dfi= DataFormatIdentifier(compression=5, encryption=2))
        self.assertTrue(response.valid)
        self.assertTrue(response.positive)
        self.assertEqual(response.service_data.moop_echo, 4)
        self.assertEqual(response.service_data.max_length, 0xabcd)
        self.assertEqual(response.service_data.dfi.compression, 5)
        self.assertEqual(response.service_data.dfi.encryption, 2)
        self.assertEqual(response.service_data.filesize.uncompressed, 0x9876)
        self.assertEqual(response.service_data.filesize.compressed, 0x1234)
        self.assertIsNone(response.service_data.dirinfo_length)
github pylessard / python-udsoncan / udsoncan / services.py View on Github external
def __init__(self, memory_location, dfi=None):
		from udsoncan import DataFormatIdentifier, MemoryLocation

		if dfi is None:
			dfi = DataFormatIdentifier()

		if not isinstance(memory_location, MemoryLocation):
			raise ValueError('memory_location must be an instance of MemoryLocation')

		if not isinstance(dfi, DataFormatIdentifier):
			raise ValueError('dfi must be an instance of DataFormatIdentifier')

		self.memory_location = memory_location
		self.dfi = dfi