Fork of the offical HSP_RPC_GUI firmware

Dependencies:   USBDevice

Fork of MAXREFDES100 firmware for MAX32620HSP

Revision:
1:9490836294ea
Parent:
0:e4a10ed6eb92
Child:
3:8e9b9f5818aa
--- a/HSP/RpcServer/RpcServer.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/RpcServer/RpcServer.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -49,7 +49,7 @@
 #include "Device_Logging.h"
 
 /// define the version string that is reported with a RPC "ReadVer" command
-#define FW_VERSION_STRING "HSP FW Version 3.0.0 10/14/16"
+#define FW_VERSION_STRING "HSP FW Version 3.0.1 4/21/16"
 
 char args[32][32];
 char results[32][32];
@@ -94,7 +94,7 @@
 
 //******************************************************************************
 int System_SystemCoreClock(char argStrs[32][32], char replyStrs[32][32]) {
-  sprintf(replyStrs[0], "SystemCoreClock = %d", SystemCoreClock);
+  sprintf(replyStrs[0], "SystemCoreClock = %d", (unsigned int)SystemCoreClock);
   strcpy(replyStrs[1], "\0");
   return 0;
 }
@@ -283,7 +283,7 @@
 }
 
 //******************************************************************************
-int CheckForDoubleQuote(char *str) {
+int CheckForDoubleQuote(const char *str) {
   int doubleQuoteFound;
   // scan through arguments, see if there is a double quote for a string
   // argument
@@ -299,7 +299,7 @@
 }
 
 //******************************************************************************
-void ExtractDoubleQuoteStr(char *src, char *dst) {
+void ExtractDoubleQuoteStr(const char *src, char *dst) {
   int start;
 
   dst[0] = 0;
@@ -328,7 +328,7 @@
 void RPC_call_test(void) {
   int doubleQuoteFound;
   char doubleQuoteStr[64];
-  char *request = "/Logging/AppendMissionCmd \"BMP280 InitStart 1\"";
+  const char *request = "/Logging/AppendMissionCmd \"BMP280 InitStart 1\"";
 
   // scan through arguments, see if there is a double quote for a string
   // argument
@@ -351,6 +351,7 @@
   int resultIndex;
   int doubleQuoteFound;
   struct RPC_registeredProcedure *procedurePtr;
+  int callResult;
 
   // clear out the reply
   reply[0] = 0;
@@ -410,10 +411,11 @@
     strcpy(objectName, MAX30001_NAME);
   }
 
+  callResult = 0;
   procedurePtr = RPC_lookup(objectName, methodName);
   if (procedurePtr != NULL) {
     // printf("RPC_call: %s processing\n",requestCpy);
-    procedurePtr->func(args, results);
+    callResult = procedurePtr->func(args, results);
   } else {
     printf("RPC_call: %s not found\n", requestCpy);
     // printf("Unable to lookup %s %s", objectName, methodName);
@@ -422,11 +424,13 @@
   // loop while (if) there are results to return
   resultIndex = 0;
   strcpy(reply, "\0");
-  while (results[resultIndex][0] != '\0') {
-    strcat(reply, results[resultIndex++]);
-    strcat(reply, " ");
+  if (callResult != RPC_SKIP_CRLF) { 
+    while (results[resultIndex][0] != '\0') {
+      strcat(reply, results[resultIndex++]);
+      strcat(reply, " ");
+    }
+    strcat(reply, "\r\n");
   }
-  strcat(reply, "\r\n");
 }
 
 //******************************************************************************