Added motorConnected logic
This commit is contained in:
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ REQUIRED+=sinqMotor
|
|||||||
motorBase_VERSION=7.2.2
|
motorBase_VERSION=7.2.2
|
||||||
|
|
||||||
# Specify the version of sinqMotor we want to build against
|
# Specify the version of sinqMotor we want to build against
|
||||||
sinqMotor_VERSION=mathis_s
|
sinqMotor_VERSION=0.14.0
|
||||||
|
|
||||||
# These headers allow to depend on this library for derived drivers.
|
# These headers allow to depend on this library for derived drivers.
|
||||||
HEADERS += src/masterMacsAxis.h
|
HEADERS += src/masterMacsAxis.h
|
||||||
|
@ -305,12 +305,21 @@ asynStatus masterMacsController::parseResponse(
|
|||||||
|
|
||||||
bool responseValid = false;
|
bool responseValid = false;
|
||||||
int responseStart = 0;
|
int responseStart = 0;
|
||||||
|
asynStatus status = asynSuccess;
|
||||||
|
int prevConnected = 0;
|
||||||
char printableCommand[MAXBUF_] = {0};
|
char printableCommand[MAXBUF_] = {0};
|
||||||
char printableResponse[MAXBUF_] = {0};
|
char printableResponse[MAXBUF_] = {0};
|
||||||
|
|
||||||
msgPrintControlKey parseKey =
|
msgPrintControlKey parseKey =
|
||||||
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
// Was the motor previously connected?
|
||||||
|
status = getIntegerParam(axisNo, motorConnected(), &prevConnected);
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
return paramLibAccessFailed(status, "motorConnected", axisNo,
|
||||||
|
__PRETTY_FUNCTION__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
// We don't use strlen here since the C string terminator 0x00
|
// We don't use strlen here since the C string terminator 0x00
|
||||||
// occurs in the middle of the char array.
|
// occurs in the middle of the char array.
|
||||||
for (uint32_t i = 0; i < MAXBUF_; i++) {
|
for (uint32_t i = 0; i < MAXBUF_; i++) {
|
||||||
@ -319,20 +328,75 @@ asynStatus masterMacsController::parseResponse(
|
|||||||
} else if (fullResponse[i] == '=') {
|
} else if (fullResponse[i] == '=') {
|
||||||
*valueStart = i + 1;
|
*valueStart = i + 1;
|
||||||
} else if (fullResponse[i] == '\x06') {
|
} else if (fullResponse[i] == '\x06') {
|
||||||
|
// ACK
|
||||||
*valueStop = i;
|
*valueStop = i;
|
||||||
responseValid = true;
|
responseValid = true;
|
||||||
break;
|
|
||||||
} else if (fullResponse[i] == '\x15') {
|
|
||||||
// NAK
|
|
||||||
snprintf(drvMessageText, MAXBUF_, "Communication failed.");
|
|
||||||
|
|
||||||
if (msgPrintControl_.shouldBePrinted(parseKey, true,
|
// Motor wasn't connected before -> Update the paramLib entry and PV
|
||||||
pasynUserSelf)) {
|
// to show it is now connected.
|
||||||
|
if (prevConnected == 0) {
|
||||||
|
|
||||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||||
"Controller \"%s\", axis %d => %s, line "
|
"Controller \"%s\", axis %d => %s, line "
|
||||||
"%d:\nCommunication failed.%s\n",
|
"%d:\nAxis connection status has changed to "
|
||||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
|
"connected.\n",
|
||||||
msgPrintControl_.getSuffix());
|
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
masterMacsAxis *axis = getMasterMacsAxis(axisNo);
|
||||||
|
if (axis == nullptr) {
|
||||||
|
return asynError;
|
||||||
|
}
|
||||||
|
status = axis->setIntegerParam(motorConnected(), 1);
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
return paramLibAccessFailed(status, "motorConnected",
|
||||||
|
axisNo, __PRETTY_FUNCTION__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
status = callParamCallbacks();
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||||
|
"Controller \"%s\", axis %d => %s, line "
|
||||||
|
"%d:\nCould not update parameter library\n",
|
||||||
|
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
} else if (fullResponse[i] == '\x15') {
|
||||||
|
/*
|
||||||
|
NAK
|
||||||
|
This indicates that the axis is not connected. This is not an error!
|
||||||
|
*/
|
||||||
|
snprintf(drvMessageText, MAXBUF_, "Axis not connected.");
|
||||||
|
|
||||||
|
// Motor was connected before -> Update the paramLib entry and PV
|
||||||
|
// to show it is now disconnected.
|
||||||
|
if (prevConnected == 1) {
|
||||||
|
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||||
|
"Controller \"%s\", axis %d => %s, line "
|
||||||
|
"%d:\nAxis connection status has changed to "
|
||||||
|
"disconnected.\n",
|
||||||
|
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
masterMacsAxis *axis = getMasterMacsAxis(axisNo);
|
||||||
|
if (axis == nullptr) {
|
||||||
|
return asynError;
|
||||||
|
}
|
||||||
|
status = axis->setIntegerParam(motorConnected(), 0);
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
return paramLibAccessFailed(status, "motorConnected",
|
||||||
|
axisNo, __PRETTY_FUNCTION__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
status = callParamCallbacks();
|
||||||
|
if (status != asynSuccess) {
|
||||||
|
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||||
|
"Controller \"%s\", axis %d => %s, line "
|
||||||
|
"%d:\nCould not update parameter library\n",
|
||||||
|
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (fullResponse[i] == '\x18') {
|
} else if (fullResponse[i] == '\x18') {
|
||||||
|
Reference in New Issue
Block a user