Update monitor response handling
r1056 | dcl | 2006-08-10 16:44:01 +1000 (Thu, 10 Aug 2006) | 2 lines
This commit is contained in:
@@ -184,7 +184,7 @@ static int MonDrainInput(CounterDriver *cntrData) {
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
static int MonHandleInput(CounterDriver *cntrData, BUFFER* bp) {
|
||||||
BeamMon* self = NULL;
|
BeamMon* self = NULL;
|
||||||
int iRet, len;
|
int iRet, len;
|
||||||
int iLen = 0;
|
int iLen = 0;
|
||||||
@@ -193,15 +193,41 @@ static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
|||||||
char* pTerm;
|
char* pTerm;
|
||||||
|
|
||||||
self = (BeamMon *) cntrData->pData;
|
self = (BeamMon *) cntrData->pData;
|
||||||
#if 0
|
/* TODO handle the line */
|
||||||
MonWrite(self, "SICS READ");
|
flog('<', bp->body);
|
||||||
self->buffer.length = sizeof(self->buffer.body);
|
const char et[] = "EVENT TERMINAL";
|
||||||
if (MonRead(self, self->buffer.body, &self->buffer.length) == SUCCESS) {
|
if (strncasecmp(bp->body, et, sizeof(et) - 1) == 0) {
|
||||||
HandleReport(cntrData, &self->buffer);
|
if (self->state == HWBusy)
|
||||||
return SUCCESS;
|
self->state = HWIdle;
|
||||||
}
|
}
|
||||||
return FAILURE;
|
const char eri[] = "EVENT RANGE IN";
|
||||||
#else
|
if (strncasecmp(bp->body, eri, sizeof(eri) - 1) == 0)
|
||||||
|
if (self->state == HWPause)
|
||||||
|
self->state = HWBusy;
|
||||||
|
const char ero[] = "EVENT RANGE OUT";
|
||||||
|
if (strncasecmp(bp->body, ero, sizeof(ero) - 1) == 0)
|
||||||
|
if (self->state == HWBusy)
|
||||||
|
self->state = HWPause;
|
||||||
|
const char rpt[] = "READ";
|
||||||
|
if (strncasecmp(bp->body, rpt, sizeof(rpt) - 1) == 0) {
|
||||||
|
if (self->state == HWBusy) {
|
||||||
|
HandleReport(cntrData, &self->buffer);
|
||||||
|
MonWrite(self, "SICS READ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bp->length = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MonLookForInput(CounterDriver *cntrData, int timeout) {
|
||||||
|
BeamMon* self = NULL;
|
||||||
|
int iRet, len;
|
||||||
|
int iLen = 0;
|
||||||
|
int jLen = 0;
|
||||||
|
char reply[1024];
|
||||||
|
char* pTerm;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData->pData;
|
||||||
while (availableRS232(self->controller)) {
|
while (availableRS232(self->controller)) {
|
||||||
len = sizeof(reply);
|
len = sizeof(reply);
|
||||||
iRet = MonRead(self, reply, &len);
|
iRet = MonRead(self, reply, &len);
|
||||||
@@ -221,36 +247,14 @@ static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
|||||||
self->buffer.length += jLen;
|
self->buffer.length += jLen;
|
||||||
self->buffer.body[self->buffer.length] = '\0';
|
self->buffer.body[self->buffer.length] = '\0';
|
||||||
iLen += jLen;
|
iLen += jLen;
|
||||||
if (pTerm)
|
if (pTerm) {
|
||||||
{
|
/* handle the line */
|
||||||
/* TODO handle the line */
|
MonHandleInput(cntrData, &self->buffer);
|
||||||
flog('<', self->buffer.body);
|
|
||||||
const char et[] = "EVENT TERMINAL";
|
|
||||||
if (strncasecmp(self->buffer.body, et, sizeof(et) - 1) == 0) {
|
|
||||||
if (self->state == HWBusy)
|
|
||||||
self->state = HWIdle;
|
|
||||||
}
|
|
||||||
const char eri[] = "EVENT RANGE IN";
|
|
||||||
if (strncasecmp(self->buffer.body, eri, sizeof(eri) - 1) == 0)
|
|
||||||
if (self->state == HWPause)
|
|
||||||
self->state = HWBusy;
|
|
||||||
const char ero[] = "EVENT RANGE OUT";
|
|
||||||
if (strncasecmp(self->buffer.body, ero, sizeof(ero) - 1) == 0)
|
|
||||||
if (self->state == HWBusy)
|
|
||||||
self->state = HWPause;
|
|
||||||
const char rpt[] = "READ";
|
|
||||||
if (strncasecmp(self->buffer.body, rpt, sizeof(rpt) - 1) == 0) {
|
|
||||||
if (self->state == HWBusy) {
|
|
||||||
HandleReport(cntrData, &self->buffer);
|
|
||||||
MonWrite(self, "SICS READ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self->buffer.length = 0;
|
|
||||||
}
|
}
|
||||||
|
self->buffer.length = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Returns the counter status,
|
/** \brief Returns the counter status,
|
||||||
@@ -270,11 +274,11 @@ static int MonGetStatus(CounterDriver *cntrData, float *fControl) {
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
self = (BeamMon *) cntrData->pData;
|
self = (BeamMon *) cntrData->pData;
|
||||||
MonHandleInput(cntrData, 0);
|
MonLookForInput(cntrData, 0);
|
||||||
status = MonSend(cntrData, "SICS READ", self->buffer.body, sizeof(self->buffer.body));
|
status = MonSend(cntrData, "SICS READ", self->buffer.body, sizeof(self->buffer.body));
|
||||||
if (status == SUCCESS) {
|
if (status == SUCCESS) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
HandleReport(cntrData, &self->buffer);
|
MonHandleInput(cntrData, &self->buffer);
|
||||||
}
|
}
|
||||||
if (cntrData->eMode == eTimer)
|
if (cntrData->eMode == eTimer)
|
||||||
*fControl = cntrData->fTime;
|
*fControl = cntrData->fTime;
|
||||||
@@ -386,8 +390,8 @@ static int MonReadValues(CounterDriver *cntrData) {
|
|||||||
self = (BeamMon *) cntrData->pData;
|
self = (BeamMon *) cntrData->pData;
|
||||||
if (MonSend(cntrData, "SICS READ",
|
if (MonSend(cntrData, "SICS READ",
|
||||||
self->buffer.body, sizeof(self->buffer.body)) == SUCCESS) {
|
self->buffer.body, sizeof(self->buffer.body)) == SUCCESS) {
|
||||||
/* TODO*/
|
|
||||||
HandleReport(cntrData, &self->buffer);
|
HandleReport(cntrData, &self->buffer);
|
||||||
|
lCounts[0] = self->counter_value;
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user