Add missing htole32() call in mifare_classic_init_value(). Fix Mifare Classic support on big-endian machines.

This commit is contained in:
Romain Tartiere 2010-03-31 22:46:13 +00:00
parent 73c50a544a
commit aacddc7aae

View file

@ -267,9 +267,11 @@ mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block,
{
union mifare_classic_block b;
b.value.value = value;
b.value.value_ = ~value;
b.value.value__ = value;
uint32_t le_value = htole32 ((uint32_t)value);
b.value.value = le_value;
b.value.value_ = ~le_value;
b.value.value__ = le_value;
b.value.address = adr;
b.value.address_ = ~adr;
@ -349,7 +351,7 @@ mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, c
unsigned char command[6];
command[0] = MC_INCREMENT;
command[1] = block;
int32_t le_amount = htole32 (amount);
uint32_t le_amount = htole32 (amount);
memcpy(&(command[2]), &le_amount, sizeof (le_amount));
// Send command
@ -376,7 +378,7 @@ mifare_classic_decrement (MifareTag tag, const MifareClassicBlockNumber block, c
unsigned char command[6];
command[0] = MC_DECREMENT;
command[1] = block;
int32_t le_amount = htole32 (amount);
uint32_t le_amount = htole32 (amount);
memcpy(&(command[2]), &le_amount, sizeof (le_amount));
// Send command