#include #include #include #include "libtwn3.h" #include #include int main(int argc, char** argv){ char data[1024]; unsigned u; int device = twn3_open("/dev/ttyACM0"); printf("Device is at fd %d\n", device); if(device < 0){ printf("%s\n", strerror(errno)); return EXIT_FAILURE; } //check version if(twn3_sync_read_version(device, 0, data, sizeof(data)) >= 0){ printf("Connected reader firmware version: %s\n", data); } //read eeprom for(u = 0; u < 0x15; u++){ uint8_t regdata = 0; twn3_sync_read_eeprom(device, 0, u, ®data); printf("Register %d has data %02X\n", u, regdata); } //write some userdata twn3_sync_write_eeprom(device, 0, 19, 0xAA); //set ExtendID bit //twn3_sync_write_eeprom(device, 0, 5, 0x05); //restart device //twn3_sync_restart(device, 0); //store a key uint8_t key[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; twn3_sync_storekey(device, 0, 12, key); close(device); return EXIT_SUCCESS; }