author | Florian Pose <fp@igh-essen.com> |
Fri, 22 Jan 2010 10:36:36 +0100 | |
changeset 1780 | 11f452ca4d7a |
parent 1779 | 9fab229d6ca9 |
child 1782 | 2ba454c790c5 |
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 |
||
45 |
/****************************************************************************** |
|
46 |
* Data types |
|
47 |
*****************************************************************************/ |
|
48 |
||
49 |
struct ec_tty; |
|
50 |
typedef struct ec_tty ec_tty_t; /**< \see ec_tty */ |
|
51 |
||
52 |
/****************************************************************************** |
|
53 |
* Global functions |
|
54 |
*****************************************************************************/ |
|
55 |
||
56 |
/** Create a virtual TTY interface. |
|
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
57 |
* |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
58 |
* \param cflag_cb This callback function is called when the serial settings |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
59 |
* shall be changed. The \a cb_data argument is the same as the \a cb_data |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
60 |
* given on device creation, while the \a cflag argument contains the new |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
61 |
* settings. |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
62 |
* \param cb_data Arbitrary data to pass to callbacks. |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
63 |
* |
1569 | 64 |
* \return Pointer to the interface object, otherwise an ERR_PTR value. |
65 |
*/ |
|
1779
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
66 |
ec_tty_t *ectty_create( |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
67 |
int (*cflag_cb)(void *cb_data, unsigned short cflag), |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
68 |
void *cb_data |
9fab229d6ca9
Passing tty cflag to serial implementation.
Florian Pose <fp@igh-essen.com>
parents:
1577
diff
changeset
|
69 |
); |
1569 | 70 |
|
71 |
/****************************************************************************** |
|
72 |
* TTY interface methods |
|
73 |
*****************************************************************************/ |
|
74 |
||
75 |
/** Releases a virtual TTY interface. |
|
76 |
*/ |
|
77 |
void ectty_free( |
|
78 |
ec_tty_t *tty /**< TTY interface. */ |
|
79 |
); |
|
80 |
||
1575 | 81 |
/** Reads data to send from the TTY interface. |
82 |
* |
|
83 |
* If there are data to send, they are copied into the \a buffer. At maximum, |
|
84 |
* \a size bytes are copied. The actual number of bytes copied is returned. |
|
85 |
* |
|
86 |
* \return Number of bytes copied. |
|
87 |
*/ |
|
88 |
unsigned int ectty_tx_data( |
|
89 |
ec_tty_t *tty, /**< TTY interface. */ |
|
90 |
uint8_t *buffer, /**< Buffer for data to transmit. */ |
|
91 |
size_t size /**< Available space in \a buffer. */ |
|
92 |
); |
|
93 |
||
1577
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
94 |
/** Pushes received data to the TTY interface. |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
95 |
*/ |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
96 |
void ectty_rx_data( |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
97 |
ec_tty_t *tty, /**< TTY interface. */ |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
); |
fa3f66b783c1
Implemented reading direction of tty driver.
Florian Pose <fp@igh-essen.com>
parents:
1575
diff
changeset
|
101 |
|
1569 | 102 |
/*****************************************************************************/ |
103 |
||
104 |
/** @} */ |
|
105 |
||
106 |
#endif |