aqhome: started rewriting message code, start using new event2 lib.
This commit is contained in:
@@ -17,6 +17,15 @@
|
||||
#include "aqhome/hexfile/hexfile.h"
|
||||
#include "aqhome/hexfile/flashrecord.h"
|
||||
|
||||
#include "aqhome/events2/eventloop.h"
|
||||
#include "aqhome/events2/fdobject.h"
|
||||
#include "aqhome/ipc2/ttyobject.h"
|
||||
#include "aqhome/ipc2/nodemsgreader.h"
|
||||
#include "aqhome/ipc2/msgreader.h"
|
||||
#include "aqhome/ipc2/msgwriter.h"
|
||||
#include "aqhome/ipc2/nodeendpoint.h"
|
||||
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
@@ -463,6 +472,51 @@ int testFlashRecords(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
int testTty(int argc, char **argv)
|
||||
{
|
||||
const char *deviceName;
|
||||
AQH_EVENT_LOOP *eventLoop;
|
||||
struct termios initialTermiosState;
|
||||
int fd;
|
||||
AQH_OBJECT *ttyReadObject;
|
||||
AQH_OBJECT *msgReaderObject;
|
||||
AQH_OBJECT *nodeEndpointObject;
|
||||
int rv;
|
||||
|
||||
if (argc<2) {
|
||||
fprintf(stderr, "Missing device name\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv=AQH_Init();
|
||||
if (rv<0) {
|
||||
}
|
||||
|
||||
deviceName=argv[1];
|
||||
|
||||
eventLoop=AQH_EventLoop_new();
|
||||
fd=AQH_TtyObject_OpenAndInitDevice(deviceName, &initialTermiosState);
|
||||
if (fd<0) {
|
||||
fprintf(stderr, "Error opening device \"%s\"\n", deviceName);
|
||||
return 2;
|
||||
}
|
||||
|
||||
ttyReadObject=AQH_TtyObject_new(eventLoop, fd, AQH_FDOBJECT_FDMODE_READ);
|
||||
AQH_FdObject_FlushInput(ttyReadObject);
|
||||
msgReaderObject=AQH_NodeMsgReader_new(eventLoop, ttyReadObject);
|
||||
nodeEndpointObject=AQH_NodeEndpoint_new(eventLoop, msgReaderObject, NULL);
|
||||
|
||||
AQH_Object_Enable(msgReaderObject);
|
||||
|
||||
for (;;) {
|
||||
AQH_EventLoop_Run(eventLoop);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -471,7 +525,8 @@ int main(int argc, char **argv)
|
||||
//return testMqttConnection2();
|
||||
//return testMqttSubscribe2(argc, argv);
|
||||
//return testHttpDaemon();
|
||||
return testMqttSubscribe3(argc, argv);
|
||||
//return testMqttSubscribe3(argc, argv);
|
||||
return testTty(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user