fp@1569: /******************************************************************************
fp@1569: *
fp@1569: * $Id$
fp@1569: *
fp@1569: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
fp@1569: *
fp@1569: * This file is part of the IgH EtherCAT master userspace library.
fp@2421: *
fp@1569: * The IgH EtherCAT master userspace library is free software; you can
fp@1569: * redistribute it and/or modify it under the terms of the GNU Lesser General
fp@1569: * Public License as published by the Free Software Foundation; version 2.1
fp@1569: * of the License.
fp@1569: *
fp@1569: * The IgH EtherCAT master userspace library is distributed in the hope that
fp@1569: * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fp@1569: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fp@1569: * GNU Lesser General Public License for more details.
fp@1569: *
fp@1569: * You should have received a copy of the GNU Lesser General Public License
fp@1569: * along with the IgH EtherCAT master userspace library. If not, see
fp@1569: * .
fp@2421: *
fp@1569: * ---
fp@2421: *
fp@1569: * The license mentioned above concerns the source code only. Using the
fp@1569: * EtherCAT technology and brand is only permitted in compliance with the
fp@1569: * industrial property and similar rights of Beckhoff Automation GmbH.
fp@1569: *
fp@1569: *****************************************************************************/
fp@1569:
fp@1569: /** \file
fp@1569: *
fp@1569: * EtherCAT virtual TTY interface.
fp@1569: *
fp@1569: * \defgroup TTYInterface EtherCAT Virtual TTY Interface
fp@1569: *
fp@1569: * @{
fp@1569: */
fp@1569:
fp@1569: /*****************************************************************************/
fp@1569:
fp@1569: #ifndef __ECTTY_H__
fp@1569: #define __ECTTY_H__
fp@1569:
fp@1795: #include
fp@1795:
fp@1569: /******************************************************************************
fp@2421: * Data types
fp@1569: *****************************************************************************/
fp@1569:
fp@1569: struct ec_tty;
fp@1569: typedef struct ec_tty ec_tty_t; /**< \see ec_tty */
fp@1569:
fp@1903: /** Operations on the virtual TTY interface.
fp@1787: */
fp@1787: typedef struct {
fp@1903: int (*cflag_changed)(void *, tcflag_t); /**< Called when the serial
fp@1903: * settings shall be changed. The
fp@1903: * \a cflag argument contains the
fp@1903: * new settings. */
fp@1787: } ec_tty_operations_t;
fp@1787:
fp@1569: /******************************************************************************
fp@1569: * Global functions
fp@1569: *****************************************************************************/
fp@1569:
fp@1569: /** Create a virtual TTY interface.
fp@1779: *
fp@1787: * \param ops Set of callbacks.
fp@1787: * \param cb_data Arbitrary data, that is passed to any callback.
fp@1779: *
fp@1569: * \return Pointer to the interface object, otherwise an ERR_PTR value.
fp@1569: */
fp@1779: ec_tty_t *ectty_create(
fp@1787: const ec_tty_operations_t *ops,
fp@1779: void *cb_data
fp@1779: );
fp@1569:
fp@1569: /******************************************************************************
fp@1569: * TTY interface methods
fp@1569: *****************************************************************************/
fp@1569:
fp@1569: /** Releases a virtual TTY interface.
fp@1569: */
fp@1569: void ectty_free(
fp@1569: ec_tty_t *tty /**< TTY interface. */
fp@1569: );
fp@1569:
fp@1575: /** Reads data to send from the TTY interface.
fp@1575: *
fp@1575: * If there are data to send, they are copied into the \a buffer. At maximum,
fp@1575: * \a size bytes are copied. The actual number of bytes copied is returned.
fp@1575: *
fp@1575: * \return Number of bytes copied.
fp@1575: */
fp@1575: unsigned int ectty_tx_data(
fp@1575: ec_tty_t *tty, /**< TTY interface. */
fp@1575: uint8_t *buffer, /**< Buffer for data to transmit. */
fp@1575: size_t size /**< Available space in \a buffer. */
fp@1575: );
fp@1575:
fp@1577: /** Pushes received data to the TTY interface.
fp@1577: */
fp@1577: void ectty_rx_data(
fp@1577: ec_tty_t *tty, /**< TTY interface. */
fp@1577: const uint8_t *buffer, /**< Buffer with received data. */
fp@1577: size_t size /**< Number of bytes in \a buffer. */
fp@1577: );
fp@1577:
fp@1569: /*****************************************************************************/
fp@1569:
fp@1569: /** @} */
fp@1569:
fp@1569: #endif