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