From b1905c82e21ca2f9ab1748116275a495b67762ca Mon Sep 17 00:00:00 2001 From: MarkRivers Date: Fri, 2 Mar 2012 18:52:24 +0000 Subject: [PATCH] Added new convenience functions for communicating with controllers over asynOctet ports --- motorApp/MotorSrc/asynMotorController.cpp | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/motorApp/MotorSrc/asynMotorController.cpp b/motorApp/MotorSrc/asynMotorController.cpp index 20b63451..00b3ab60 100644 --- a/motorApp/MotorSrc/asynMotorController.cpp +++ b/motorApp/MotorSrc/asynMotorController.cpp @@ -13,6 +13,7 @@ #include #include +#include #define epicsExportSharedSymbols #include #include "asynMotorController.h" @@ -651,6 +652,59 @@ void asynMotorController::asynMotorMoveToHome() } +/** Writes a string to the controller. + * Calls writeController() with a default location of the string to write and a default timeout. */ +asynStatus asynMotorController::writeController() +{ + return writeController(outString_, DEFAULT_CONTROLLER_TIMEOUT); +} + +/** Writes a string to the controller. + * \param[in] output The string to be written. + * \param[in] timeout Timeout before returning an error.*/ +asynStatus asynMotorController::writeController(const char *output, double timeout) +{ + size_t nwrite; + asynStatus status; + // const char *functionName="writeController"; + + status = pasynOctetSyncIO->write(pasynUserController_, output, + strlen(output), timeout, &nwrite); + + return status ; +} + +/** Writes a string to the controller and reads the response. + * Calls writeReadController() with default locations of the input and output strings + * and default timeout. */ +asynStatus asynMotorController::writeReadController() +{ + size_t nread; + return writeReadController(outString_, inString_, sizeof(inString_), &nread, DEFAULT_CONTROLLER_TIMEOUT); +} + +/** Writes a string to the controller and reads a response. + * \param[in] output Pointer to the output string. + * \param[out] input Pointer to the input string location. + * \param[in] maxChars Size of the input buffer. + * \param[out] nread Number of characters read. + * \param[out] timeout Timeout before returning an error.*/ +asynStatus asynMotorController::writeReadController(const char *output, char *input, + size_t maxChars, size_t *nread, double timeout) +{ + size_t nwrite; + asynStatus status; + int eomReason; + // const char *functionName="writeReadController"; + + status = pasynOctetSyncIO->writeRead(pasynUserController_, output, + strlen(output), input, maxChars, timeout, + &nwrite, nread, &eomReason); + + return status; +} + + /* These are the functions for profile moves */ /** Initialize a profile move of multiple axes. */