Telescope Control Library

Dependents:   PushToGo-F429

Revision:
1:a4d5537de7ae
Parent:
0:6cb2eaf8b133
Child:
2:2ee28add0821
--- a/EqMountServer.cpp	Sun Aug 19 05:21:20 2018 +0000
+++ b/EqMountServer.cpp	Sun Aug 19 05:37:52 2018 +0000
@@ -1,13 +1,14 @@
 /*
  * EqMountServer.cpp
  *
- *  Created on: 2018Äê3ÔÂ1ÈÕ
+ *  Created on: 2018��3��1��
  *      Author: caoyuan9642
  */
 
 #include "EqMountServer.h"
 #include "mbed_events.h"
 #include <ctype.h>
+#include <time.h>
 
 #define EMS_DEBUG 0
 
@@ -165,6 +166,7 @@
 		if (cind == -1)
 		{
 			debug_if(EMS_DEBUG, "Error: command %s not found.\n", command);
+			stprintf(stream, "Unknown command\r\n");
 			delete[] buffer;
 			delete[] args;
 			continue;
@@ -838,14 +840,24 @@
 		{
 			t += (int) (remainder(server->getEqMount()->getLocation().lon, 360)
 					* 240);
-			ctime_r(&t, buf);
+					
+			core_util_critical_section_enter();
+			char *ibuf = ctime(&t);
+			strncpy(buf, ibuf, sizeof(buf));
+			core_util_critical_section_exit();
+			
 			stprintf(server->getStream(), "%s %s\r\n", cmd, buf);
 			return 0;
 		}
 		else if (strcmp(argv[0], "zone") == 0)
 		{
 			t += (int) (TelescopeConfiguration::getInt("timezone") * 3600);
-			ctime_r(&t, buf);
+			
+			core_util_critical_section_enter();
+			char *ibuf = ctime(&t);
+			strncpy(buf, ibuf, sizeof(buf));
+			core_util_critical_section_exit();
+			
 			stprintf(server->getStream(), "%s %s\r\n", cmd, buf);
 			return 0;
 		}
@@ -853,7 +865,11 @@
 	}
 
 // Print of formatted string of current time
-	ctime_r(&t, buf);
+	core_util_critical_section_enter();
+	char *ibuf = ctime(&t);
+	strncpy(buf, ibuf, sizeof(buf));
+	core_util_critical_section_exit();
+	
 	stprintf(server->getStream(), "%s %s\r\n", cmd, buf);
 
 	return 0;