forked from epics_driver_modules/motorBase
- Converted from MPF to asyn.
- Removed unused <driver>Setup() argument.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
FILENAME... ImsRegister.cc
|
||||
USAGE... Register IMS motor device driver shell commands.
|
||||
|
||||
Version: $Revision: 1.2 $
|
||||
Version: $Revision: 1.3 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-05-23 19:34:13 $
|
||||
Last Modified: $Date: 2004-07-16 19:10:15 $
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
@@ -32,53 +32,48 @@ extern "C"
|
||||
|
||||
// Ims Setup arguments
|
||||
static const iocshArg setupArg0 = {"Max. controller count", iocshArgInt};
|
||||
static const iocshArg setupArg1 = {"N/A", iocshArgInt};
|
||||
static const iocshArg setupArg2 = {"Polling rate", iocshArgInt};
|
||||
static const iocshArg setupArg1 = {"Polling rate", iocshArgInt};
|
||||
// Ims Config arguments
|
||||
static const iocshArg configArg0 = {"Card being configured", iocshArgInt};
|
||||
static const iocshArg configArg1 = {"N/A - always RS232_PORT", iocshArgInt};
|
||||
static const iocshArg configArg2 = {"MPF server location", iocshArgInt};
|
||||
static const iocshArg configArg3 = {"MPF server task name", iocshArgString};
|
||||
static const iocshArg configArg1 = {"asyn port name", iocshArgString};
|
||||
|
||||
|
||||
static const iocshArg * const IM483SetupArgs[3] = {&setupArg0, &setupArg1,
|
||||
&setupArg2};
|
||||
static const iocshArg * const IM483ConfigArgs[4] = {&configArg0, &configArg1,
|
||||
&configArg2, &configArg3};
|
||||
static const iocshArg * const IM483SetupArgs[2] = {&setupArg0, &setupArg1};
|
||||
static const iocshArg * const IM483ConfigArgs[2] = {&configArg0, &configArg1};
|
||||
|
||||
static const iocshFuncDef setupIM483SM = {"IM483SMSetup", 3, IM483SetupArgs};
|
||||
static const iocshFuncDef setupIM483PL = {"IM483PLSetup", 3, IM483SetupArgs};
|
||||
static const iocshFuncDef setupMDrive = {"MDriveSetup", 3, IM483SetupArgs};
|
||||
static const iocshFuncDef setupIM483SM = {"IM483SMSetup", 2, IM483SetupArgs};
|
||||
static const iocshFuncDef setupIM483PL = {"IM483PLSetup", 2, IM483SetupArgs};
|
||||
static const iocshFuncDef setupMDrive = {"MDriveSetup", 2, IM483SetupArgs};
|
||||
|
||||
static const iocshFuncDef configIM483SM = {"IM483SMConfig", 4, IM483ConfigArgs};
|
||||
static const iocshFuncDef configIM483PL = {"IM483PLConfig", 4, IM483ConfigArgs};
|
||||
static const iocshFuncDef configMDrive = {"MDriveConfig", 4, IM483ConfigArgs};
|
||||
static const iocshFuncDef configIM483SM = {"IM483SMConfig", 2, IM483ConfigArgs};
|
||||
static const iocshFuncDef configIM483PL = {"IM483PLConfig", 2, IM483ConfigArgs};
|
||||
static const iocshFuncDef configMDrive = {"MDriveConfig", 2, IM483ConfigArgs};
|
||||
|
||||
static void setupSMCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
IM483SMSetup(args[0].ival, args[1].ival, args[2].ival);
|
||||
IM483SMSetup(args[0].ival, args[1].ival);
|
||||
}
|
||||
static void setupPLCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
IM483PLSetup(args[0].ival, args[1].ival, args[2].ival);
|
||||
IM483PLSetup(args[0].ival, args[1].ival);
|
||||
}
|
||||
static void setupMDriveCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
MDriveSetup(args[0].ival, args[1].ival, args[2].ival);
|
||||
MDriveSetup(args[0].ival, args[1].ival);
|
||||
}
|
||||
|
||||
|
||||
static void configSMCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
IM483SMConfig(args[0].ival, args[1].ival, args[2].ival, args[3].sval);
|
||||
IM483SMConfig(args[0].ival, args[1].sval);
|
||||
}
|
||||
static void configPLCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
IM483PLConfig(args[0].ival, args[1].ival, args[2].ival, args[3].sval);
|
||||
IM483PLConfig(args[0].ival, args[1].sval);
|
||||
}
|
||||
static void configMDriveCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
MDriveConfig(args[0].ival, args[1].ival, args[2].ival, args[3].sval);
|
||||
MDriveConfig(args[0].ival, args[1].sval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+15
-19
@@ -3,9 +3,9 @@ FILENAME... drvIM483.h
|
||||
USAGE... This file contains driver "include" information that is specific to
|
||||
Intelligent Motion Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-05-27 21:57:54 $
|
||||
Last Modified: $Date: 2004-07-16 19:12:08 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -37,39 +37,35 @@ Last Modified: $Date: 2003-05-27 21:57:54 $
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 02/10/2000 rls copied from drvMM4000.h
|
||||
* .01 02/10/2000 rls copied from drvMM4000.h
|
||||
* .02 07/01/2004 rls Converted from MPF to asyn.
|
||||
*/
|
||||
|
||||
#ifndef INCdrvIM483h
|
||||
#define INCdrvIM483h 1
|
||||
|
||||
#include "motordrvCom.h"
|
||||
#include "serialIO.h"
|
||||
#include "asynDriver.h"
|
||||
#include "asynSyncIO.h"
|
||||
|
||||
#define GPIB_TIMEOUT 2000 /* Command timeout in msec */
|
||||
#define SERIAL_TIMEOUT 2000 /* Command timeout in msec */
|
||||
#define COMM_TIMEOUT 2 /* Timeout in seconds */
|
||||
|
||||
|
||||
/* IM483 specific data is stored in this structure. */
|
||||
struct IM483controller
|
||||
{
|
||||
int port_type; /* GPIB_PORT or RS232_PORT */
|
||||
serialIO *serialInfo; /* For RS-232 */
|
||||
int gpib_link;
|
||||
int gpib_address;
|
||||
struct gpibInfo *gpibInfo; /* For GPIB */
|
||||
int serial_card; /* Card on which Hideos is running */
|
||||
char serial_task[20]; /* Hideos task name for serial port */
|
||||
asynUser *pasynUser; /* For RS-232 */
|
||||
char asyn_port[80]; /* asyn port name */
|
||||
CommStatus status; /* Controller communication status. */
|
||||
};
|
||||
|
||||
/* Function prototypes. */
|
||||
extern RTN_STATUS IM483SMSetup(int, int, int);
|
||||
extern RTN_STATUS IM483PLSetup(int, int, int);
|
||||
extern RTN_STATUS MDriveSetup(int, int, int);
|
||||
extern RTN_STATUS IM483SMConfig(int, int, int, const char *);
|
||||
extern RTN_STATUS IM483PLConfig(int, int, int, const char *);
|
||||
extern RTN_STATUS MDriveConfig(int, int, int, const char *);
|
||||
extern RTN_STATUS IM483SMSetup(int, int);
|
||||
extern RTN_STATUS IM483PLSetup(int, int);
|
||||
extern RTN_STATUS MDriveSetup(int, int);
|
||||
extern RTN_STATUS IM483SMConfig(int, const char *);
|
||||
extern RTN_STATUS IM483PLConfig(int, const char *);
|
||||
extern RTN_STATUS MDriveConfig(int, const char *);
|
||||
|
||||
#endif /* INCdrvIM483h */
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvIM483PL.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.7 $
|
||||
Version: $Revision: 1.8 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2004-03-15 20:39:56 $
|
||||
Last Modified: $Date: 2004-07-16 19:13:22 $
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
@@ -19,7 +19,6 @@ described on the COPYRIGHT_UniversityOfChicago file included as part
|
||||
of this distribution.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Original Author: Ron Sluiter
|
||||
* Date: 07/10/2000
|
||||
@@ -32,8 +31,9 @@ of this distribution.
|
||||
* set_status() based on (new - old) commanded position.
|
||||
* Removed support for "ASCII record separator (IS2) = /x1E"
|
||||
* from send_mess().
|
||||
* .04 03/07/03 rls R3.14 conversion.
|
||||
* .05 02/03/04 rls Eliminate erroneous "Motor motion timeout ERROR".
|
||||
* .04 03/07/03 rls R3.14 conversion.
|
||||
* .05 02/03/04 rls Eliminate erroneous "Motor motion timeout ERROR".
|
||||
* .06 07/01/04 rls Converted from MPF to asyn.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -53,11 +53,9 @@ DESIGN LIMITATIONS...
|
||||
#include <drvSup.h>
|
||||
#include "motor.h"
|
||||
#include "drvIM483.h"
|
||||
#include "serialIO.h"
|
||||
#include "asynSyncIO.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#define STATIC static
|
||||
|
||||
/* Read Limit Status response values. */
|
||||
#define L_ALIMIT 1
|
||||
#define L_BLIMIT 2
|
||||
@@ -84,19 +82,19 @@ DESIGN LIMITATIONS...
|
||||
|
||||
/* --- Local data. --- */
|
||||
int IM483PL_num_cards = 0;
|
||||
STATIC char IM483PL_axis[8] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'};
|
||||
static char IM483PL_axis[8] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'};
|
||||
|
||||
/* Local data required for every driver; see "motordrvComCode.h" */
|
||||
#include "motordrvComCode.h"
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
STATIC int recv_mess(int, char *, int);
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
STATIC int set_status(int card, int signal);
|
||||
int recv_mess(int, char *, int);
|
||||
RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
static int set_status(int card, int signal);
|
||||
static long report(int level);
|
||||
static long init();
|
||||
STATIC int motor_init();
|
||||
STATIC void query_done(int, int, struct mess_node *);
|
||||
static int motor_init();
|
||||
static void query_done(int, int, struct mess_node *);
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
|
||||
@@ -138,7 +136,7 @@ struct
|
||||
|
||||
epicsExportAddress(drvet, drvIM483PL);
|
||||
|
||||
STATIC struct thread_args targs = {SCAN_RATE, &IM483PL_access};
|
||||
static struct thread_args targs = {SCAN_RATE, &IM483PL_access};
|
||||
|
||||
/*********************************************************
|
||||
* Print out driver status report
|
||||
@@ -162,19 +160,8 @@ static long report(int level)
|
||||
struct IM483controller *cntrl;
|
||||
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
switch (cntrl->port_type)
|
||||
{
|
||||
case RS232_PORT:
|
||||
printf(" IM483PL controller %d port type = RS-232, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
default:
|
||||
printf(" IM483PL controller %d port type = Unknown, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
}
|
||||
printf(" IM483PL controller #%d, port=%s, id: %s \n", card,
|
||||
cntrl->asyn_port, brdptr->ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +186,7 @@ static long init()
|
||||
}
|
||||
|
||||
|
||||
STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
static void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -233,7 +220,7 @@ STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
STATIC int set_status(int card, int signal)
|
||||
static int set_status(int card, int signal)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
struct mess_node *nodeptr;
|
||||
@@ -386,7 +373,7 @@ exit:
|
||||
/* send a message to the IM483PL board */
|
||||
/* send_mess() */
|
||||
/*****************************************************/
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
{
|
||||
char local_buff[MAX_MSG_SIZE];
|
||||
struct IM483controller *cntrl;
|
||||
@@ -418,7 +405,8 @@ STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
Debug(2, "send_mess(): message = %s\n", local_buff);
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
cntrl->serialInfo->serialIOSend(local_buff, strlen(local_buff), SERIAL_TIMEOUT);
|
||||
pasynSyncIO->write(cntrl->pasynUser, local_buff, strlen(local_buff),
|
||||
COMM_TIMEOUT);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
@@ -428,11 +416,12 @@ STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
/* receive a message from the IM483 board */
|
||||
/* recv_mess() */
|
||||
/*****************************************************/
|
||||
STATIC int recv_mess(int card, char *com, int flag)
|
||||
int recv_mess(int card, char *com, int flag)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
int timeout;
|
||||
int len=0;
|
||||
int flush = 0;
|
||||
int len = 0;
|
||||
|
||||
/* Check that card exists */
|
||||
if (!motor_state[card])
|
||||
@@ -443,9 +432,10 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
if (flag == FLUSH)
|
||||
timeout = 0;
|
||||
else
|
||||
timeout = SERIAL_TIMEOUT;
|
||||
timeout = COMM_TIMEOUT;
|
||||
|
||||
len = cntrl->serialInfo->serialIORecv(com, BUFF_SIZE, (char *) "\n", timeout);
|
||||
len = pasynSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, (char *) "\n",
|
||||
1, flush, timeout);
|
||||
|
||||
if (len == 0)
|
||||
com[0] = '\0';
|
||||
@@ -463,8 +453,7 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
IM483PLSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
int num_channels, /* NOT Used. */
|
||||
int scan_rate) /* polling rate - 1/60 sec units. */
|
||||
int scan_rate) /* polling rate - 1/60 sec units. */
|
||||
{
|
||||
int itera;
|
||||
|
||||
@@ -500,10 +489,8 @@ IM483PLSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
/* IM483PLConfig() */
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
IM483PLConfig(int card, /* card being configured */
|
||||
int port_type, /* N/A - always RS232_PORT */
|
||||
int location, /* MPF server location */
|
||||
const char *name) /* MPF server task name */
|
||||
IM483PLConfig(int card, /* card being configured */
|
||||
const char *name) /* asyn server task name */
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
|
||||
@@ -514,9 +501,7 @@ IM483PLConfig(int card, /* card being configured */
|
||||
motor_state[card]->DevicePrivate = malloc(sizeof(struct IM483controller));
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
|
||||
cntrl->port_type = RS232_PORT;
|
||||
cntrl->serial_card = location;
|
||||
strcpy(cntrl->serial_task, name);
|
||||
strcpy(cntrl->asyn_port, name);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -527,7 +512,7 @@ IM483PLConfig(int card, /* card being configured */
|
||||
/* device support. */
|
||||
/* motor_init() */
|
||||
/*****************************************************/
|
||||
STATIC int motor_init()
|
||||
static int motor_init()
|
||||
{
|
||||
struct controller *brdptr;
|
||||
struct IM483controller *cntrl;
|
||||
@@ -535,7 +520,7 @@ STATIC int motor_init()
|
||||
char buff[BUFF_SIZE];
|
||||
int total_axis = 0;
|
||||
int status;
|
||||
bool success_rtn;
|
||||
asynStatus success_rtn;
|
||||
|
||||
initialized = true; /* Indicate that driver is initialized. */
|
||||
|
||||
@@ -555,17 +540,13 @@ STATIC int motor_init()
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
|
||||
/* Initialize communications channel */
|
||||
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)
|
||||
{
|
||||
/* Send a message to the board, see if it exists */
|
||||
/* flush any junk at input port - should not be any data available */
|
||||
do
|
||||
recv_mess(card_index, buff, FLUSH);
|
||||
while (strlen(buff) != 0);
|
||||
pasynSyncIO->flush(cntrl->pasynUser);
|
||||
|
||||
for (total_axis = 0; total_axis < MAX_AXES; total_axis++)
|
||||
{
|
||||
@@ -577,7 +558,7 @@ STATIC int motor_init()
|
||||
brdptr->total_axis = total_axis;
|
||||
}
|
||||
|
||||
if (success_rtn == true && total_axis > 0)
|
||||
if (success_rtn == asynSuccess && total_axis > 0)
|
||||
{
|
||||
brdptr->localaddr = (char *) NULL;
|
||||
brdptr->motor_in_motion = 0;
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvIM483SM.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. IM483(I/IE).
|
||||
|
||||
Version: $Revision: 1.8 $
|
||||
Version: $Revision: 1.9 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2004-03-15 20:40:20 $
|
||||
Last Modified: $Date: 2004-07-16 19:14:18 $
|
||||
*/
|
||||
|
||||
/*****************************************************************
|
||||
@@ -33,6 +33,7 @@ of this distribution.
|
||||
* from send_mess().
|
||||
* .04 03/07/03 rls R3.14 conversion.
|
||||
* .05 02/03/04 rls Eliminate erroneous "Motor motion timeout ERROR".
|
||||
* .06 07/01/04 rls Converted from MPF to asyn.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -53,11 +54,9 @@ DESIGN LIMITATIONS...
|
||||
#include <drvSup.h>
|
||||
#include "motor.h"
|
||||
#include "drvIM483.h"
|
||||
#include "serialIO.h"
|
||||
#include "asynSyncIO.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#define STATIC static
|
||||
|
||||
/* Read Limit Status response values. */
|
||||
#define L_ALIMIT 1
|
||||
#define L_BLIMIT 2
|
||||
@@ -65,7 +64,7 @@ DESIGN LIMITATIONS...
|
||||
|
||||
|
||||
#define IM483SM_NUM_CARDS 8
|
||||
#define BUFF_SIZE 13 /* Maximum length of string to/from IM483 */
|
||||
#define BUFF_SIZE 50 /* Maximum length of string to/from IM483 */
|
||||
|
||||
/*----------------debugging-----------------*/
|
||||
#ifdef __GNUG__
|
||||
@@ -88,13 +87,13 @@ int IM483SM_num_cards = 0;
|
||||
#include "motordrvComCode.h"
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
STATIC int recv_mess(int, char *, int);
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
STATIC int set_status(int card, int signal);
|
||||
static int recv_mess(int, char *, int);
|
||||
static RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
static int set_status(int card, int signal);
|
||||
static long report(int level);
|
||||
static long init();
|
||||
STATIC int motor_init();
|
||||
STATIC void query_done(int, int, struct mess_node *);
|
||||
static int motor_init();
|
||||
static void query_done(int, int, struct mess_node *);
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
|
||||
@@ -136,7 +135,7 @@ struct
|
||||
|
||||
epicsExportAddress(drvet, drvIM483SM);
|
||||
|
||||
STATIC struct thread_args targs = {SCAN_RATE, &IM483SM_access};
|
||||
static struct thread_args targs = {SCAN_RATE, &IM483SM_access};
|
||||
|
||||
|
||||
/*********************************************************
|
||||
@@ -161,19 +160,8 @@ static long report(int level)
|
||||
struct IM483controller *cntrl;
|
||||
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
switch (cntrl->port_type)
|
||||
{
|
||||
case RS232_PORT:
|
||||
printf(" IM483SM controller %d port type = RS-232, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
default:
|
||||
printf(" IM483SM controller %d port type = Unknown, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
}
|
||||
printf(" IM483SM controller #%d, port=%s, id: %s \n", card,
|
||||
cntrl->asyn_port, brdptr->ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +186,7 @@ static long init()
|
||||
}
|
||||
|
||||
|
||||
STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
static void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -232,7 +220,7 @@ STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
STATIC int set_status(int card, int signal)
|
||||
static int set_status(int card, int signal)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
struct mess_node *nodeptr;
|
||||
@@ -385,7 +373,7 @@ exit:
|
||||
/* send a message to the IM483SM board */
|
||||
/* send_mess() */
|
||||
/*****************************************************/
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
static RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
{
|
||||
char local_buff[MAX_MSG_SIZE];
|
||||
struct IM483controller *cntrl;
|
||||
@@ -423,7 +411,8 @@ STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
Debug(2, "send_mess(): message = %s\n", local_buff);
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
cntrl->serialInfo->serialIOSend(local_buff, strlen(local_buff), SERIAL_TIMEOUT);
|
||||
pasynSyncIO->write(cntrl->pasynUser, local_buff, strlen(local_buff),
|
||||
COMM_TIMEOUT);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
@@ -433,11 +422,12 @@ STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
/* receive a message from the IM483 board */
|
||||
/* recv_mess() */
|
||||
/*****************************************************/
|
||||
STATIC int recv_mess(int card, char *com, int flag)
|
||||
static int recv_mess(int card, char *com, int flag)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
int timeout;
|
||||
int len=0;
|
||||
int flush = 0;
|
||||
int len = 0;
|
||||
|
||||
/* Check that card exists */
|
||||
if (!motor_state[card])
|
||||
@@ -448,9 +438,10 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
if (flag == FLUSH)
|
||||
timeout = 0;
|
||||
else
|
||||
timeout = SERIAL_TIMEOUT;
|
||||
timeout = COMM_TIMEOUT;
|
||||
|
||||
len = cntrl->serialInfo->serialIORecv(com, BUFF_SIZE, (char *) "\r\n", timeout);
|
||||
len = pasynSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, (char *) "\r\n",
|
||||
2, flush, timeout);
|
||||
|
||||
if (len < 2)
|
||||
com[0] = '\0';
|
||||
@@ -468,7 +459,6 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
IM483SMSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
int num_channels, /* NOT Used. */
|
||||
int scan_rate) /* polling rate - 1/60 sec units. */
|
||||
{
|
||||
int itera;
|
||||
@@ -506,9 +496,7 @@ IM483SMSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
IM483SMConfig(int card, /* card being configured */
|
||||
int port_type, /* N/A - always RS232_PORT */
|
||||
int location, /* MPF server location */
|
||||
const char *name) /* MPF server task name */
|
||||
const char *name) /* asyn server task name */
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
|
||||
@@ -519,9 +507,7 @@ IM483SMConfig(int card, /* card being configured */
|
||||
motor_state[card]->DevicePrivate = malloc(sizeof(struct IM483controller));
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
|
||||
cntrl->port_type = RS232_PORT;
|
||||
cntrl->serial_card = location;
|
||||
strcpy(cntrl->serial_task, name);
|
||||
strcpy(cntrl->asyn_port, name);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -532,7 +518,7 @@ IM483SMConfig(int card, /* card being configured */
|
||||
/* device support. */
|
||||
/* motor_init() */
|
||||
/*****************************************************/
|
||||
STATIC int motor_init()
|
||||
static int motor_init()
|
||||
{
|
||||
struct controller *brdptr;
|
||||
struct IM483controller *cntrl;
|
||||
@@ -540,7 +526,7 @@ STATIC int motor_init()
|
||||
char buff[BUFF_SIZE];
|
||||
int total_axis = 0;
|
||||
int status;
|
||||
bool success_rtn;
|
||||
asynStatus success_rtn;
|
||||
|
||||
initialized = true; /* Indicate that driver is initialized. */
|
||||
|
||||
@@ -559,20 +545,16 @@ STATIC int motor_init()
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
|
||||
/* Initialize communications channel */
|
||||
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 itera;
|
||||
char *src, *dest;
|
||||
|
||||
/* Send a message to the board, see if it exists */
|
||||
/* flush any junk at input port - should not be any data available */
|
||||
do
|
||||
recv_mess(card_index, buff, FLUSH);
|
||||
while (strlen(buff) != 0);
|
||||
pasynSyncIO->flush(cntrl->pasynUser);
|
||||
|
||||
send_mess(card_index, "\003", (char) NULL); /* Reset device. */
|
||||
epicsThreadSleep(1.0);
|
||||
@@ -622,7 +604,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;
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvMDrive.cc
|
||||
USAGE... Motor record driver level support for Intelligent Motion
|
||||
Systems, Inc. MDrive series; M17, M23, M34.
|
||||
|
||||
Version: $Revision: 1.9 $
|
||||
Version: $Revision: 1.10 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2004-03-15 21:01:44 $
|
||||
Last Modified: $Date: 2004-07-16 19:16:06 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -40,6 +40,7 @@ Last Modified: $Date: 2004-03-15 21:01:44 $
|
||||
* .03 03/15/04 rls Previous driver releases not working. Fixed by adding
|
||||
* Kevin Peterson's eat_garbage() function. Added support
|
||||
* for encoder detection via "ident".
|
||||
* .04 07/01/04 rls Converted from MPF to asyn.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -56,11 +57,9 @@ DESIGN LIMITATIONS...
|
||||
#include <drvSup.h>
|
||||
#include "motor.h"
|
||||
#include "drvIM483.h"
|
||||
#include "serialIO.h"
|
||||
#include "asynSyncIO.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#define STATIC static
|
||||
|
||||
#define MDrive_NUM_CARDS 8
|
||||
#define MAX_AXES 8
|
||||
#define BUFF_SIZE 13 /* Maximum length of string to/from MDrive */
|
||||
@@ -80,20 +79,20 @@ DESIGN LIMITATIONS...
|
||||
|
||||
/* --- Local data. --- */
|
||||
int MDrive_num_cards = 0;
|
||||
STATIC char MDrive_axis[8] = {'1', '2', '3', '4', '5', '6', '7', '8'};
|
||||
static char MDrive_axis[8] = {'1', '2', '3', '4', '5', '6', '7', '8'};
|
||||
|
||||
/* Local data required for every driver; see "motordrvComCode.h" */
|
||||
#include "motordrvComCode.h"
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
static int eat_garbage(int, char *, int);
|
||||
STATIC int recv_mess(int, char *, int);
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
STATIC int set_status(int card, int signal);
|
||||
static int recv_mess(int, char *, int);
|
||||
static RTN_STATUS send_mess(int card, char const *com, char c);
|
||||
static int set_status(int card, int signal);
|
||||
static long report(int level);
|
||||
static long init();
|
||||
STATIC int motor_init();
|
||||
STATIC void query_done(int, int, struct mess_node *);
|
||||
static int motor_init();
|
||||
static void query_done(int, int, struct mess_node *);
|
||||
|
||||
/*----------------functions-----------------*/
|
||||
|
||||
@@ -135,7 +134,7 @@ struct
|
||||
|
||||
epicsExportAddress(drvet, drvMDrive);
|
||||
|
||||
STATIC struct thread_args targs = {SCAN_RATE, &MDrive_access};
|
||||
static struct thread_args targs = {SCAN_RATE, &MDrive_access};
|
||||
|
||||
|
||||
/* Single Inputs - response from PR IN command */
|
||||
@@ -188,19 +187,8 @@ static long report(int level)
|
||||
struct IM483controller *cntrl;
|
||||
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
switch (cntrl->port_type)
|
||||
{
|
||||
case RS232_PORT:
|
||||
printf(" MDrive controller %d port type = RS-232, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
default:
|
||||
printf(" MDrive controller %d port type = Unknown, id: %s \n",
|
||||
card,
|
||||
brdptr->ident);
|
||||
break;
|
||||
}
|
||||
printf(" IM483SM controller #%d, port=%s, id: %s \n", card,
|
||||
cntrl->asyn_port, brdptr->ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +213,7 @@ static long init()
|
||||
}
|
||||
|
||||
|
||||
STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
static void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -259,7 +247,7 @@ STATIC void query_done(int card, int axis, struct mess_node *nodeptr)
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
STATIC int set_status(int card, int signal)
|
||||
static int set_status(int card, int signal)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
struct mess_node *nodeptr;
|
||||
@@ -413,7 +401,7 @@ exit:
|
||||
/* send a message to the MDrive board */
|
||||
/* send_mess() */
|
||||
/*****************************************************/
|
||||
STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
static RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
{
|
||||
char local_buff[MAX_MSG_SIZE];
|
||||
struct IM483controller *cntrl;
|
||||
@@ -445,7 +433,8 @@ STATIC RTN_STATUS send_mess(int card, char const *com, char inchar)
|
||||
Debug(2, "send_mess(): message = %s\n", local_buff);
|
||||
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
cntrl->serialInfo->serialIOSend(local_buff, strlen(local_buff), SERIAL_TIMEOUT);
|
||||
pasynSyncIO->write(cntrl->pasynUser, local_buff, strlen(local_buff),
|
||||
COMM_TIMEOUT);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
@@ -460,7 +449,8 @@ static int eat_garbage(int card, char *com, int flag)
|
||||
struct IM483controller *cntrl;
|
||||
char localbuf[BUFF_SIZE];
|
||||
int timeout;
|
||||
int len=0;
|
||||
int flush = 0;
|
||||
int len = 0;
|
||||
|
||||
/* Check that card exists */
|
||||
if (!motor_state[card])
|
||||
@@ -471,10 +461,11 @@ static int eat_garbage(int card, char *com, int flag)
|
||||
if (flag == FLUSH)
|
||||
timeout = 0;
|
||||
else
|
||||
timeout = SERIAL_TIMEOUT;
|
||||
timeout = COMM_TIMEOUT;
|
||||
|
||||
/* Get the response. */
|
||||
len = cntrl->serialInfo->serialIORecv(localbuf, BUFF_SIZE, (char *) "\r\n", timeout);
|
||||
len = pasynSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, (char *) "\r\n",
|
||||
2, flush, timeout);
|
||||
|
||||
Debug(2, "eat_garbage(): len = %i\n", len);
|
||||
if (len != 2)
|
||||
@@ -491,12 +482,13 @@ static int eat_garbage(int card, char *com, int flag)
|
||||
/* receive a message from the MDrive board */
|
||||
/* recv_mess() */
|
||||
/*****************************************************/
|
||||
STATIC int recv_mess(int card, char *com, int flag)
|
||||
static int recv_mess(int card, char *com, int flag)
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
char localbuf[BUFF_SIZE];
|
||||
int timeout;
|
||||
int len=0;
|
||||
int flush = 0;
|
||||
int len = 0;
|
||||
|
||||
/* Check that card exists */
|
||||
if (!motor_state[card])
|
||||
@@ -507,10 +499,11 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
if (flag == FLUSH)
|
||||
timeout = 0;
|
||||
else
|
||||
timeout = SERIAL_TIMEOUT;
|
||||
timeout = COMM_TIMEOUT;
|
||||
|
||||
/* Get the response. */
|
||||
len = cntrl->serialInfo->serialIORecv(localbuf, BUFF_SIZE, (char *) "\r\n", timeout);
|
||||
len = pasynSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, (char *) "\r\n",
|
||||
1, flush, timeout);
|
||||
|
||||
if (len == 0)
|
||||
com[0] = '\0';
|
||||
@@ -531,7 +524,6 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
MDriveSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
int num_channels, /* NOT Used. */
|
||||
int scan_rate) /* polling rate - 1/60 sec units. */
|
||||
{
|
||||
int itera;
|
||||
@@ -569,8 +561,6 @@ MDriveSetup(int num_cards, /* maximum number of controllers in system. */
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
MDriveConfig(int card, /* card being configured */
|
||||
int port_type, /* N/A - always RS232_PORT */
|
||||
int location, /* MPF server location */
|
||||
const char *name) /* MPF server task name */
|
||||
{
|
||||
struct IM483controller *cntrl;
|
||||
@@ -582,9 +572,7 @@ MDriveConfig(int card, /* card being configured */
|
||||
motor_state[card]->DevicePrivate = malloc(sizeof(struct IM483controller));
|
||||
cntrl = (struct IM483controller *) motor_state[card]->DevicePrivate;
|
||||
|
||||
cntrl->port_type = RS232_PORT;
|
||||
cntrl->serial_card = location;
|
||||
strcpy(cntrl->serial_task, name);
|
||||
strcpy(cntrl->asyn_port, name);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -595,7 +583,7 @@ MDriveConfig(int card, /* card being configured */
|
||||
/* device support. */
|
||||
/* motor_init() */
|
||||
/*****************************************************/
|
||||
STATIC int motor_init()
|
||||
static int motor_init()
|
||||
{
|
||||
struct controller *brdptr;
|
||||
struct IM483controller *cntrl;
|
||||
@@ -603,7 +591,7 @@ STATIC int motor_init()
|
||||
char buff[BUFF_SIZE];
|
||||
int total_axis = 0;
|
||||
int status;
|
||||
bool success_rtn;
|
||||
asynStatus success_rtn;
|
||||
|
||||
initialized = true; /* Indicate that driver is initialized. */
|
||||
|
||||
@@ -623,17 +611,13 @@ STATIC int motor_init()
|
||||
cntrl = (struct IM483controller *) brdptr->DevicePrivate;
|
||||
|
||||
/* Initialize communications channel */
|
||||
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)
|
||||
{
|
||||
/* Send a message to the board, see if it exists */
|
||||
/* flush any junk at input port - should not be any data available */
|
||||
do
|
||||
recv_mess(card_index, buff, FLUSH);
|
||||
while (strlen(buff) != 0);
|
||||
pasynSyncIO->flush(cntrl->pasynUser);
|
||||
|
||||
for (total_axis = 0; total_axis < MAX_AXES; total_axis++)
|
||||
{
|
||||
@@ -656,7 +640,7 @@ STATIC int motor_init()
|
||||
brdptr->total_axis = total_axis;
|
||||
}
|
||||
|
||||
if (success_rtn == true && total_axis > 0)
|
||||
if (success_rtn == asynSuccess && total_axis > 0)
|
||||
{
|
||||
brdptr->localaddr = (char *) NULL;
|
||||
brdptr->motor_in_motion = 0;
|
||||
|
||||
Reference in New Issue
Block a user