astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header --align-pointer=name

This commit is contained in:
Philippe Teuwen 2012-05-29 15:55:35 +00:00
parent 01303fab0d
commit 568317929d
21 changed files with 94 additions and 94 deletions

View file

@ -85,19 +85,19 @@ target_thread(void *arg)
size_t szRx = sizeof(abtRx);
int res = nfc_target_init(device, &nt, abtRx, sizeof(abtRx), 0);
cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't receive bytes from initiator: %s", nfc_strerror(device)));
szRx = (size_t) res;
const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
return (void *) thread_res;
}
@ -117,7 +117,7 @@ initiator_thread(void *arg)
printf("=========== INITIATOR %s =========\n", nfc_device_get_name(device));
int res = nfc_initiator_init(device);
cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
nfc_target nt;
@ -130,7 +130,7 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_ACTIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP target!";
uint8_t abtRx[1024];
@ -140,10 +140,10 @@ initiator_thread(void *arg)
const uint8_t abtAttRx[] = "Hello DEP initiator!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
return (void *) thread_res;
}

View file

@ -84,7 +84,7 @@ target_thread(void *arg)
size_t szRx = sizeof(abtRx);
int res = nfc_target_init(device, &nt, abtRx, szRx, 0);
cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// First pass
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
@ -93,12 +93,12 @@ target_thread(void *arg)
const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
// Second pass
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
@ -106,11 +106,11 @@ target_thread(void *arg)
szRx = (size_t) res;
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
// Third pass
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
@ -118,11 +118,11 @@ target_thread(void *arg)
szRx = (size_t) res;
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
// Fourth pass
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
@ -130,11 +130,11 @@ target_thread(void *arg)
szRx = (size_t) res;
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
return (void *) thread_res;
}
@ -154,7 +154,7 @@ initiator_thread(void *arg)
int res = nfc_initiator_init(device);
cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
nfc_target nt;
@ -167,7 +167,7 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP target!";
uint8_t abtRx[1024];
@ -177,11 +177,11 @@ initiator_thread(void *arg)
const uint8_t abtAttRx[] = "Hello DEP initiator!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// Passive mode / 212Kbps (second pass)
printf("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_get_name(device));
@ -192,18 +192,18 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
szRx = sizeof(abtRx);
res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 1000);
cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device)));
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// Passive mode / 212Kbps
printf("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_get_name(device));
@ -214,18 +214,18 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
szRx = sizeof(abtRx);
res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 5000);
cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device)));
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// Passive mode / 424Kbps
printf("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name(device));
@ -236,18 +236,18 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
szRx = sizeof(abtRx);
res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 5000);
cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device)));
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
return (void *) thread_res;
}

View file

@ -65,7 +65,7 @@ target_thread(void *arg)
// 1) nfc_target_init should take target in idle mode
int res = nfc_target_init(device, &nt, abtRx, szRx, 500);
cut_assert_operator_int(res, >= , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// 2) act as target
nfc_target nt1 = {
@ -91,7 +91,7 @@ target_thread(void *arg)
sleep(6);
res = nfc_target_init(device, &nt1, abtRx, szRx, 0);
cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't receive bytes from initiator: %s", nfc_strerror(device)));
@ -99,12 +99,12 @@ target_thread(void *arg)
const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
// 3) idle mode
sleep(1);
@ -128,13 +128,13 @@ initiator_thread(void *arg)
int res = nfc_initiator_init(device);
cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// 1) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0
nfc_target nt;
res = nfc_initiator_poll_dep_target(device, NDM_PASSIVE, NBR_106, NULL, &nt, 1000);
cut_assert_equal_int(0, res, cut_message("Problem with nfc_idle"));
if (res != 0) { thread_res = -1; return (void*) thread_res; }
if (res != 0) { thread_res = -1; return (void *) thread_res; }
// 2 As other device should be in target mode, nfc_initiator_poll_dep_target should be positive.
@ -149,7 +149,7 @@ initiator_thread(void *arg)
cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt1.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3"));
cut_assert_equal_int(NDM_PASSIVE, nt1.nti.ndi.ndm, cut_message("Invalid target DEP mode"));
cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt1.nti.ndi.abtGB, nt1.nti.ndi.szGB, cut_message("Invalid target general bytes"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
if (res <= 0) { thread_res = -1; return (void *) thread_res; }
const uint8_t abtTx[] = "Hello DEP target!";
uint8_t abtRx[1024];
@ -159,17 +159,17 @@ initiator_thread(void *arg)
const uint8_t abtAttRx[] = "Hello DEP initiator!";
cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data"));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
res = nfc_initiator_deselect_target(device);
cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; }
if (res < 0) { thread_res = -1; return (void *) thread_res; }
// 3) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0
nfc_target nt2;
res = nfc_initiator_poll_dep_target(device, NDM_PASSIVE, NBR_106, NULL, &nt2, 1000);
cut_assert_equal_int(0, res, cut_message("Problem with nfc_idle"));
if (res != 0) { thread_res = -1; return (void*) thread_res; }
if (res != 0) { thread_res = -1; return (void *) thread_res; }
return (void *) thread_res;
}