Changed to C++ serialIO interface.

This commit is contained in:
Ron Sluiter
2003-05-27 21:48:45 +00:00
parent b0ad58a29d
commit 4807b6d03b
3 changed files with 34 additions and 22 deletions
+8 -11
View File
@@ -291,7 +291,7 @@ STATIC RTN_STATUS send_mess(int card, const char *com, char c)
Debug(2, "%.2f : send_mess: sending message to card %d, message=%s\n",
tickGet()/60., card, buff);
*/
serialIOSend(cntrl->serialInfo, buff, strlen(buff), SERIAL_TIMEOUT);
cntrl->serialInfo->serialIOSend(buff, strlen(buff), SERIAL_TIMEOUT);
return (OK);
}
@@ -324,8 +324,7 @@ STATIC int recv_mess(int card, char *com, int flag)
timeout = 0;
else
timeout = SERIAL_TIMEOUT;
len = serialIORecv(cntrl->serialInfo, com, MAX_MSG_SIZE,
(char *) "\r", timeout);
len = cntrl->serialInfo->serialIORecv(com, MAX_MSG_SIZE, (char *) "\r", timeout);
/* The response from the MCB4B is terminated with CR. Remove */
if (len < 1) com[0] = '\0';
@@ -428,7 +427,7 @@ STATIC int motor_init()
char buff[BUFF_SIZE];
int total_axis = 0;
int status = 0;
bool errind;
bool success_rtn;
initialized = true; /* Indicate that driver is initialized. */
@@ -450,14 +449,12 @@ STATIC int motor_init()
cntrl = (struct MCB4Bcontroller *) brdptr->DevicePrivate;
/* Initialize communications channel */
errind = false;
success_rtn = false;
cntrl->serialInfo = serialIOInit(cntrl->serial_card,
cntrl->serial_task);
if (cntrl->serialInfo == NULL)
errind = true;
cntrl->serialInfo = new serialIO(cntrl->serial_card,
cntrl->serial_task, &success_rtn);
if (errind == false)
if (success_rtn == true)
{
int retry = 0;
@@ -476,7 +473,7 @@ STATIC int motor_init()
}
if (errind == false && status > 0)
if (success_rtn == true && status > 0)
{
brdptr->localaddr = (char *) NULL;
brdptr->motor_in_motion = 0;
+2 -1
View File
@@ -16,6 +16,7 @@
#define INCdrvMCB4Bh 1
#include "motordrvCom.h"
#include "serialIO.h"
/* MCB4B default profile. */
@@ -26,7 +27,7 @@
struct MCB4Bcontroller
{
struct serialInfo *serialInfo; /* For RS-232 */
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 */
};
+24 -10
View File
@@ -2,9 +2,9 @@
FILENAME... serialIO.h
USAGE... .
Version: $Revision: 1.3 $
Version: $Revision: 1.4 $
Modified By: $Author: sluiter $
Last Modified: $Date: 2003-05-07 13:42:47 $
Last Modified: $Date: 2003-05-27 21:48:45 $
*/
/*****************************************************************
@@ -25,16 +25,30 @@ of this distribution.
* -----------------
*/
#ifndef INCserialIOh
#define INCserialIOh 1
#include "Message.h"
#ifdef __cplusplus
extern "C"
class serialIO
{
public:
serialIO(int, char *, bool *);
int serialIOSend(char const *, int, int);
int serialIORecv(char *, int, char *, int);
int serialIOSendRecv(char const *, int, char *, int, char *, int);
static void serialIOCallback(Message *, void *);
private:
MessageClient* pMessageClient;
epicsRingPointer<void *> *msgQId;
};
#else /* For C just define serialInfo as a dummy structure since it can't
understand the include files which define what it really is */
void *serialIOInit(int, char *);
int serialIOSend(void *, char const *, int, int);
int serialIORecv(void *, char *, int, char *, int);
int serialIOSendRecv(void *, const char *, int, char *, int, char *, int);
#endif
struct serialInfo *serialIOInit(int card, char *task);
int serialIOSend(struct serialInfo *serialInfo, char const *buffer,
int buffer_len, int timeout);
int serialIORecv(struct serialInfo *serialInfo, char *buffer, int buffer_len,
char *terminator, int timeout);
#ifdef __cplusplus
}
#endif