diff options
author | cbdev <cb@cbcdn.com> | 2023-08-24 20:13:51 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2023-08-24 20:13:51 +0200 |
commit | 12cf1472f159b5aaf26d871d88f684f1f46cf856 (patch) | |
tree | b8d6acfb4fcddc1e6e4e7452c80a906d4fea7b7d /twn3_test.c | |
parent | dac4c23269dd62547bb14ea3274a21ac759915d5 (diff) | |
download | libtwn-12cf1472f159b5aaf26d871d88f684f1f46cf856.tar.gz libtwn-12cf1472f159b5aaf26d871d88f684f1f46cf856.tar.bz2 libtwn-12cf1472f159b5aaf26d871d88f684f1f46cf856.zip |
Implement single-tag select
Diffstat (limited to 'twn3_test.c')
-rw-r--r-- | twn3_test.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/twn3_test.c b/twn3_test.c index ca10574..734201e 100644 --- a/twn3_test.c +++ b/twn3_test.c @@ -12,8 +12,8 @@ int main(int argc, char** argv){ char data[1024]; unsigned u; - int device = twn3_open("/dev/ttyACM0"); - + int device = twn3_open("/dev/ttyACM3"); + printf("Device is at fd %d\n", device); if(device < 0){ printf("%s\n", strerror(errno)); @@ -33,7 +33,7 @@ int main(int argc, char** argv){ } //write some userdata - twn3_sync_write_eeprom(device, 0, 19, 0xAA); + //twn3_sync_write_eeprom(device, 0, 19, 0xAA); //set ExtendID bit //twn3_sync_write_eeprom(device, 0, 5, 0x05); @@ -42,8 +42,23 @@ int main(int argc, char** argv){ //twn3_sync_restart(device, 0); //store a key - uint8_t key[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - twn3_sync_storekey(device, 0, 12, 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; + uint8_t serial[20]; + size_t serial_length = sizeof(serial); + for(status = twn3_sync_select_first(device, 0, &type, serial, &serial_length); + status == 0; + status = twn3_sync_select_first(device, 0, &type, serial, &serial_length)){ + if(type != tag_none){ + printf("Tag with UID length %lu found, type %02X\n", serial_length, type); + break; + } + serial_length = sizeof(serial); + } close(device); return EXIT_SUCCESS; |