Files
aqhomecontrol/aqhome/ipc2/tty_object.h
2025-03-21 20:54:19 +01:00

41 lines
1.3 KiB
C

/****************************************************************************
* This file is part of the project Gwenhywfar.
* Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_TTYOBJECT_H
#define AQH_TTYOBJECT_H
#include <aqhome/events2/object.h>
#include <termios.h>
#define AQH_TTYOBJECT_FLAGS_NOATTN 0x0001
/**
* Create Tty object for given filedescriptor and in given mode (read or write)
*
* @return object created
* @param eventLoop event loop to assign the new object to
* @param fd filedescriptor (e.g. created by calls to open or socket)
* @param fdMode AQH_FDOBJECT_FDMODE_READ or AQH_FDOBJECT_FDMODE_WRITE
*/
AQHOME_API AQH_OBJECT *AQH_TtyObject_new(AQH_EVENT_LOOP *eventLoop, int fd, int fdMode);
/**
* Open given device and setup TTY parameters for it.
*
* @return filedescriptor for the openened and initialized device
* @param device path to device to open (e.g. "/dev/ttyUSB0")
* @param initialTermiosState var to store initial state of the device (if given)
*/
AQHOME_API int AQH_TtyObject_OpenAndInitDevice(const char *device, struct termios *initialTermiosState);
#endif