From 9af158435a4eda4918973802bf7c83cf279d2387 Mon Sep 17 00:00:00 2001 From: Ron Sluiter Date: Fri, 16 Jul 2004 19:24:38 +0000 Subject: [PATCH] Converted from MPF to asyn. --- motorApp/MicosSrc/Makefile | 2 +- motorApp/MicosSrc/MicosRegister.cc | 15 +++++------- motorApp/MicosSrc/drvMicos.cc | 37 +++++++++++++++--------------- motorApp/MicosSrc/drvMicos.h | 11 +++++---- motorApp/MicroMoSrc/Makefile | 2 +- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/motorApp/MicosSrc/Makefile b/motorApp/MicosSrc/Makefile index beff6dc4..d5ea0401 100644 --- a/motorApp/MicosSrc/Makefile +++ b/motorApp/MicosSrc/Makefile @@ -13,7 +13,7 @@ LIBRARY_IOC = Micos SRCS += MicosRegister.cc SRCS += devMicos.cc drvMicos.cc -Micos_LIBS += motor motorCOM_mpf +Micos_LIBS += motor asyn Micos_LIBS += $(EPICS_BASE_IOC_LIBS) include $(TOP)/configure/RULES diff --git a/motorApp/MicosSrc/MicosRegister.cc b/motorApp/MicosSrc/MicosRegister.cc index a83b1b2f..798ac68a 100644 --- a/motorApp/MicosSrc/MicosRegister.cc +++ b/motorApp/MicosSrc/MicosRegister.cc @@ -2,9 +2,9 @@ FILENAME... MicosRegister.cc USAGE... Register Micos MoCo dc motor controller device driver shell commands. -Version: $Revision: 1.1 $ +Version: $Revision: 1.2 $ Modified By: $Author: sluiter $ -Last Modified: $Date: 2004-02-13 18:21:19 $ +Last Modified: $Date: 2004-07-16 19:22:58 $ */ /***************************************************************** @@ -36,17 +36,14 @@ static const iocshArg setupArg1 = {"Max. motor count", iocshArgInt}; static const iocshArg setupArg2 = {"Polling rate", iocshArgInt}; // Micos Config arguments static const iocshArg configArg0 = {"Card being configured", iocshArgInt}; -static const iocshArg configArg1 = {"MPF server location", iocshArgInt}; -static const iocshArg configArg2 = {"MPF server task name", iocshArgString}; - +static const iocshArg configArg1 = {"asyn port name", iocshArgString}; static const iocshArg * const MicosSetupArgs[3] = {&setupArg0, &setupArg1, &setupArg2}; -static const iocshArg * const MicosConfigArgs[3] = {&configArg0, &configArg1, - &configArg2}; +static const iocshArg * const MicosConfigArgs[2] = {&configArg0, &configArg1}; static const iocshFuncDef setupMicos = {"MicosSetup", 3, MicosSetupArgs}; -static const iocshFuncDef configMicos = {"MicosConfig", 3, MicosConfigArgs}; +static const iocshFuncDef configMicos = {"MicosConfig", 2, MicosConfigArgs}; static void setupMicosCallFunc(const iocshArgBuf *args) { @@ -56,7 +53,7 @@ static void setupMicosCallFunc(const iocshArgBuf *args) static void configMicosCallFunc(const iocshArgBuf *args) { - MicosConfig(args[0].ival, args[1].ival, args[2].sval); + MicosConfig(args[0].ival, args[1].sval); } diff --git a/motorApp/MicosSrc/drvMicos.cc b/motorApp/MicosSrc/drvMicos.cc index 25ce9f3c..b4ec2f54 100644 --- a/motorApp/MicosSrc/drvMicos.cc +++ b/motorApp/MicosSrc/drvMicos.cc @@ -11,6 +11,7 @@ * .01 02-06-2004 rls Eliminate erroneous "Motor motion timeout ERROR". * .02 02-12-2004 rls Copied from drvMicos.c. Upgraded from R3.14.x * .03 02-17-2004 rls Removed Debug calls to tickGet(). + * .04 07-12-2004 rls Converted from MPF to asyn. */ @@ -19,12 +20,11 @@ #include #include "motor.h" #include "drvMicos.h" -#include "serialIO.h" #include "epicsExport.h" #define WAIT 1 -#define SERIAL_TIMEOUT 2000 /* Command timeout in msec */ +#define COMM_TIMEOUT 2 /* Command timeout in seconds. */ #define BUFF_SIZE 100 /* Maximum length of string to/from Micos */ @@ -308,10 +308,9 @@ static RTN_STATUS send_mess(int card, const char *com, char c) strcpy(buff, com); strcat(buff, OUTPUT_TERMINATOR); - Debug(2, "send_mess: sending message to card %d, message=%s\n", - card, buff); + Debug(2, "send_mess: sending message to card %d, message=%s\n", card, buff); cntrl = (struct MicosController *) motor_state[card]->DevicePrivate; - cntrl->serialInfo->serialIOSend(buff, strlen(buff), SERIAL_TIMEOUT); + pasynSyncIO->write(cntrl->pasynUser, buff, strlen(buff), COMM_TIMEOUT); return (OK); } @@ -324,6 +323,7 @@ static RTN_STATUS send_mess(int card, const char *com, char c) static int recv_mess(int card, char *com, int flag) { int timeout; + int flush = 0; int len=0; struct MicosController *cntrl; @@ -340,8 +340,10 @@ static int recv_mess(int card, char *com, int flag) if (flag == FLUSH) timeout = 0; else - timeout = SERIAL_TIMEOUT; - len = cntrl->serialInfo->serialIORecv(com, BUFF_SIZE, (char *) "\3", timeout); + timeout = COMM_TIMEOUT; + + len = pasynSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, (char *) "\3", + 1, flush, timeout); /* The response from the Micos is terminated with . Remove */ if (len < 3) com[0] = '\0'; @@ -409,9 +411,8 @@ MicosSetup(int num_cards, /* maximum number of "controllers" in system */ /* MicosConfig() */ /*****************************************************/ RTN_STATUS -MicosConfig(int card, /* "controller" being configured */ - int location, /* MPF server location */ - const char *name) /* MPF server task name */ +MicosConfig(int card, /* "controller" being configured */ + const char *name) /* asyn server task name */ { struct MicosController *cntrl; @@ -420,9 +421,9 @@ MicosConfig(int card, /* "controller" being configured */ motor_state[card] = (struct controller *) malloc(sizeof(struct controller)); motor_state[card]->DevicePrivate = malloc(sizeof(struct MicosController)); + cntrl = (struct MicosController *) motor_state[card]->DevicePrivate; - cntrl->serial_card = location; - strcpy(cntrl->serial_task, name); + strcpy(cntrl->asyn_port, name); return(OK); } @@ -442,7 +443,8 @@ static int motor_init() char buff[BUFF_SIZE]; int total_axis = 0; int status = 0; - bool errind, success_rtn; + bool errind; + asynStatus success_rtn; initialized = true; /* Indicate that driver is initialized. */ @@ -465,12 +467,9 @@ static int motor_init() /* Initialize communications channel */ errind = false; - - success_rtn = false; - cntrl->serialInfo = new serialIO(cntrl->serial_card, - cntrl->serial_task, &success_rtn); + success_rtn = pasynSyncIO->connect(cntrl->asyn_port, 0, &cntrl->pasynUser); - if (success_rtn == true) + if (success_rtn == asynSuccess) { int retry = 0; @@ -499,7 +498,7 @@ static int motor_init() } - if (success_rtn == true && status > 0) + if (success_rtn == asynSuccess && status > 0) { brdptr->localaddr = (char *) NULL; brdptr->motor_in_motion = 0; diff --git a/motorApp/MicosSrc/drvMicos.h b/motorApp/MicosSrc/drvMicos.h index 9966511d..9a4948e5 100644 --- a/motorApp/MicosSrc/drvMicos.h +++ b/motorApp/MicosSrc/drvMicos.h @@ -10,6 +10,7 @@ * Modification Log: * ----------------- * .00 11/24/2003 kag initialized from drvMCB4B.h + * .01 07/12/2004 rls Converted from MPF to asyn. */ #ifndef INCdrvMicosh @@ -17,7 +18,8 @@ #include "motor.h" #include "motordrvCom.h" -#include "serialIO.h" +#include "asynDriver.h" +#include "asynSyncIO.h" /* Micos default profile. */ @@ -28,13 +30,12 @@ struct MicosController { - serialIO *serialInfo; /* For RS-232 */ - int serial_card; /* Card on which Hideos/MPF is running */ - char serial_task[20]; /* Hideos/MPF task/server name for serial port */ + asynUser *pasynUser; /* For RS-232 */ + char asyn_port[80]; /* asyn port name */ }; /* Function prototypes. */ extern RTN_STATUS MicosSetup(int, int, int); -extern RTN_STATUS MicosConfig(int, int, const char *); +extern RTN_STATUS MicosConfig(int, const char *); #endif /* INCdrvMicosh */ diff --git a/motorApp/MicroMoSrc/Makefile b/motorApp/MicroMoSrc/Makefile index a24fb953..d3090cd3 100644 --- a/motorApp/MicroMoSrc/Makefile +++ b/motorApp/MicroMoSrc/Makefile @@ -13,7 +13,7 @@ LIBRARY_IOC = MicroMo SRCS += MicroMoRegister.cc SRCS += devMVP2001.cc drvMVP2001.cc -MicroMo_LIBS += motor motorCOM_mpf +MicroMo_LIBS += motor asyn MicroMo_LIBS += $(EPICS_BASE_IOC_LIBS) include $(TOP)/configure/RULES