- uint64_t blockaddress = param_get64ex(Cmd, 0, 0, 16);
- uint64_t byteaddress = param_get64ex(Cmd, 1, 0, 16);
- uint8_t data = param_get8ex(Cmd,2,0,16);
-
- if ( blockaddress == 0 ) {
- PrintAndLog("Please specify the block address in hex");
- return 1;
- }
-
- PrintAndLog("Please specify the byte address in hex");
- PrintAndLog("Please specify the data in hex (1 byte)");
+ uint8_t block = 0, bytepos = 0, data = 0;
+
+ if ( param_getdec(Cmd, 0, &block) ) return usage_pcf7931_write();
+ if ( param_getdec(Cmd, 1, &bytepos) ) return usage_pcf7931_write();
+
+ if ( (block > 7) || (bytepos > 3) ) return usage_pcf7931_write();