forked from epics_driver_modules/motorBase
Corrected compiler error when calling Asyn method.
This commit is contained in:
@@ -31,13 +31,13 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <epicsThread.h>
|
||||
#include <drvSup.h>
|
||||
#include <string.h>
|
||||
#include <epicsThread.h>
|
||||
#include <drvSup.h>
|
||||
#include "motor.h"
|
||||
#include "drvPM304.h"
|
||||
#include "asynOctetSyncIO.h"
|
||||
#include "epicsExport.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#define STATIC static
|
||||
|
||||
@@ -59,12 +59,12 @@ struct mess_queue
|
||||
|
||||
#ifdef __GNUG__
|
||||
#ifdef DEBUG
|
||||
volatile int drvPM304Debug = 0;
|
||||
#define Debug(L, FMT, V...) { if(L <= drvPM304Debug) \
|
||||
volatile int drvPM304Debug = 0;
|
||||
#define Debug(L, FMT, V...) { if(L <= drvPM304Debug) \
|
||||
{ errlogPrintf("%s(%d):",__FILE__,__LINE__); \
|
||||
errlogPrintf(FMT,##V); } }
|
||||
#else
|
||||
#define Debug(L, FMT, V...)
|
||||
#define Debug(L, FMT, V...)
|
||||
#endif
|
||||
#else
|
||||
#define Debug()
|
||||
@@ -73,10 +73,10 @@ struct mess_queue
|
||||
/* Debugging notes:
|
||||
* drvPM304Debug == 0 No debugging information is printed
|
||||
* drvPM304Debug >= 1 Warning information is printed
|
||||
* drvPM304Debug >= 2 Time-stamped messages are printed for each string
|
||||
* drvPM304Debug >= 2 Time-stamped messages are printed for each string
|
||||
* sent to and received from the controller
|
||||
* drvPM304Debug >= 3 Additional debugging messages
|
||||
*/
|
||||
*/
|
||||
|
||||
int PM304_num_cards = 0;
|
||||
|
||||
@@ -228,7 +228,7 @@ STATIC int set_status(int card, int signal)
|
||||
|
||||
status.Bits.RA_PLUS_LS = 0;
|
||||
status.Bits.RA_MINUS_LS = 0;
|
||||
|
||||
|
||||
if (cntrl->model == MODEL_PM304) {
|
||||
/* The response string is an eight character string of ones and zeroes */
|
||||
|
||||
@@ -240,17 +240,17 @@ STATIC int set_status(int card, int signal)
|
||||
epicsThreadSleep(drvPM304ReadbackDelay);
|
||||
}
|
||||
|
||||
status.Bits.RA_PROBLEM = (response[2] == '1') ? 1 : 0;
|
||||
status.Bits.RA_PROBLEM = (response[2] == '1') ? 1 : 0;
|
||||
|
||||
if (response[1] == '1') {
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 1;
|
||||
ls_active = true;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 1;
|
||||
ls_active = true;
|
||||
}
|
||||
if (response[0] == '1') {
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 0;
|
||||
ls_active = true;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
status.Bits.RA_DIRECTION = 0;
|
||||
ls_active = true;
|
||||
}
|
||||
} else {
|
||||
/* The response string is 01: followed by an eight character string of ones and zeroes */
|
||||
@@ -263,22 +263,22 @@ STATIC int set_status(int card, int signal)
|
||||
epicsThreadSleep(drvPM304ReadbackDelay);
|
||||
}
|
||||
|
||||
status.Bits.RA_PROBLEM = (response[1] == '1') ? 1 : 0;
|
||||
status.Bits.RA_PROBLEM = (response[1] == '1') ? 1 : 0;
|
||||
|
||||
if (response[2] == '1') {
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
status.Bits.RA_PLUS_LS = 1;
|
||||
}
|
||||
if (response[3] == '1') {
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
status.Bits.RA_MINUS_LS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* encoder status */
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_SLIP = 0;
|
||||
status.Bits.EA_POSITION = 0;
|
||||
status.Bits.EA_SLIP_STALL = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
status.Bits.EA_HOME = 0;
|
||||
|
||||
/* Request the position of this motor */
|
||||
if (cntrl->use_encoder[signal]) {
|
||||
@@ -293,12 +293,12 @@ STATIC int set_status(int card, int signal)
|
||||
|
||||
if (motorData == motor_info->position)
|
||||
{
|
||||
if (nodeptr != 0) /* Increment counter only if motor is moving. */
|
||||
motor_info->no_motion_count++;
|
||||
if (nodeptr != 0) /* Increment counter only if motor is moving. */
|
||||
motor_info->no_motion_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0;
|
||||
status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0;
|
||||
motor_info->position = motorData;
|
||||
motor_info->encoder_position = motorData;
|
||||
motor_info->no_motion_count = 0;
|
||||
@@ -313,11 +313,11 @@ STATIC int set_status(int card, int signal)
|
||||
motor_info->velocity *= -1;
|
||||
|
||||
rtn_state = (!motor_info->no_motion_count || ls_active == true ||
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0;
|
||||
|
||||
/* Test for post-move string. */
|
||||
if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 &&
|
||||
nodeptr->postmsgptr != 0)
|
||||
nodeptr->postmsgptr != 0)
|
||||
{
|
||||
strcpy(buff, nodeptr->postmsgptr);
|
||||
strcat(buff, "\r");
|
||||
@@ -347,13 +347,14 @@ STATIC RTN_STATUS send_mess(int card, const char *com, char *name)
|
||||
char *p, *tok_save;
|
||||
char response[BUFF_SIZE];
|
||||
struct PM304controller *cntrl;
|
||||
int nwrite, nread, eomReason;
|
||||
size_t nwrite, nread;
|
||||
int eomReason;
|
||||
|
||||
/* Check that card exists */
|
||||
if (!motor_state[card])
|
||||
{
|
||||
epicsPrintf("send_mess - invalid card #%d\n", card);
|
||||
return(ERROR);
|
||||
return(ERROR);
|
||||
}
|
||||
|
||||
cntrl = (struct PM304controller *) motor_state[card]->DevicePrivate;
|
||||
@@ -365,8 +366,8 @@ STATIC RTN_STATUS send_mess(int card, const char *com, char *name)
|
||||
((p != NULL) && (strlen(p) != 0));
|
||||
p = strtok_r(NULL, ";", &tok_save)) {
|
||||
Debug(2, "send_mess: sending message to card %d, message=%s\n", card, p);
|
||||
pasynOctetSyncIO->writeRead(cntrl->pasynUser, p, strlen(p), response,
|
||||
BUFF_SIZE, TIMEOUT, &nwrite, &nread, &eomReason);
|
||||
pasynOctetSyncIO->writeRead(cntrl->pasynUser, p, strlen(p), response,
|
||||
BUFF_SIZE, TIMEOUT, &nwrite, &nread, &eomReason);
|
||||
Debug(2, "send_mess: card %d, response=%s\n", card, response);
|
||||
}
|
||||
|
||||
@@ -390,7 +391,8 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
char temp[BUFF_SIZE];
|
||||
int flush;
|
||||
asynStatus status;
|
||||
int nread=0, eomReason;
|
||||
size_t nread=0;
|
||||
int eomReason;
|
||||
struct PM304controller *cntrl;
|
||||
|
||||
com[0] = '\0';
|
||||
@@ -411,7 +413,7 @@ STATIC int recv_mess(int card, char *com, int flag)
|
||||
timeout = TIMEOUT;
|
||||
}
|
||||
if (flush) status = pasynOctetSyncIO->flush(cntrl->pasynUser);
|
||||
status = pasynOctetSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE,
|
||||
status = pasynOctetSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE,
|
||||
timeout, &nread, &eomReason);
|
||||
|
||||
/* The response from the PM304 is terminated with CR/LF. Remove these */
|
||||
@@ -457,7 +459,8 @@ STATIC int send_recv_mess(int card, const char *out, char *response)
|
||||
struct PM304controller *cntrl;
|
||||
char *pos;
|
||||
asynStatus status;
|
||||
int nwrite, nread=0, eomReason;
|
||||
size_t nwrite=0, nread=0;
|
||||
int eomReason;
|
||||
char temp[BUFF_SIZE];
|
||||
|
||||
response[0] = '\0';
|
||||
@@ -478,7 +481,7 @@ STATIC int send_recv_mess(int card, const char *out, char *response)
|
||||
((p != NULL) && (strlen(p) != 0));
|
||||
p = strtok_r(NULL, ";", &tok_save)) {
|
||||
Debug(2, "send_recv_mess: sending message to card %d, message=%s\n", card, p);
|
||||
status = pasynOctetSyncIO->writeRead(cntrl->pasynUser, p, strlen(p),
|
||||
status = pasynOctetSyncIO->writeRead(cntrl->pasynUser, p, strlen(p),
|
||||
response, BUFF_SIZE, TIMEOUT,
|
||||
&nwrite, &nread, &eomReason);
|
||||
}
|
||||
@@ -511,7 +514,7 @@ STATIC int send_recv_mess(int card, const char *out, char *response)
|
||||
/* PM304Setup() */
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
PM304Setup(int num_cards, /* maximum number of controllers in system */
|
||||
PM304Setup(int num_cards, /* maximum number of controllers in system */
|
||||
int scan_rate) /* polling rate - 1/60 sec units */
|
||||
{
|
||||
int itera;
|
||||
@@ -523,9 +526,9 @@ PM304Setup(int num_cards, /* maximum number of controllers in system */
|
||||
|
||||
/* Set motor polling task rate */
|
||||
if (scan_rate >= 1 && scan_rate <= 60)
|
||||
targs.motor_scan_rate = scan_rate;
|
||||
targs.motor_scan_rate = scan_rate;
|
||||
else
|
||||
targs.motor_scan_rate = SCAN_RATE;
|
||||
targs.motor_scan_rate = SCAN_RATE;
|
||||
|
||||
/*
|
||||
* Allocate space for motor_state structure pointers. Note this must be done
|
||||
@@ -549,7 +552,7 @@ PM304Setup(int num_cards, /* maximum number of controllers in system */
|
||||
/*****************************************************/
|
||||
RTN_STATUS
|
||||
PM304Config(int card, /* card being configured */
|
||||
const char *port, /* asyn port name */
|
||||
const char *port, /* asyn port name */
|
||||
int n_axes) /* Number of axes */
|
||||
{
|
||||
struct PM304controller *cntrl;
|
||||
@@ -667,7 +670,7 @@ STATIC int motor_init()
|
||||
send_recv_mess(card_index, command, buff); /* Read controller ID string for this axis */
|
||||
if (cntrl->model == MODEL_PM304) {
|
||||
/* For now always assume encoder if PM304 - needs work */
|
||||
cntrl->use_encoder[motor_index] = 1;
|
||||
cntrl->use_encoder[motor_index] = 1;
|
||||
} else {
|
||||
/* PM600 ident string identifies open loop stepper motors */
|
||||
if (strstr(buff, "Open loop stepper mode") != NULL) {
|
||||
@@ -698,8 +701,8 @@ STATIC int motor_init()
|
||||
free_list.tail = (struct mess_node *) NULL;
|
||||
|
||||
epicsThreadCreate((char *) "tPM304", epicsThreadPriorityMedium,
|
||||
epicsThreadGetStackSize(epicsThreadStackMedium),
|
||||
(EPICSTHREADFUNC) motor_task, (void *) &targs);
|
||||
|
||||
epicsThreadGetStackSize(epicsThreadStackMedium),
|
||||
(EPICSTHREADFUNC) motor_task, (void *) &targs);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user