author | Florian Pose <fp@igh-essen.com> |
Mon, 15 Feb 2010 18:31:23 +0100 | |
changeset 1805 | 44dde06c0685 |
parent 1795 | 16c9640493fa |
child 1903 | 5b526d0f5a5d |
permissions | -rw-r--r-- |
1569 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 |
* |
|
7 |
* This file is part of the IgH EtherCAT master userspace library. |
|
8 |
* |
|
9 |
* The IgH EtherCAT master userspace library is free software; you can |
|
10 |
* redistribute it and/or modify it under the terms of the GNU Lesser General |
|
11 |
* Public License as published by the Free Software Foundation; version 2.1 |
|
12 |
* of the License. |
|
13 |
* |
|
14 |
* The IgH EtherCAT master userspace library is distributed in the hope that |
|
15 |
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
16 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU Lesser General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU Lesser General Public License |
|
20 |
* along with the IgH EtherCAT master userspace library. If not, see |
|
21 |
* <http://www.gnu.org/licenses/>. |
|
22 |
* |
|
23 |
* --- |
|
24 |
* |
|
25 |
* The license mentioned above concerns the source code only. Using the |
|
26 |
* EtherCAT technology and brand is only permitted in compliance with the |
|
27 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
|
28 |
* |
|
29 |
*****************************************************************************/ |
|
30 |
||
31 |
/** \file |
|
32 |
* |
|
33 |
* EtherCAT virtual TTY interface. |
|
34 |
* |
|
35 |
* \defgroup TTYInterface EtherCAT Virtual TTY Interface |
|
36 |
* |
|
37 |
* @{ |
|
38 |
*/ |
|
39 |
||
40 |
/*****************************************************************************/ |
|
41 |
||
42 |
#ifndef __ECTTY_H__ |
|
43 |
#define __ECTTY_H__ |
|
44 |
||
1795
16c9640493fa
Include termios.h from ectty.h.
Florian Pose <fp@igh-essen.com>
parents:
1787
diff
changeset
|
45 |
#include <linux/termios.h> |
16c9640493fa
Include termios.h from ectty.h.
Florian Pose <fp@igh-essen.com>
parents:
1787
diff
changeset
|
46 |
|
1569 | 47 |
/****************************************************************************** |
48 |
* Data types |
|
49 |
*****************************************************************************/ |
|
50 |
||
51 |
struct ec_tty; |
|
52 |
typedef struct ec_tty ec_tty_t; /**< \see ec_tty */ |
|
53 |
||
1787
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
54 |
/** |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
55 |
* \param cflag_changed This callback function is called when the serial |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
56 |
* settings shall be changed. The \a cflag argument contains the new settings. |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
57 |
*/ |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
58 |
typedef struct { |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
59 |
int (*cflag_changed)(void *, tcflag_t); |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
60 |
} ec_tty_operations_t; |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
61 |
|
1569 | 62 |
/****************************************************************************** |
63 |
* Global functions |
|
64 |
*****************************************************************************/ |
|
65 |
||
66 |
/** Create a virtual TTY interface. |
|
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
67 |
* |
1787
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
68 |
* \param ops Set of callbacks. |
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
69 |
* \param cb_data Arbitrary data, that is passed to any callback. |
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
70 |
* |
1569 | 71 |
* \return Pointer to the interface object, otherwise an ERR_PTR value. |
72 |
*/ |
|
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
73 |
ec_tty_t *ectty_create( |
1787
439f186185be
Callback set via own structure.
Florian Pose <fp@igh-essen.com>
parents:
1782
diff
changeset
|
74 |
const ec_tty_operations_t *ops, |
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
75 |
void *cb_data |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
76 |
); |
1569 | 77 |
|
78 |
/****************************************************************************** |
|
79 |
* TTY interface methods |
|
80 |
*****************************************************************************/ |
|
81 |
||
82 |
/** Releases a virtual TTY interface. |
|
83 |
*/ |
|
84 |
void ectty_free( |
|
85 |
ec_tty_t *tty /**< TTY interface. */ |
|
86 |
); |
|
87 |
||
1575 | 88 |
/** Reads data to send from the TTY interface. |
89 |
* |
|
90 |
* If there are data to send, they are copied into the \a buffer. At maximum, |
|
91 |
* \a size bytes are copied. The actual number of bytes copied is returned. |
|
92 |
* |
|
93 |
* \return Number of bytes copied. |
|
94 |
*/ |
|
95 |
unsigned int ectty_tx_data( |
|
96 |
ec_tty_t *tty, /**< TTY interface. */ |
|
97 |
uint8_t *buffer, /**< Buffer for data to transmit. */ |
|
98 |
size_t size /**< Available space in \a buffer. */ |
|
99 |
); |
|
100 |
||
1577
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
101 |
/** Pushes received data to the TTY interface. |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
102 |
*/ |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
103 |
void ectty_rx_data( |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
104 |
ec_tty_t *tty, /**< TTY interface. */ |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
); |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
108 |
|
1569 | 109 |
/*****************************************************************************/ |
110 |
||
111 |
/** @} */ |
|
112 |
||
113 |
#endif |