We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 98cf695 commit 6f97d80Copy full SHA for 6f97d80
tools/checksum.py
@@ -10,6 +10,7 @@
10
11
import argparse
12
import struct
13
+import sys
14
15
16
def sum_complement(fw, max_size):
@@ -133,6 +134,13 @@ def crc32_checksum(fw, max_size):
133
134
135
args = parser.parse_args()
136
137
+ # argparse doesn't know how to handle "rb" for stdin and gives us TextIO
138
+ # instead of BinaryIO
139
+ if args.fw_file == sys.stdin:
140
+ if sys.stdin.isatty():
141
+ raise RuntimeError("expecting data to be piped via stdin")
142
+ args.fw_file = sys.stdin.buffer
143
+
144
if args.checksum_type == "xor":
145
print(hex(sum_complement(args.fw_file, args.max_size)))
146
elif args.checksum_type == "crc32":
0 commit comments