Title: Starting Address record line is always the first line, but in original file it was last line · Issue #43 · python-intelhex/intelhex · GitHub
Open Graph Title: Starting Address record line is always the first line, but in original file it was last line · Issue #43 · python-intelhex/intelhex
X Title: Starting Address record line is always the first line, but in original file it was last line · Issue #43 · python-intelhex/intelhex
Description: I am testing this module for some production/testing firmware automation and I am super pleased! I am noticing that when I encode a hex file to a dict with this module, then fetch and re-save to a hex file (the data is stored in a databa...
Open Graph Description: I am testing this module for some production/testing firmware automation and I am super pleased! I am noticing that when I encode a hex file to a dict with this module, then fetch and re-save to a ...
X Description: I am testing this module for some production/testing firmware automation and I am super pleased! I am noticing that when I encode a hex file to a dict with this module, then fetch and re-save to a ...
Opengraph URL: https://github.com/python-intelhex/intelhex/issues/43
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Starting Address record line is always the first line, but in original file it was last line","articleBody":"I am testing this module for some production/testing firmware automation and I am super pleased! \r\nI am noticing that when I encode a hex file to a dict with this module, then fetch and re-save to a hex file (the data is stored in a database as a JSON record) one line gets swapped in the file thus causing my md5 checksums to not match. While I am fairly certain the structure of an intel hex file prevents this from being an issue, it would be nice to under stand how this happens.\r\n\r\nEncode to database:\r\n```\r\nfile_name = file_path.split('/')[-1]\r\nwith open(file_path, 'rb') as file:\r\n md5 = hashlib.md5(\r\n file.read()\r\n ).hexdigest()\r\nintel_hex = IntelHex()\r\nintel_hex.loadhex(file_path)\r\nif image_type.lower() in ['mfg', 'manufacturing']:\r\n self.manufacturing_fw = intel_hex.todict()\r\n self.manufacturing_fw_name = file_name\r\n self.manufacturing_md5 = md5\r\n```\r\n\r\nDecode From database:\r\n```\r\nif image_type.lower() in ['mfg', 'manufacturing']:\r\n output_file_name = f'{out_path}/{self.part_number}-{self.manufacturing_fw_name}'\r\n firmware_data = self.manufacturing_fw\r\n\r\ndata = {}\r\nfor key, value in firmware_data.items():\r\n if key != 'start_addr':\r\n key = int(key)\r\n data[key] = value\r\n\r\nintel_hex = IntelHex()\r\nintel_hex.fromdict(data)\r\nintel_hex.write_hex_file(output_file_name)\r\n```\r\n\r\nI need to add these lines upon export to re-arrange the lines to get the exported file to match the original exactly.\r\nNot efficient or the minimum solution, but it works with everything I have tested so far.\r\n```\r\nfile = open(output_file_name, 'r')\r\nlines = file.readlines()\r\nfile.close()\r\noutput = open(output_file_name, 'w')\r\ntotal_lines = len(lines)\r\nlast_line = lines[-1]\r\nlines.append(lines[-1])\r\nlines[0], lines[total_lines-1] = lines[total_lines-1], lines[0]\r\nlines.append(last_line)\r\nfor line in lines[1:-1]:\r\n output.write(line)\r\noutput.close()\r\n```\r\n\r\nI appreciate any help with this!","author":{"url":"https://github.com/LukeGary462","@type":"Person","name":"LukeGary462"},"datePublished":"2020-07-08T15:15:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/43/intelhex/issues/43"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b21757e-6ef7-f1ec-1fe3-b474c822dbcf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9446:3F2860:49169A:63480B:698D8BC3 |
| html-safe-nonce | 14a44a2f6629cd83b3afc3efde5dc2df95deb2214c1d2285ed3243cd6ca787d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDQ2OjNGMjg2MDo0OTE2OUE6NjM0ODBCOjY5OEQ4QkMzIiwidmlzaXRvcl9pZCI6IjM5ODA4NjE0OTE3MTI0NjE3NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6d1434d0bb2ef0393c1a451648d68e52c202f8ec4b3d653bf75202c640066648 |
| hovercard-subject-tag | issue:653381763 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-intelhex/intelhex/43/issue_layout |
| twitter:image | https://opengraph.githubassets.com/abe8751dc293e3d9458725a0c8fad18fc19a543a9444b3a0898a755cf4a325d9/python-intelhex/intelhex/issues/43 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/abe8751dc293e3d9458725a0c8fad18fc19a543a9444b3a0898a755cf4a325d9/python-intelhex/intelhex/issues/43 |
| og:image:alt | I am testing this module for some production/testing firmware automation and I am super pleased! I am noticing that when I encode a hex file to a dict with this module, then fetch and re-save to a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LukeGary462 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0818105fa276287e9369cfdefa0a0fa7953719791ceff9b94d69623c0a4fe8a |
| turbo-cache-control | no-preview |
| go-import | github.com/python-intelhex/intelhex git https://github.com/python-intelhex/intelhex.git |
| octolytics-dimension-user_id | 55888006 |
| octolytics-dimension-user_login | python-intelhex |
| octolytics-dimension-repository_id | 33128473 |
| octolytics-dimension-repository_nwo | python-intelhex/intelhex |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33128473 |
| octolytics-dimension-repository_network_root_nwo | python-intelhex/intelhex |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bd964b0594af16531b06ac03e14711206a3079aa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width