diff --git a/.gitignore b/.gitignore index 90e9858f8..9c42779fa 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ tools/jtag_openocd/openocd_configuration tools/mfd_aes_brute/mfd_aes_brute tools/mfd_aes_brute/mfd_multi_brute tools/mfd_aes_brute/brute_key +!tools/lena.bmp fpga/__build* diff --git a/client/src/cmdhfwaveshare.c b/client/src/cmdhfwaveshare.c index 2f4c835b4..f3906bed2 100644 --- a/client/src/cmdhfwaveshare.c +++ b/client/src/cmdhfwaveshare.c @@ -618,6 +618,10 @@ static int CmdHF14AWSLoad(const char *Cmd) { PrintAndLogEx(WARNING, "Unknown model"); return PM3_EINVARG; } + if (!g_session.pm3_present && !outfilelen) { + PrintAndLogEx(WARNING, "Offline - can only perform image conversion"); + return PM3_ENOTTY; + } bool model_has_red = model_nr == M1in54B || model_nr == M2in13B; @@ -653,8 +657,16 @@ static int CmdHF14AWSLoad(const char *Cmd) { return PM3_EMALLOC; } - if (outfilelen && !gdImageFile(pal_img, outfile)) { - PrintAndLogEx(WARNING, "Could not save converted image"); + if (outfilelen) { + if (gdImageFile(pal_img, outfile)) { + PrintAndLogEx(INFO, "Save converted image to " _YELLOW_("%s"), outfile); + gdImageDestroy(pal_img); + return PM3_SUCCESS; + } else { + PrintAndLogEx(WARNING, "Could not save converted image", outfile); + gdImageDestroy(pal_img); + return PM3_EFILE; + } } uint8_t * black_plane = map8to1(pal_img, 1); @@ -684,7 +696,7 @@ static int CmdHF14AWSLoad(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"load", CmdHF14AWSLoad, IfPm3Iso14443a, "Load image file to Waveshare NFC ePaper"}, + {"load", CmdHF14AWSLoad, AlwaysAvailable, "Load image file to Waveshare NFC ePaper"}, {NULL, NULL, NULL, NULL} }; diff --git a/tools/lena.bmp b/tools/lena.bmp new file mode 100644 index 000000000..d03cf8509 Binary files /dev/null and b/tools/lena.bmp differ diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index e56ce5d25..2e32b39bb 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -535,6 +535,7 @@ while true; do if ! CheckExecute "emv test" "$CLIENTBIN -c 'emv test'" "Test\(s\) \[ ok"; then break; fi if ! CheckExecute "hf cipurse test" "$CLIENTBIN -c 'hf cipurse test'" "Tests \[ ok"; then break; fi if ! CheckExecute "hf mfdes test" "$CLIENTBIN -c 'hf mfdes test'" "Tests \[ ok"; then break; fi + if ! CheckExecute "hf waveshare load" "$CLIENTBIN -c 'hf waveshare load -m 6 -f tools/lena.bmp -s dither.bmp' && echo '9cee7dcc285f59f88c7cbc9de1dc02b4 dither.bmp' | md5sum -c" "dither.bmp: OK"; then break; fi fi echo -e "\n------------------------------------------------------------" echo -e "Tests [ ${C_GREEN}OK${C_NC} ] ${C_OK}\n"