summaryrefslogtreecommitdiff
path: root/openpicc/application
diff options
context:
space:
mode:
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