Commit 741d63c2 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

check for empty target image

parent 1d7bb7bf
......@@ -106,6 +106,11 @@ def main(argv):
logger.warning("Wrong API usage")
# Check file size
if os.path.getsize(imagepath) == 0:
logger.error("Invalid file size")
# Just basic checking for Intel HEX files ---
if "hex" in os.path.splitext(imagepath)[1].lower() or flocklab.is_hex_file(imagepath) == True:
logger.debug("Hex file detected.")
......@@ -454,9 +454,14 @@ def main(argv):
obsiddict[obsid][core] = platform
# Get the image and save it to a temporary file:
image = imageconf[0].xpath('d:data', namespaces=ns)[0].text
# For target platform DPP2LoRa, the <data> tag may be empty
if len(image.strip()) == 0 and (platform.lower() == "dpp2lora" or platform.lower() == "dpp2lorahg"):
if len(image.strip()) == 0:
# For target platform DPP2LoRa, the <data> tag may be empty (such that the user only has to provide an image for either dpp2lora or dpp2lorahg when using both targets in one test)
if (platform.lower() == "dpp2lora" or platform.lower() == "dpp2lorahg"):
continue # skip image validation
if not quiet:
print(("Line %d: element data is empty." % line))
errcnt = errcnt + 1
image_line = imageconf[0].xpath('d:data', namespaces=ns)[0].sourceline
(fd, imagefilename) = tempfile.mkstemp()
imagefile = os.fdopen(fd, 'w+b')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment