mirror of
https://github.com/Binary-Coalescence/motorDSM.git
synced 2025-08-04 21:55:40 -05:00
Convert from MPF to asyn
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
FILENAME... AcsRegister.cc
|
FILENAME... AcsRegister.cc
|
||||||
USAGE... Register ACS motor device driver shell commands.
|
USAGE... Register ACS motor device driver shell commands.
|
||||||
|
|
||||||
Version: $Revision: 1.1 $
|
Version: $Revision: 1.2 $
|
||||||
Modified By: $Author: sluiter $
|
Modified By: $Author: rivers $
|
||||||
Last Modified: $Date: 2003-05-27 13:39:40 $
|
Last Modified: $Date: 2004-04-20 20:50:11 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
@@ -31,16 +31,14 @@ static const iocshArg setupArg1 = {"N/A", iocshArgInt};
|
|||||||
static const iocshArg setupArg2 = {"Polling rate", iocshArgInt};
|
static const iocshArg setupArg2 = {"Polling rate", iocshArgInt};
|
||||||
// ACS Config arguments
|
// ACS Config arguments
|
||||||
static const iocshArg configArg0 = {"Card being configured", iocshArgInt};
|
static const iocshArg configArg0 = {"Card being configured", iocshArgInt};
|
||||||
static const iocshArg configArg1 = {"MPF server location", iocshArgInt};
|
static const iocshArg configArg1 = {"asyn port name", iocshArgString};
|
||||||
static const iocshArg configArg2 = {"MPF server task name", iocshArgString};
|
|
||||||
|
|
||||||
static const iocshArg * const MCB4BSetupArgs[3] = {&setupArg0, &setupArg1,
|
static const iocshArg * const MCB4BSetupArgs[3] = {&setupArg0, &setupArg1,
|
||||||
&setupArg2};
|
&setupArg2};
|
||||||
static const iocshArg * const MCB4BConfigArgs[3] = {&configArg0, &configArg1,
|
static const iocshArg * const MCB4BConfigArgs[2] = {&configArg0, &configArg1};
|
||||||
&configArg2};
|
|
||||||
|
|
||||||
static const iocshFuncDef setupMCB4B = {"MCB4BSetup", 3, MCB4BSetupArgs};
|
static const iocshFuncDef setupMCB4B = {"MCB4BSetup", 3, MCB4BSetupArgs};
|
||||||
static const iocshFuncDef configMCB4B = {"MCB4BConfig", 3, MCB4BConfigArgs};
|
static const iocshFuncDef configMCB4B = {"MCB4BConfig", 2, MCB4BConfigArgs};
|
||||||
|
|
||||||
static void setupMCB4BCallFunc(const iocshArgBuf *args)
|
static void setupMCB4BCallFunc(const iocshArgBuf *args)
|
||||||
{
|
{
|
||||||
@@ -48,7 +46,7 @@ static void setupMCB4BCallFunc(const iocshArgBuf *args)
|
|||||||
}
|
}
|
||||||
static void configMCB4BCallFunc(const iocshArgBuf *args)
|
static void configMCB4BCallFunc(const iocshArgBuf *args)
|
||||||
{
|
{
|
||||||
MCB4BConfig(args[0].ival, args[1].ival, args[2].sval);
|
MCB4BConfig(args[0].ival, args[2].sval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AcsRegister(void)
|
static void AcsRegister(void)
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
FILENAME... AcsRegister.h
|
FILENAME... AcsRegister.h
|
||||||
USAGE... This file contains function prototypes for ACS IOC shell commands.
|
USAGE... This file contains function prototypes for ACS IOC shell commands.
|
||||||
|
|
||||||
Version: $Revision: 1.1 $
|
Version: $Revision: 1.2 $
|
||||||
Modified By: $Author: sluiter $
|
Modified By: $Author: rivers $
|
||||||
Last Modified: $Date: 2003-05-27 13:39:40 $
|
Last Modified: $Date: 2004-04-20 20:50:12 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -41,5 +41,5 @@ Last Modified: $Date: 2003-05-27 13:39:40 $
|
|||||||
|
|
||||||
/* Function prototypes. */
|
/* Function prototypes. */
|
||||||
extern RTN_STATUS MCB4BSetup(int, int, int);
|
extern RTN_STATUS MCB4BSetup(int, int, int);
|
||||||
extern RTN_STATUS MCB4BConfig(int, int, const char *);
|
extern RTN_STATUS MCB4BConfig(int, const char *);
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ SRCS += AcsRegister.cc
|
|||||||
# Advanced Control Systems driver support.
|
# Advanced Control Systems driver support.
|
||||||
SRCS += devMCB4B.c drvMCB4B.c
|
SRCS += devMCB4B.c drvMCB4B.c
|
||||||
|
|
||||||
Acs_LIBS += motor motorCOM_mpf
|
Acs_LIBS += motor asyn
|
||||||
Acs_LIBS += $(EPICS_BASE_IOC_LIBS)
|
Acs_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||||
|
|
||||||
include $(TOP)/configure/RULES
|
include $(TOP)/configure/RULES
|
||||||
|
@@ -20,14 +20,14 @@
|
|||||||
#include "motor.h"
|
#include "motor.h"
|
||||||
#include "AcsRegister.h"
|
#include "AcsRegister.h"
|
||||||
#include "drvMCB4B.h"
|
#include "drvMCB4B.h"
|
||||||
#include "serialIO.h"
|
#include "asynSyncIO.h"
|
||||||
#include "epicsExport.h"
|
#include "epicsExport.h"
|
||||||
|
|
||||||
#define STATIC static
|
#define STATIC static
|
||||||
|
|
||||||
#define WAIT 1
|
#define WAIT 1
|
||||||
|
|
||||||
#define SERIAL_TIMEOUT 2000 /* Command timeout in msec */
|
#define TIMEOUT 2.0 /* Command timeout in sec */
|
||||||
|
|
||||||
#define BUFF_SIZE 100 /* Maximum length of string to/from MCB4B */
|
#define BUFF_SIZE 100 /* Maximum length of string to/from MCB4B */
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
volatile int drvMCB4BDebug = 0;
|
volatile int drvMCB4BDebug = 0;
|
||||||
#define Debug(L, FMT, V...) { if(L <= drvMCB4BDebug) \
|
#define Debug(L, FMT, V...) { if(L <= drvMCB4BDebug) \
|
||||||
{ errlogPrintf("%s(%d):",__FILE__,__LINE__); \
|
{ printf("%s(%d):",__FILE__,__LINE__); \
|
||||||
errlogPrintf(FMT,##V); } }
|
printf(FMT,##V); } }
|
||||||
#else
|
#else
|
||||||
#define Debug(L, FMT, V...)
|
#define Debug(L, FMT, V...)
|
||||||
#endif
|
#endif
|
||||||
@@ -116,16 +116,20 @@ STATIC struct thread_args targs = {SCAN_RATE, &MCB4B_access};
|
|||||||
static long report(int level)
|
static long report(int level)
|
||||||
{
|
{
|
||||||
int card;
|
int card;
|
||||||
|
struct MCB4Bcontroller *cntrl;
|
||||||
|
|
||||||
if (MCB4B_num_cards <=0)
|
if (MCB4B_num_cards <=0)
|
||||||
printf(" NO MCB4B controllers found\n");
|
printf(" NO MCB4B controllers found\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (card = 0; card < MCB4B_num_cards; card++)
|
for (card = 0; card < MCB4B_num_cards; card++) {
|
||||||
if (motor_state[card])
|
if (motor_state[card]) {
|
||||||
printf(" MCB4B controller %d, id: %s \n",
|
cntrl = (struct MCB4Bcontroller *) motor_state[card]->DevicePrivate;
|
||||||
card,
|
printf(" MCB4B controller %d, port=%s, id: %s \n",
|
||||||
|
card, cntrl->port,
|
||||||
motor_state[card]->ident);
|
motor_state[card]->ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -292,11 +296,11 @@ STATIC RTN_STATUS send_mess(int card, const char *com, char c)
|
|||||||
|
|
||||||
strcpy(buff, com);
|
strcpy(buff, com);
|
||||||
strcat(buff, OUTPUT_TERMINATOR);
|
strcat(buff, OUTPUT_TERMINATOR);
|
||||||
/*
|
|
||||||
Debug(2, "%.2f : send_mess: sending message to card %d, message=%s\n",
|
Debug(2, "send_mess: sending message to card %d, message=%s\n",
|
||||||
tickGet()/60., card, buff);
|
card, buff);
|
||||||
*/
|
|
||||||
cntrl->serialInfo->serialIOSend(buff, strlen(buff), SERIAL_TIMEOUT);
|
pasynSyncIO->write(cntrl->pasynUser, buff, strlen(buff), TIMEOUT);
|
||||||
|
|
||||||
return (OK);
|
return (OK);
|
||||||
}
|
}
|
||||||
@@ -308,9 +312,10 @@ STATIC RTN_STATUS send_mess(int card, const char *com, char c)
|
|||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
STATIC int recv_mess(int card, char *com, int flag)
|
STATIC int recv_mess(int card, char *com, int flag)
|
||||||
{
|
{
|
||||||
int timeout;
|
double timeout;
|
||||||
int len=0;
|
int len=0;
|
||||||
struct MCB4Bcontroller *cntrl;
|
struct MCB4Bcontroller *cntrl;
|
||||||
|
int flush;
|
||||||
|
|
||||||
/* Check that card exists */
|
/* Check that card exists */
|
||||||
if (!motor_state[card])
|
if (!motor_state[card])
|
||||||
@@ -321,35 +326,35 @@ STATIC int recv_mess(int card, char *com, int flag)
|
|||||||
|
|
||||||
cntrl = (struct MCB4Bcontroller *) motor_state[card]->DevicePrivate;
|
cntrl = (struct MCB4Bcontroller *) motor_state[card]->DevicePrivate;
|
||||||
|
|
||||||
/*
|
Debug(3, "recv_mess entry: card %d, flag=%d\n",
|
||||||
Debug(3, "%.2f : recv_mess entry: card %d, flag=%d\n",
|
card, flag);
|
||||||
tickGet()/60., card, flag);
|
if (flag == FLUSH) {
|
||||||
*/
|
flush = 1;
|
||||||
if (flag == FLUSH)
|
timeout = 0.;
|
||||||
timeout = 0;
|
} else {
|
||||||
else
|
flush = 0;
|
||||||
timeout = SERIAL_TIMEOUT;
|
timeout = TIMEOUT;
|
||||||
len = cntrl->serialInfo->serialIORecv(com, MAX_MSG_SIZE, (char *) "\r", timeout);
|
}
|
||||||
|
len = pasynSyncIO->read(cntrl->pasynUser, com, MAX_MSG_SIZE,
|
||||||
|
"\r", 1, flush, timeout);
|
||||||
|
|
||||||
/* The response from the MCB4B is terminated with CR. Remove */
|
/* The response from the MCB4B is terminated with CR. Remove */
|
||||||
if (len < 1) com[0] = '\0';
|
if (len < 1) com[0] = '\0';
|
||||||
else com[len-1] = '\0';
|
else com[len-1] = '\0';
|
||||||
|
|
||||||
/*
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
Debug(2, "%.2f : recv_mess: card %d, message = \"%s\"\n",
|
Debug(2, "recv_mess: card %d, message = \"%s\"\n",
|
||||||
tickGet()/60., card, com);
|
card, com);
|
||||||
}
|
}
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
if (flag != FLUSH) {
|
if (flag != FLUSH) {
|
||||||
Debug(1, "%.2f: recv_mess: card %d ERROR: no response\n",
|
Debug(1, "recv_mess: card %d ERROR: no response\n",
|
||||||
tickGet()/60., card);
|
card);
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "%.2f: recv_mess: card %d flush returned no characters\n",
|
Debug(3, "recv_mess: card %d flush returned no characters\n",
|
||||||
tickGet()/60., card);
|
card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return (len);
|
return (len);
|
||||||
}
|
}
|
||||||
@@ -400,8 +405,7 @@ MCB4BSetup(int num_cards, /* maximum number of controllers in system */
|
|||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
RTN_STATUS
|
RTN_STATUS
|
||||||
MCB4BConfig(int card, /* card being configured */
|
MCB4BConfig(int card, /* card being configured */
|
||||||
int location, /* card for RS-232 */
|
const char *name) /* port name for asyn */
|
||||||
const char *name) /* server_task for RS-232 */
|
|
||||||
{
|
{
|
||||||
struct MCB4Bcontroller *cntrl;
|
struct MCB4Bcontroller *cntrl;
|
||||||
|
|
||||||
@@ -411,8 +415,7 @@ MCB4BConfig(int card, /* card being configured */
|
|||||||
motor_state[card] = (struct controller *) malloc(sizeof(struct controller));
|
motor_state[card] = (struct controller *) malloc(sizeof(struct controller));
|
||||||
motor_state[card]->DevicePrivate = malloc(sizeof(struct MCB4Bcontroller));
|
motor_state[card]->DevicePrivate = malloc(sizeof(struct MCB4Bcontroller));
|
||||||
cntrl = (struct MCB4Bcontroller *) motor_state[card]->DevicePrivate;
|
cntrl = (struct MCB4Bcontroller *) motor_state[card]->DevicePrivate;
|
||||||
cntrl->serial_card = location;
|
strcpy(cntrl->port, name);
|
||||||
strcpy(cntrl->serial_task, name);
|
|
||||||
return (OK);
|
return (OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +435,7 @@ STATIC int motor_init()
|
|||||||
char buff[BUFF_SIZE];
|
char buff[BUFF_SIZE];
|
||||||
int total_axis = 0;
|
int total_axis = 0;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
bool success_rtn;
|
int success_rtn;
|
||||||
|
|
||||||
initialized = true; /* Indicate that driver is initialized. */
|
initialized = true; /* Indicate that driver is initialized. */
|
||||||
|
|
||||||
@@ -454,20 +457,18 @@ STATIC int motor_init()
|
|||||||
cntrl = (struct MCB4Bcontroller *) brdptr->DevicePrivate;
|
cntrl = (struct MCB4Bcontroller *) brdptr->DevicePrivate;
|
||||||
|
|
||||||
/* Initialize communications channel */
|
/* Initialize communications channel */
|
||||||
success_rtn = false;
|
|
||||||
|
|
||||||
cntrl->serialInfo = new serialIO(cntrl->serial_card,
|
success_rtn = pasynSyncIO->connect(cntrl->port, 0, &cntrl->pasynUser);
|
||||||
cntrl->serial_task, &success_rtn);
|
Debug(1, "motor_init, return from pasynSyncIO->connect for port %s = %d, pasynUser=%p\n",
|
||||||
|
cntrl->port, success_rtn, cntrl->pasynUser);
|
||||||
|
|
||||||
if (success_rtn == true)
|
if (success_rtn == 0)
|
||||||
{
|
{
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
|
|
||||||
/* Send a message to the board, see if it exists */
|
/* Send a message to the board, see if it exists */
|
||||||
/* flush any junk at input port - should not be any data available */
|
/* flush any junk at input port - should not be any data available */
|
||||||
do {
|
pasynSyncIO->flush(cntrl->pasynUser);
|
||||||
recv_mess(card_index, buff, FLUSH);
|
|
||||||
} while (strlen(buff) != 0);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
send_mess(card_index, "#00X", 0);
|
send_mess(card_index, "#00X", 0);
|
||||||
@@ -478,7 +479,7 @@ STATIC int motor_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (success_rtn == true && status > 0)
|
if (success_rtn == 0 && status > 0)
|
||||||
{
|
{
|
||||||
brdptr->localaddr = (char *) NULL;
|
brdptr->localaddr = (char *) NULL;
|
||||||
brdptr->motor_in_motion = 0;
|
brdptr->motor_in_motion = 0;
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#define INCdrvMCB4Bh 1
|
#define INCdrvMCB4Bh 1
|
||||||
|
|
||||||
#include "motordrvCom.h"
|
#include "motordrvCom.h"
|
||||||
#include "serialIO.h"
|
#include "asynDriver.h"
|
||||||
|
|
||||||
/* MCB4B default profile. */
|
/* MCB4B default profile. */
|
||||||
|
|
||||||
@@ -27,9 +27,8 @@
|
|||||||
|
|
||||||
struct MCB4Bcontroller
|
struct MCB4Bcontroller
|
||||||
{
|
{
|
||||||
serialIO *serialInfo; /* For RS-232 */
|
asynUser *pasynUser; /* asynUser structure */
|
||||||
int serial_card; /* Card on which Hideos/MPF is running */
|
char port[80]; /* asyn port name */
|
||||||
char serial_task[20]; /* Hideos/MPF task/server name for serial port */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* INCdrvMCB4Bh */
|
#endif /* INCdrvMCB4Bh */
|
||||||
|
Reference in New Issue
Block a user