include/ectty.h
author Florian Pose <fp@igh-essen.com>
Tue, 19 Jan 2010 17:57:46 +0100
changeset 1774 a9143f82c7c5
parent 1577 fa3f66b783c1
child 1779 9fab229d6ca9
permissions -rw-r--r--
Fixed name of byte transmission time define; changed coding style.
1569
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT master userspace library.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *  
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT master userspace library is free software; you can
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  Public License as published by the Free Software Foundation; version 2.1
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  of the License.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT master userspace library is distributed in the hope that
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU Lesser General Public License for more details.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU Lesser General Public License
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT master userspace library. If not, see
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  <http://www.gnu.org/licenses/>.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *  
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  ---
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  The license mentioned above concerns the source code only. Using the
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  EtherCAT technology and brand is only permitted in compliance with the
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  industrial property and similar rights of Beckhoff Automation GmbH.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
/** \file
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 * EtherCAT virtual TTY interface.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 * \defgroup TTYInterface EtherCAT Virtual TTY Interface
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 *
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 * @{
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
 */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
/*****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#ifndef __ECTTY_H__
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#define __ECTTY_H__
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
/******************************************************************************
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 * Data types 
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 *****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
struct ec_tty;
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
typedef struct ec_tty ec_tty_t; /**< \see ec_tty */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
/******************************************************************************
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 * Global functions
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 *****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
/** Create a virtual TTY interface.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
 * 
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
 * \return Pointer to the interface object, otherwise an ERR_PTR value.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
 */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
ec_tty_t *ectty_create(void);
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
/******************************************************************************
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
 * TTY interface methods
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
 *****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
/** Releases a virtual TTY interface.
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
 */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
void ectty_free(
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        ec_tty_t *tty /**< TTY interface. */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        );
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
1575
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    72
/** Reads data to send from the TTY interface.
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    73
 *
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    74
 * If there are data to send, they are copied into the \a buffer. At maximum,
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    75
 * \a size bytes are copied. The actual number of bytes copied is returned.
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    76
 *
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    77
 * \return Number of bytes copied.
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    78
 */
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    79
unsigned int ectty_tx_data(
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    80
        ec_tty_t *tty, /**< TTY interface. */
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    81
        uint8_t *buffer, /**< Buffer for data to transmit. */
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    82
        size_t size /**< Available space in \a buffer. */
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    83
        );
17598f2332b6 Send direction works!
Florian Pose <fp@igh-essen.com>
parents: 1569
diff changeset
    84
1577
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    85
/** Pushes received data to the TTY interface.
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    86
 */
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    87
void ectty_rx_data(
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    88
        ec_tty_t *tty, /**< TTY interface. */
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    89
        const uint8_t *buffer, /**< Buffer with received data. */
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    90
        size_t size /**< Number of bytes in \a buffer. */
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    91
        );
fa3f66b783c1 Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents: 1575
diff changeset
    92
1569
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
/*****************************************************************************/
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
/** @} */
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
61f5f4c35883 Interface management.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
#endif