diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2008-02-03 23:51:20 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2008-02-03 23:51:20 +0000 |
commit | 619b96eb49363eff5971b1052c1747bb20351d14 (patch) | |
tree | c5a77eef1ffc2f0c4a56d6148a68d4d65bc76a36 /openpicc/application/cmd.c | |
parent | 90e4bd792d38d08a63b9e0ef72bf4555731b889f (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/cmd.c')
-rw-r--r-- | openpicc/application/cmd.c | 40 |
1 files changed, 28 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); |