Allow image conversion when offline

This commit is contained in:
Marcos Del Sol Vives 2024-01-07 18:05:48 +01:00
parent 572bdbf727
commit d27669f22c
No known key found for this signature in database
4 changed files with 17 additions and 3 deletions

1
.gitignore vendored
View file

@ -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*

View file

@ -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}
};

BIN
tools/lena.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View file

@ -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"