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;
|
||||
}
|
||||
|
||||
static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
||||
static int MonHandleInput(CounterDriver *cntrData, BUFFER* bp) {
|
||||
BeamMon* self = NULL;
|
||||
int iRet, len;
|
||||
int iLen = 0;
|
||||
@@ -193,15 +193,41 @@ static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
||||
char* pTerm;
|
||||
|
||||
self = (BeamMon *) cntrData->pData;
|
||||
#if 0
|
||||
MonWrite(self, "SICS READ");
|
||||
self->buffer.length = sizeof(self->buffer.body);
|
||||
if (MonRead(self, self->buffer.body, &self->buffer.length) == SUCCESS) {
|
||||
HandleReport(cntrData, &self->buffer);
|
||||
return SUCCESS;
|
||||
/* TODO handle the line */
|
||||
flog('<', bp->body);
|
||||
const char et[] = "EVENT TERMINAL";
|
||||
if (strncasecmp(bp->body, et, sizeof(et) - 1) == 0) {
|
||||
if (self->state == HWBusy)
|
||||
self->state = HWIdle;
|
||||
}
|
||||
return FAILURE;
|
||||
#else
|
||||
const char eri[] = "EVENT RANGE IN";
|
||||
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)) {
|
||||
len = sizeof(reply);
|
||||
iRet = MonRead(self, reply, &len);
|
||||
@@ -221,36 +247,14 @@ static int MonHandleInput(CounterDriver *cntrData, int timeout) {
|
||||
self->buffer.length += jLen;
|
||||
self->buffer.body[self->buffer.length] = '\0';
|
||||
iLen += jLen;
|
||||
if (pTerm)
|
||||
{
|
||||
/* TODO handle the line */
|
||||
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");
|
||||
}
|
||||
if (pTerm) {
|
||||
/* handle the line */
|
||||
MonHandleInput(cntrData, &self->buffer);
|
||||
}
|
||||
self->buffer.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief Returns the counter status,
|
||||
@@ -270,11 +274,11 @@ static int MonGetStatus(CounterDriver *cntrData, float *fControl) {
|
||||
int status;
|
||||
|
||||
self = (BeamMon *) cntrData->pData;
|
||||
MonHandleInput(cntrData, 0);
|
||||
MonLookForInput(cntrData, 0);
|
||||
status = MonSend(cntrData, "SICS READ", self->buffer.body, sizeof(self->buffer.body));
|
||||
if (status == SUCCESS) {
|
||||
/* TODO */
|
||||
HandleReport(cntrData, &self->buffer);
|
||||
MonHandleInput(cntrData, &self->buffer);
|
||||
}
|
||||
if (cntrData->eMode == eTimer)
|
||||
*fControl = cntrData->fTime;
|
||||
@@ -386,8 +390,8 @@ static int MonReadValues(CounterDriver *cntrData) {
|
||||
self = (BeamMon *) cntrData->pData;
|
||||
if (MonSend(cntrData, "SICS READ",
|
||||
self->buffer.body, sizeof(self->buffer.body)) == SUCCESS) {
|
||||
/* TODO*/
|
||||
HandleReport(cntrData, &self->buffer);
|
||||
lCounts[0] = self->counter_value;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user