aqhome apps: sending a message via aqhome-nodes to nodes now works.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#define AQH_MSGWRITER_FLAGS_MSGSTARTED 0x0001
|
||||
#define AQH_MSGWRITER_FLAGS_MSGSTARTED 0x80000000
|
||||
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ int _handleSocketReady(AQH_OBJECT *o, AQH_OBJECT *fdObject)
|
||||
|
||||
if (xo->bytesLeft) {
|
||||
if (!(xo->flags & AQH_MSGWRITER_FLAGS_MSGSTARTED)) {
|
||||
DBG_ERROR(NULL, "Starting message");
|
||||
rv=_startMsg(xo, fdObject);
|
||||
if (rv<0) {
|
||||
if (rv==GWEN_ERROR_TRY_AGAIN) {
|
||||
@@ -166,6 +167,7 @@ int _handleSocketReady(AQH_OBJECT *o, AQH_OBJECT *fdObject)
|
||||
const uint8_t *msgPtr;
|
||||
|
||||
_endMsg(xo, fdObject);
|
||||
DBG_ERROR(NULL, "Ended message");
|
||||
msgPtr=xo->msgBufPtr;
|
||||
msgLen=xo->msgBufLen;
|
||||
_resetBuffer(o);
|
||||
|
||||
@@ -45,7 +45,7 @@ AQH_OBJECT *AQH_TtyEndpoint2_new(AQH_EVENT_LOOP *eventLoop, int fd)
|
||||
msgReader=AQH_NodeMsgReader_new(eventLoop, fdReader);
|
||||
AQH_Object_Enable(msgReader);
|
||||
|
||||
fdWriter=AQH_FdObject_new(eventLoop, fdCopy, AQH_FDOBJECT_FDMODE_WRITE);
|
||||
fdWriter=AQH_TtyObject_new(eventLoop, fdCopy, AQH_FDOBJECT_FDMODE_WRITE);
|
||||
msgWriter=AQH_MsgWriter_new(eventLoop, fdWriter);
|
||||
|
||||
endpoint=AQH_Endpoint_new(eventLoop, msgReader, msgWriter);
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_TTYOBJECT_BAUDRATE B19200
|
||||
@@ -35,6 +37,7 @@ static void _endMsg(AQH_OBJECT *o);
|
||||
static int _getAttn(int fd);
|
||||
static int _setAttn(int fd, int val);
|
||||
static int _fdSetBlocking(int sk, int fl);
|
||||
//static int _msleep(long int msec);
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +73,7 @@ int _startMsg(AQH_OBJECT *o)
|
||||
return rv;
|
||||
}
|
||||
else if (rv==0) {
|
||||
DBG_ERROR(NULL, "Line busy");
|
||||
return GWEN_ERROR_TRY_AGAIN; /* line busy */
|
||||
}
|
||||
else {
|
||||
@@ -89,8 +93,9 @@ void _endMsg(AQH_OBJECT *o)
|
||||
int fd;
|
||||
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd>=0)
|
||||
if (fd>=0) {
|
||||
_setAttn(fd, 1); /* set ATTN high */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +137,7 @@ int _setAttn(int fd, int val)
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl: %s (%d)", strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
DBG_ERROR(NULL, "Set ATTN to %d", val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -187,6 +193,12 @@ int AQH_TtyObject_OpenAndInitDevice(const char *device, struct termios *initialT
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
rv=_setAttn(fd, 1);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on setAttn(%s): %s (%d)", device, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -225,6 +237,26 @@ int _fdSetBlocking(int fd, int fl)
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int _msleep(long int msec)
|
||||
{
|
||||
struct timespec ts;
|
||||
int rv;
|
||||
|
||||
if (msec<0) {
|
||||
errno=EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ts.tv_sec=msec/1000;
|
||||
ts.tv_nsec=(msec%1000)*1000000;
|
||||
|
||||
do {
|
||||
rv=nanosleep(&ts, &ts);
|
||||
} while (rv && errno==EINTR);
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ AQHOME_API AQH_MESSAGE *AQH_IpcnMessageSetAcceptedMsgGroups_new(uint16_t code, u
|
||||
AQHOME_API void AQH_IpcdMessageSetAcceptedMsgGroups_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
|
||||
GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
uint32_t AQH_IpcnMessageSetAcceptedMsgGroups_GetGroups(const GWEN_TAG16_LIST *tagList);
|
||||
AQHOME_API uint32_t AQH_IpcnMessageSetAcceptedMsgGroups_GetGroups(const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user