From 5df49391a9fbb49fe60815a2dc55289b9394f348 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 18 Feb 2011 22:05:36 +0000 Subject: [PATCH] pn53x-tamashell: add pause command & doc --- examples/pn53x-tamashell.1 | 10 +++++++++- examples/pn53x-tamashell.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/examples/pn53x-tamashell.1 b/examples/pn53x-tamashell.1 index 328b1e7..3607e05 100644 --- a/examples/pn53x-tamashell.1 +++ b/examples/pn53x-tamashell.1 @@ -15,6 +15,14 @@ TAMA commands and responses prefixes (0xD4/0xD5), CRC and any framing above are You can use the shell interactively (with readline support) or you can write your own script file consisting in commands and comments (anything that starts with ";", "#" or "//"). +Spaces are ignored and can be used for readability. + +Shebang is supported, simply start your script with: + #!/usr/bin/env \fBpn53x-tamashell\fP + +.SH COMMANDS + +\fIp N\fP to introduce a pause of N seconds. \fIq\fP or \fICtrl-d\fP to quit. @@ -35,7 +43,7 @@ GetFirmware command is D4 02, so one has just to send the command "02": Same thing, with a script: - $ cat << EOF | \fBpn53x-tamashell\fP + $ \fBpn53x-tamashell\fP << EOF // This is a comment 02 // GetFirmware 40 // Command with missing arguments diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 3d76fe8..ef89ee5 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -126,6 +126,20 @@ int main(int argc, const char* argv[]) free(cmd); break; } + if (cmd[0]=='p') { + int s=0; + offset++; + while (isspace(cmd[offset])) { + offset++; + } + sscanf(cmd+offset, "%u", &s); + printf("Pause for %i secs\n", s); + if (s>0) { + sleep(s); + } + free(cmd); + continue; + } szTx = 0; for(int i = 0; i