aqhome-nodes: allow for TTY interface without ATTN line.
This commit is contained in:
@@ -445,6 +445,7 @@ void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs)
|
||||
xo->dbArgs=dbArgs;
|
||||
|
||||
xo->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
|
||||
xo->noAttn=GWEN_DB_GetIntValue(dbArgs, "noAttn", 0, 0);
|
||||
xo->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
|
||||
|
||||
AQH_NodeServer_SetDbFile(o, GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, NULL));
|
||||
@@ -534,7 +535,7 @@ int _startTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo)
|
||||
DBG_INFO(NULL, "here");
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
xo->ttyEndpoint=AQH_TtyEndpoint2_new(AQH_Object_GetEventLoop(o), fd);
|
||||
xo->ttyEndpoint=AQH_TtyEndpoint2_new(AQH_Object_GetEventLoop(o), fd, xo->noAttn);
|
||||
AQH_Object_AddLink(xo->ttyEndpoint, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_NODE_SERVER_SLOT_TTYCLOSED, o);
|
||||
AQH_Object_Enable(xo->ttyEndpoint);
|
||||
}
|
||||
@@ -1410,6 +1411,7 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs)
|
||||
{ A_ARG, A_CHAR, "dbfile", 0, 1, "db", "dbfile", I18S("DB file to read/write node database"), NULL},
|
||||
{ A_ARG, A_CHAR, "pidfile", 0, 1, "p", "pidfile", I18S("PID file"), NULL},
|
||||
{ A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("timeout in seconds [0]"), NULL},
|
||||
{ 0, A_INT, "noAttn", 0, 1, "N", "noattn", I18S("Don't use ATTN line (for T03 or newer)"), NULL},
|
||||
{ A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ struct AQH_NODE_SERVER {
|
||||
uint8_t protoId;
|
||||
uint8_t protoVer;
|
||||
|
||||
int noAttn;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd)
|
||||
AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd, int noAttn)
|
||||
{
|
||||
int fdCopy;
|
||||
AQH_OBJECT *fdReader;
|
||||
@@ -46,6 +46,10 @@ AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd)
|
||||
AQH_Object_Enable(msgReader);
|
||||
|
||||
fdWriter=AQH_TtyObject_new(eventLoop, fdCopy, AQH_FDOBJECT_FDMODE_WRITE);
|
||||
if (noAttn) {
|
||||
DBG_ERROR(NULL, "Adding noAttn flag");
|
||||
AQH_Object_AddFlags(fdWriter, AQH_TTYOBJECT_FLAGS_NOATTN);
|
||||
}
|
||||
msgWriter=AQH_MsgWriter_new(eventLoop, fdWriter);
|
||||
|
||||
endpoint=AQH_Endpoint_new(eventLoop, msgReader, msgWriter);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @param eventLoop pointer to eventLoop
|
||||
* @param fd open file descriptor for tty object (see @ref AQH_TtyObject_OpenAndInitDevice).
|
||||
*/
|
||||
AQHOME_API AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd);
|
||||
AQHOME_API AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd, int noAttn);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,24 +61,28 @@ AQH_OBJECT *AQH_TtyObject_new(AQH_EVENT_LOOP *eventLoop, int fd, int fdMode)
|
||||
int _startMsg(AQH_OBJECT *o)
|
||||
{
|
||||
if (o) {
|
||||
int fd;
|
||||
int rv;
|
||||
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd==-1)
|
||||
return GWEN_ERROR_IO;
|
||||
rv=_getAttn(fd);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
else if (rv==0) {
|
||||
DBG_ERROR(NULL, "Line busy");
|
||||
return GWEN_ERROR_TRY_AGAIN; /* line busy */
|
||||
}
|
||||
else {
|
||||
_setAttn(fd, 0); /* set ATTN low */
|
||||
if (AQH_Object_GetFlags(o) & AQH_TTYOBJECT_FLAGS_NOATTN)
|
||||
return 0;
|
||||
else {
|
||||
int fd;
|
||||
int rv;
|
||||
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd==-1)
|
||||
return GWEN_ERROR_IO;
|
||||
rv=_getAttn(fd);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
else if (rv==0) {
|
||||
DBG_ERROR(NULL, "Line busy");
|
||||
return GWEN_ERROR_TRY_AGAIN; /* line busy */
|
||||
}
|
||||
else {
|
||||
_setAttn(fd, 0); /* set ATTN low */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -90,11 +94,13 @@ int _startMsg(AQH_OBJECT *o)
|
||||
void _endMsg(AQH_OBJECT *o)
|
||||
{
|
||||
if (o) {
|
||||
int fd;
|
||||
if (!(AQH_Object_GetFlags(o) & AQH_TTYOBJECT_FLAGS_NOATTN)) {
|
||||
int fd;
|
||||
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd>=0) {
|
||||
_setAttn(fd, 1); /* set ATTN high */
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd>=0) {
|
||||
_setAttn(fd, 1); /* set ATTN high */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
#define AQH_TTYOBJECT_FLAGS_NOATTN 0x0001
|
||||
|
||||
|
||||
/**
|
||||
* Create Tty object for given filedescriptor and in given mode (read or write)
|
||||
|
||||
Reference in New Issue
Block a user