author | Philipp Weyer <pw@igh-essen.com> |
Fri, 18 Aug 2017 12:30:16 +0200 | |
changeset 2679 | 33b922ec1871 |
parent 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
5 |
* Copyright (C) 2009-2010 Moehwald GmbH B. Benner |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
6 |
* 2011 IgH Andreas Stewering-Bone |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
7 |
* 2012 Florian Pose <fp@igh-essen.com> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
8 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
9 |
* This file is part of the IgH EtherCAT master |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
10 |
* |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
11 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
12 |
* modify it under the terms of the GNU General Public License version 2, as |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
13 |
* published by the Free Software Foundation. |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
14 |
* |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
15 |
* The IgH EtherCAT master is distributed in the hope that it will be useful, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
18 |
* Public License for more details. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
19 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
20 |
* You should have received a copy of the GNU General Public License along |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
21 |
* with the IgH EtherCAT master. If not, see <http://www.gnu.org/licenses/>. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
22 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
23 |
* --- |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
24 |
* |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
25 |
* The license mentioned above concerns the source code only. Using the |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
26 |
* EtherCAT technology and brand is only permitted in compliance with the |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
27 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
28 |
* |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
29 |
*****************************************************************************/ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
30 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
31 |
#include <errno.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
32 |
#include <signal.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
33 |
#include <stdio.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
34 |
#include <string.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
35 |
#include <sys/resource.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
36 |
#include <sys/time.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <sys/types.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
38 |
#include <unistd.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
39 |
#include <sys/mman.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
40 |
#include <rtdm/rtdm.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <native/task.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
42 |
#include <native/sem.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
43 |
#include <native/mutex.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
44 |
#include <native/timer.h> |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
45 |
#include <rtdk.h> |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
46 |
#include <pthread.h> |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
47 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
48 |
#include "ecrt.h" |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
49 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
50 |
RT_TASK my_task; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
51 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
52 |
static int run = 1; |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
53 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
54 |
/****************************************************************************/ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
55 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
56 |
// EtherCAT |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
57 |
static ec_master_t *master = NULL; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
58 |
static ec_master_state_t master_state = {}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
59 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
60 |
static ec_domain_t *domain1 = NULL; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
61 |
static ec_domain_state_t domain1_state = {}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
62 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
63 |
static uint8_t *domain1_pd = NULL; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
64 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
65 |
static ec_slave_config_t *sc_dig_out_01 = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
66 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
67 |
/****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
68 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
69 |
// process data |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
70 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
71 |
#define BusCoupler01_Pos 0, 0 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
72 |
#define DigOutSlave01_Pos 0, 1 |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
73 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
74 |
#define Beckhoff_EK1100 0x00000002, 0x044c2c52 |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
75 |
#define Beckhoff_EL2004 0x00000002, 0x07d43052 |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
76 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
77 |
// offsets for PDO entries |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
78 |
static unsigned int off_dig_out0 = 0; |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
79 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
80 |
// process data |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
81 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
82 |
const static ec_pdo_entry_reg_t domain1_regs[] = { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
83 |
{DigOutSlave01_Pos, Beckhoff_EL2004, 0x7000, 0x01, &off_dig_out0, NULL}, |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
84 |
{} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
85 |
}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
86 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
87 |
/****************************************************************************/ |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
88 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
89 |
/* Slave 1, "EL2004" |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
90 |
* Vendor ID: 0x00000002 |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
91 |
* Product code: 0x07d43052 |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
92 |
* Revision number: 0x00100000 |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
93 |
*/ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
94 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
95 |
ec_pdo_entry_info_t slave_1_pdo_entries[] = { |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
96 |
{0x7000, 0x01, 1}, /* Output */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
97 |
{0x7010, 0x01, 1}, /* Output */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
98 |
{0x7020, 0x01, 1}, /* Output */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
99 |
{0x7030, 0x01, 1}, /* Output */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
100 |
}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
101 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
102 |
ec_pdo_info_t slave_1_pdos[] = { |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
103 |
{0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
104 |
{0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
105 |
{0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
106 |
{0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
107 |
}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
108 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
109 |
ec_sync_info_t slave_1_syncs[] = { |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
110 |
{0, EC_DIR_OUTPUT, 4, slave_1_pdos + 0, EC_WD_ENABLE}, |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
111 |
{0xff} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
112 |
}; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
113 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
114 |
/***************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
115 |
* Realtime task |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
116 |
****************************************************************************/ |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
117 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
118 |
void rt_check_domain_state(void) |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
119 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
120 |
ec_domain_state_t ds = {}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
121 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
122 |
ecrt_domain_state(domain1, &ds); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
123 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
124 |
if (ds.working_counter != domain1_state.working_counter) { |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
125 |
rt_printf("Domain1: WC %u.\n", ds.working_counter); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
126 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
127 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
128 |
if (ds.wc_state != domain1_state.wc_state) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
129 |
rt_printf("Domain1: State %u.\n", ds.wc_state); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
130 |
} |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
131 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
132 |
domain1_state = ds; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
133 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
134 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
135 |
/****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
136 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
137 |
void rt_check_master_state(void) |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
138 |
{ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
139 |
ec_master_state_t ms; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
140 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
141 |
ecrt_master_state(master, &ms); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
142 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
143 |
if (ms.slaves_responding != master_state.slaves_responding) { |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
144 |
rt_printf("%u slave(s).\n", ms.slaves_responding); |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
145 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
146 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
147 |
if (ms.al_states != master_state.al_states) { |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
148 |
rt_printf("AL states: 0x%02X.\n", ms.al_states); |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
149 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
150 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
151 |
if (ms.link_up != master_state.link_up) { |
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
152 |
rt_printf("Link is %s.\n", ms.link_up ? "up" : "down"); |
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
153 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
154 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
155 |
master_state = ms; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
156 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
157 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
158 |
/****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
159 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
160 |
void my_task_proc(void *arg) |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
161 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
162 |
int cycle_counter = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
163 |
unsigned int blink = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
164 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
165 |
rt_task_set_periodic(NULL, TM_NOW, 1000000); // ns |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
166 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
167 |
while (run) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
168 |
rt_task_wait_period(NULL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
169 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
170 |
cycle_counter++; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
171 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
172 |
// receive EtherCAT frames |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
173 |
ecrt_master_receive(master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
174 |
ecrt_domain_process(domain1); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
175 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
176 |
rt_check_domain_state(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
177 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
178 |
if (!(cycle_counter % 1000)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
179 |
rt_check_master_state(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
180 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
181 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
182 |
if (!(cycle_counter % 200)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
183 |
blink = !blink; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
184 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
185 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
186 |
EC_WRITE_U8(domain1_pd + off_dig_out0, blink ? 0x0 : 0x0F); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
187 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
188 |
// send process data |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
189 |
ecrt_domain_queue(domain1); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
190 |
ecrt_master_send(master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
191 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
192 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
193 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
194 |
/**************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
195 |
* Signal handler |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
196 |
***************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
197 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
198 |
void signal_handler(int sig) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
199 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
200 |
run = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
201 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
202 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
203 |
/**************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
204 |
* Main function |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
205 |
***************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
206 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
207 |
int main(int argc, char *argv[]) |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
208 |
{ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
209 |
ec_slave_config_t *sc; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
210 |
int ret; |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
211 |
|
2055
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
212 |
/* Perform auto-init of rt_print buffers if the task doesn't do so */ |
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
213 |
rt_print_auto_init(1); |
d246ab6b50d2
Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2054
diff
changeset
|
214 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
215 |
signal(SIGTERM, signal_handler); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
216 |
signal(SIGINT, signal_handler); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
217 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
218 |
mlockall(MCL_CURRENT | MCL_FUTURE); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
219 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
220 |
printf("Requesting master...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
221 |
master = ecrt_request_master(0); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
222 |
if (!master) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
223 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
224 |
} |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
225 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
226 |
domain1 = ecrt_master_create_domain(master); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
227 |
if (!domain1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
228 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
229 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
230 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
231 |
printf("Creating slave configurations...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
232 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
233 |
// Create configuration for bus coupler |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
234 |
sc = ecrt_master_slave_config(master, BusCoupler01_Pos, Beckhoff_EK1100); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
235 |
if (!sc) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
236 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
237 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
238 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
239 |
sc_dig_out_01 = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
240 |
ecrt_master_slave_config(master, DigOutSlave01_Pos, Beckhoff_EL2004); |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
241 |
if (!sc_dig_out_01) { |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
242 |
fprintf(stderr, "Failed to get slave configuration.\n"); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
243 |
return -1; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
244 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
245 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
246 |
if (ecrt_slave_config_pdos(sc_dig_out_01, EC_END, slave_1_syncs)) { |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
247 |
fprintf(stderr, "Failed to configure PDOs.\n"); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
248 |
return -1; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
249 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
250 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
251 |
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
252 |
fprintf(stderr, "PDO entry registration failed!\n"); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
253 |
return -1; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
254 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
255 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
256 |
printf("Activating master...\n"); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
257 |
if (ecrt_master_activate(master)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
258 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
259 |
} |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
260 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
261 |
if (!(domain1_pd = ecrt_domain_data(domain1))) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
262 |
fprintf(stderr, "Failed to get domain data pointer.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
263 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
264 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
265 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
266 |
ret = rt_task_create(&my_task, "my_task", 0, 80, T_FPU); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
267 |
if (ret < 0) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
268 |
fprintf(stderr, "Failed to create task: %s\n", strerror(-ret)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
269 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
270 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
271 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
272 |
printf("Starting my_task...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
273 |
ret = rt_task_start(&my_task, &my_task_proc, NULL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
274 |
if (ret < 0) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
275 |
fprintf(stderr, "Failed to start task: %s\n", strerror(-ret)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
276 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
277 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
278 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
279 |
while (run) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
280 |
sched_yield(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
281 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
282 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2056
diff
changeset
|
283 |
printf("Deleting realtime task...\n"); |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
284 |
rt_task_delete(&my_task); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
285 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
286 |
printf("End of Program\n"); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
287 |
ecrt_release_master(master); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
288 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
289 |
return 0; |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
290 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
291 |
|
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
292 |
/****************************************************************************/ |