summaryrefslogtreecommitdiff
path: root/twn3_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'twn3_test.c')
-rw-r--r--twn3_test.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/twn3_test.c b/twn3_test.c
index 734201e..692cd3a 100644
--- a/twn3_test.c
+++ b/twn3_test.c
@@ -11,6 +11,7 @@
int main(int argc, char** argv){
char data[1024];
unsigned u;
+ uint8_t test_block = 4, test_sector = 1;
int device = twn3_open("/dev/ttyACM3");
@@ -44,7 +45,7 @@ int main(int argc, char** argv){
//store a key
//uint8_t key[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//twn3_sync_storekey(device, 0, 12, key);
-
+
//wait for a single tag
int status;
uint8_t type = tag_none;
@@ -60,6 +61,29 @@ int main(int argc, char** argv){
serial_length = sizeof(serial);
}
+ printf("Authenticating for sector %d\n", test_sector);
+ uint8_t key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+ twn3_sync_auth(device, 0, 1, test_sector, key);
+ printf("\n");
+
+ printf("Reading block %d\n", test_block);
+ twn3_sync_read(device, 0, test_block, (uint8_t*) data, 16);
+ printf("Block %d data: ", test_block);
+ for(u = 0; u < 16; u++){
+ printf("%02x ", data[u]);
+ }
+ printf("\n\n");
+
+ printf("Incrementing all bytes in block %d\n", test_block);
+ for(u = 0; u < 16; u++){
+ data[u]++;
+ }
+
+ printf("Writing block %d\n", test_block);
+ twn3_sync_write(device, 0, test_block, (uint8_t*) data);
+ printf("\n");
+
+
close(device);
return EXIT_SUCCESS;
}