Improved the error message when the MCU response is printed.

This commit is contained in:
2024-11-27 15:37:53 +01:00
parent 2dd46cc48d
commit a6227629ad

View File

@ -1,9 +1,10 @@
// Needed to use strcpy_s from string.h
#define __STDC_WANT_LIB_EXT1__ 1
#include "pmacv3Controller.h"
#include "asynMotorController.h"
#include "asynOctetSyncIO.h"
#include "pmacv3Axis.h"
#include <cstring>
#include <epicsExport.h>
#include <errlog.h>
#include <iocsh.h>
@ -19,12 +20,15 @@
* @param src Original string
*/
void adjustResponseForPrint(char *dst, const char *src) {
strcpy(dst, src);
// Needed to use strcpy_s from string.h
#ifdef __STDC_LIB_EXT1__
strcpy_s(dst, src);
for (size_t i = 0; i < strlen(dst); i++) {
if (dst[i] == '\r') {
dst[i] = '_';
}
}
#endif
}
/**
@ -325,7 +329,6 @@ asynStatus pmacv3Controller::writeRead(int axisNo, const char *command,
if (numExpectedResponses != numReceivedResponses) {
adjustResponseForPrint(modResponse, response);
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s => line %d:\nUnexpected response %s (_ are "
"carriage returns) for command %s\n",