*** empty log message ***
This commit is contained in:
69
tecs/tecc.c
69
tecs/tecc.c
@@ -1,27 +1,22 @@
|
||||
#include "errhdl.h"
|
||||
#include "client.h"
|
||||
#include "tecc.h"
|
||||
|
||||
char command[80], response[80], device[80];
|
||||
float tempX, tempP, tempC;
|
||||
static char device[80], command[80];
|
||||
static int quit;
|
||||
static float tempX, tempP, tempC;
|
||||
|
||||
pTecsClient TeccInit(char *server) {
|
||||
pTecsClient TeccInit(char *startcmd, int port) {
|
||||
CocConn *conn;
|
||||
char buf[80];
|
||||
|
||||
ERR_SP(conn=(CocConn *)malloc(sizeof(*conn)));
|
||||
#ifdef __VMS
|
||||
sprintf(buf, "@start_tecs %s", server);
|
||||
#else
|
||||
sprintf(buf, "start_tecs %s", server);
|
||||
#endif
|
||||
CocInitClient(conn, "", "#rwacs", 0, buf);
|
||||
ERR_I(CocInitClient(conn, "", port, "#rwacs", 0, startcmd));
|
||||
CocDefFlt(tempX, CocRD);
|
||||
CocDefFlt(tempP, CocRD);
|
||||
CocDefFlt(tempC, CocWR);
|
||||
CocDefStr(device, CocWR);
|
||||
CocDefStr(command, CocWR);
|
||||
CocDefStr(response, CocWR);
|
||||
CocDefInt(quit, CocWR);
|
||||
CocDefCmd(command);
|
||||
|
||||
return((pTecsClient)conn);
|
||||
OnError: return(NULL);
|
||||
}
|
||||
@@ -39,13 +34,6 @@ char *TeccGetDev(pTecsClient conn) {
|
||||
OnError: return(NULL);
|
||||
}
|
||||
|
||||
int TeccGet(pTecsClient conn, float *temp) {
|
||||
ERR_I(CocCmd((CocConn *)conn, "tempP"));
|
||||
*temp=tempP;
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int TeccGet3(pTecsClient conn, float temp[3]) {
|
||||
ERR_I(CocCmd((CocConn *)conn, "tempC,tempX,tempP"));
|
||||
temp[0]=tempC;
|
||||
@@ -55,6 +43,14 @@ int TeccGet3(pTecsClient conn, float temp[3]) {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int TeccGet(pTecsClient conn, float *temp) {
|
||||
float t[3];
|
||||
ERR_I(TeccGet3(conn, t));
|
||||
*temp=t[2];
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int TeccSet(pTecsClient conn, float temp) {
|
||||
tempC=temp;
|
||||
ERR_I(CocCmd((CocConn *)conn, "[tempC]"));
|
||||
@@ -63,17 +59,30 @@ int TeccSet(pTecsClient conn, float temp) {
|
||||
}
|
||||
|
||||
int TeccSend(pTecsClient conn, char *cmd, char *reply, int replyLen) {
|
||||
command[0]='\0';
|
||||
while (0!=strcmp(command, cmd)) {
|
||||
str_copy(command, cmd);
|
||||
strcpy(response,"<none>");
|
||||
ERR_I(CocCmd((CocConn *)conn, "[command,response]"));
|
||||
while (0==strcmp(response,"<none>") && 0==strcmp(command, cmd)) {
|
||||
util_delay(250);
|
||||
ERR_I(CocCmd((CocConn *)conn, "command,response"));
|
||||
char *res;
|
||||
int cnt;
|
||||
|
||||
str_copy(command, cmd);
|
||||
ERR_I(CocCmd((CocConn *)conn, "[$]"));
|
||||
cnt=40;
|
||||
util_delay(100);
|
||||
while (cnt>0) {
|
||||
ERR_I(CocCmd((CocConn *)conn, "$"));
|
||||
if (command[0]!='\0') {
|
||||
str_ncpy(reply, command, replyLen);
|
||||
return(0);
|
||||
}
|
||||
util_delay(250);
|
||||
cnt--;
|
||||
}
|
||||
str_ncpy(reply, response, replyLen);
|
||||
str_ncpy(reply, "<no response>", replyLen);
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int TeccQuitServer(pTecsClient conn) {
|
||||
quit=1;
|
||||
ERR_I(CocCmd((CocConn *)conn, "quit"));
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
@@ -119,7 +128,7 @@ int TeccSendVms(pTecsClient conn, char **cmd, char **reply) {
|
||||
strncpy(cbuf, cmd[1], l);
|
||||
while (l>0 && cbuf[l-1]==' ') l--; /* trim */
|
||||
cbuf[l]='\0';
|
||||
TeccSend(conn, cbuf, rbuf, sizeof(rbuf));
|
||||
ERR_I(TeccSend(conn, cbuf, rbuf, sizeof(rbuf)));
|
||||
lr=strlen(rbuf);
|
||||
l=*(short *)reply;
|
||||
if (lr>=l) lr=l;
|
||||
|
||||
Reference in New Issue
Block a user