summaryrefslogtreecommitdiff
path: root/openpicc/application
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-02-03 23:51:20 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-02-03 23:51:20 +0000
commit619b96eb49363eff5971b1052c1747bb20351d14 (patch)
treec5a77eef1ffc2f0c4a56d6148a68d4d65bc76a36 /openpicc/application
parent90e4bd792d38d08a63b9e0ef72bf4555731b889f (diff)
Factor out time print code and enhance it
git-svn-id: https://svn.openpcd.org:2342/trunk@404 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application')
-rw-r--r--openpicc/application/cmd.c40
-rw-r--r--openpicc/application/cmd.h1
2 files changed, 29 insertions, 12 deletions
diff --git a/openpicc/application/cmd.c b/openpicc/application/cmd.c
index ac1d605..5fe143b 100644
--- a/openpicc/application/cmd.c
+++ b/openpicc/application/cmd.c
@@ -87,6 +87,31 @@ void DumpBufferToUSB(char* buffer, int len)
}
/**********************************************************************/
+void DumpTimeToUSB(long ticks)
+{
+ int h, s, m, ms;
+ ms = ticks;
+
+ s=ms/1000;
+ ms%=1000;
+ h=s/3600;
+ s%=3600;
+ m=s/60;
+ s%=60;
+ DumpUIntToUSB(h);
+ DumpStringToUSB("h:");
+ if(m < 10) DumpStringToUSB("0");
+ DumpUIntToUSB(m);
+ DumpStringToUSB("m:");
+ if(s < 10) DumpStringToUSB("0");
+ DumpUIntToUSB(s);
+ DumpStringToUSB("s.");
+ if(ms < 10) DumpStringToUSB("0");
+ if(ms < 100) DumpStringToUSB("0");
+ DumpUIntToUSB(ms);
+ DumpStringToUSB("ms");
+}
+
/*
* Convert a string to an integer. Ignores leading spaces.
* Optionally returns a pointer to the end of the number in the string */
@@ -145,7 +170,7 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) {
static int led = 0;
portCHAR cByte = cmd & 0xff;
portLONG j;
- int i,h,m,s;
+ int i,ms;
if(cByte>='A' && cByte<='Z')
cByte-=('A'-'a');
@@ -242,17 +267,8 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) {
" * compiled " COMPILE_DATE " by " COMPILE_BY "\n\r"
" *\n\r");
DumpStringToUSB(" * Uptime is ");
- s=xTaskGetTickCount()/1000;
- h=s/3600;
- s%=3600;
- m=s/60;
- s%=60;
- DumpUIntToUSB(h);
- DumpStringToUSB("h:");
- DumpUIntToUSB(m);
- DumpStringToUSB("m:");
- DumpUIntToUSB(s);
- DumpStringToUSB("s");
+ ms=xTaskGetTickCount();
+ DumpTimeToUSB(ms);
DumpStringToUSB("\n\r");
DumpStringToUSB(" * The reader id is ");
DumpUIntToUSB(env.e.reader_id);
diff --git a/openpicc/application/cmd.h b/openpicc/application/cmd.h
index 0033b58..a93d8f0 100644
--- a/openpicc/application/cmd.h
+++ b/openpicc/application/cmd.h
@@ -14,6 +14,7 @@ portBASE_TYPE vCmdInit(void);
extern void DumpUIntToUSB(unsigned int data);
extern void DumpStringToUSB(char *string);
extern void DumpBufferToUSB(char* buffer, int len);
+extern void DumpTimeToUSB(long ticks);
extern xQueueHandle xCmdQueue;
#endif /*CMD_H_*/
personal git repositories of Harald Welte. Your mileage may vary