37 #endif // HAVE_CONFIG_H
39 # define _GNU_SOURCE // for getline on system with glibc < 2.10
40 # define _POSIX_C_SOURCE 200809L // for getline on system with glibc >= 2.10
42 #if defined(HAVE_READLINE)
43 # include <readline/readline.h>
44 # include <readline/history.h>
45 #endif //HAVE_READLINE
59 #define MAX_FRAME_LEN 264
61 int main(
int argc,
const char* argv[])
64 byte_t abtRx[MAX_FRAME_LEN];
65 byte_t abtTx[MAX_FRAME_LEN] = { 0xD4 };
72 if((input=fopen(argv[1],
"r"))==NULL) {
73 ERR (
"%s",
"Cannot open file.");
82 ERR (
"%s",
"Unable to connect to NFC device.");
86 printf (
"Connected to NFC reader: %s\n", pnd->
acName);
93 #if defined(HAVE_READLINE)
103 #endif //HAVE_READLINE
107 printf(
"%s", prompt);
110 ret = fgets(cmd, n, input);
112 ret = fgets(cmd, n, stdin);
114 if (ret == NULL || strlen(cmd) <= 0) {
121 #if defined(HAVE_READLINE)
123 #endif //HAVE_READLINE
132 while (isspace(cmd[offset])) {
135 sscanf(cmd+offset,
"%u", &s);
136 printf(
"Pause for %i secs\n", s);
144 for(
int i = 0; i<MAX_FRAME_LEN-10; i++) {
147 while (isspace(cmd[offset])) {
150 size = sscanf(cmd+offset,
"%2x", (
unsigned int*)&byte);
156 if (cmd[offset+1] == 0) {
168 print_hex((byte_t*)abtTx+1,szTx-1);
170 if (!pn53x_transceive (pnd, abtTx, szTx, abtRx, &szRx)) {
177 print_hex(abtRx, szRx);