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: github.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:fbd9e717-45f5-2ec8-64c9-af880e31bf9c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE6C:32F647:127F747:1962ED8:698DAB84 |
| html-safe-nonce | 9c26c3690971b5104d89b8ce2b21b58907055fba964093c8b18f922fa0b3d5be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTZDOjMyRjY0NzoxMjdGNzQ3OjE5NjJFRDg6Njk4REFCODQiLCJ2aXNpdG9yX2lkIjoiNzQyMTAxOTE4ODA1NzY0OTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f5fa463ba4b0bc8b6e4add51800932bfefa3b3b5ce0a734260d7f89ec3b99032 |
| 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 | 8c7947c0c592efeab6162b9909ad11fa43bff8b0cb5ff43273dc25e41979d43e |
| 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 | b22a9fbf4dea601ec149a9e5362e0558df79b505 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width