author | Florian Pose <fp@igh-essen.com> |
Fri, 22 Jan 2016 13:09:43 +0100 | |
changeset 2635 | 42b62867574d |
parent 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
543c4ce9e86e
Working RTAI RTDM module
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:
2059
diff
changeset
|
5 |
* Copyright (C) 2011 IgH Andreas Stewering-Bone |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
6 |
* 2012 Florian Pose <fp@igh-essen.com> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
7 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
8 |
* This file is part of the IgH EtherCAT master |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
9 |
* |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
10 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
11 |
* modify it under the terms of the GNU General Public License version 2, as |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
12 |
* published by the Free Software Foundation. |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
14 |
* 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:
2059
diff
changeset
|
15 |
* 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:
2059
diff
changeset
|
16 |
* 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:
2059
diff
changeset
|
17 |
* Public License for more details. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
18 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
19 |
* 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:
2059
diff
changeset
|
20 |
* 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:
2059
diff
changeset
|
21 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
22 |
* --- |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
23 |
* |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
29 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
30 |
#include <sched.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
31 |
#include <stdio.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
32 |
#include <stdlib.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
33 |
#include <fcntl.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
34 |
#include <signal.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
35 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
36 |
#include <rtai_lxrt.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <rtdm/rtdm.h> |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
38 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
39 |
#include "ecrt.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
40 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
41 |
#define rt_printf(X, Y) |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
42 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
43 |
#define NSEC_PER_SEC 1000000000 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
44 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
45 |
RT_TASK *task; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
46 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
47 |
const static unsigned int cycle_us = 1000; /* 1 ms */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
48 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
49 |
static int run = 1; |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
50 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
51 |
/****************************************************************************/ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
52 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
53 |
// EtherCAT |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
54 |
static ec_master_t *master = NULL; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
55 |
static ec_master_state_t master_state = {}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
56 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
57 |
static ec_domain_t *domain1 = NULL; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
58 |
static ec_domain_state_t domain1_state = {}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
59 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
60 |
static uint8_t *domain1_pd = NULL; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
61 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
62 |
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:
2059
diff
changeset
|
63 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
64 |
/****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
65 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
66 |
// process data |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
67 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
68 |
#define BusCoupler01_Pos 0, 0 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
69 |
#define DigOutSlave01_Pos 0, 1 |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
70 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
71 |
#define Beckhoff_EK1100 0x00000002, 0x044c2c52 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
72 |
#define Beckhoff_EL2004 0x00000002, 0x07d43052 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
73 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
74 |
// offsets for PDO entries |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
75 |
static unsigned int off_dig_out0 = 0; |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
76 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
77 |
// process data |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
78 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
79 |
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:
2059
diff
changeset
|
80 |
{DigOutSlave01_Pos, Beckhoff_EL2004, 0x7000, 0x01, &off_dig_out0, NULL}, |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
81 |
{} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
82 |
}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
83 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
84 |
/****************************************************************************/ |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
85 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
86 |
/* Slave 1, "EL2004" |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
87 |
* Vendor ID: 0x00000002 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
88 |
* Product code: 0x07d43052 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
89 |
* Revision number: 0x00100000 |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
90 |
*/ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
91 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
92 |
ec_pdo_entry_info_t slave_1_pdo_entries[] = { |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
93 |
{0x7000, 0x01, 1}, /* Output */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
94 |
{0x7010, 0x01, 1}, /* Output */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
95 |
{0x7020, 0x01, 1}, /* Output */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
96 |
{0x7030, 0x01, 1}, /* Output */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
97 |
}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
98 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
99 |
ec_pdo_info_t slave_1_pdos[] = { |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
100 |
{0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
101 |
{0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
102 |
{0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
103 |
{0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
104 |
}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
105 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
106 |
ec_sync_info_t slave_1_syncs[] = { |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
107 |
{0, EC_DIR_OUTPUT, 4, slave_1_pdos + 0, EC_WD_ENABLE}, |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
108 |
{0xff} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
109 |
}; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
110 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
111 |
/***************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
112 |
* Realtime task |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
113 |
****************************************************************************/ |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
114 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
115 |
void rt_check_domain_state(void) |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
116 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
117 |
ec_domain_state_t ds = {}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
118 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
119 |
ecrt_domain_state(domain1, &ds); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
120 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
121 |
if (ds.working_counter != domain1_state.working_counter) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
122 |
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:
2059
diff
changeset
|
123 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
124 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
125 |
if (ds.wc_state != domain1_state.wc_state) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
126 |
rt_printf("Domain1: State %u.\n", ds.wc_state); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
127 |
} |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
128 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
129 |
domain1_state = ds; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
130 |
} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
131 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
132 |
/****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
133 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
134 |
void rt_check_master_state(void) |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
135 |
{ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
136 |
ec_master_state_t ms; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
137 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
138 |
ecrt_master_state(master, &ms); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
139 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
140 |
if (ms.slaves_responding != master_state.slaves_responding) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
141 |
rt_printf("%u slave(s).\n", ms.slaves_responding); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
142 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
143 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
144 |
if (ms.al_states != master_state.al_states) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
145 |
rt_printf("AL states: 0x%02X.\n", ms.al_states); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
146 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
147 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
148 |
if (ms.link_up != master_state.link_up) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
149 |
rt_printf("Link is %s.\n", ms.link_up ? "up" : "down"); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
150 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
151 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
152 |
master_state = ms; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
153 |
} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
154 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
155 |
/****************************************************************************/ |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
156 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
157 |
void my_cyclic(void) |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
158 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
159 |
int cycle_counter = 0; |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
160 |
int period; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
161 |
unsigned int blink = 0; |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
162 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
163 |
rt_set_periodic_mode(); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
164 |
period = (int) nano2count((RTIME) cycle_us * 1000); |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
165 |
start_rt_timer(period); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
166 |
rt_make_hard_real_time(); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
167 |
rt_task_make_periodic(task, rt_get_time() + 10 * period, period); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
168 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
169 |
while (run) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
170 |
rt_task_wait_period(); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
171 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
172 |
cycle_counter++; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
173 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
174 |
// receive EtherCAT |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
175 |
ecrt_master_receive(master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
176 |
ecrt_domain_process(domain1); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
177 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
178 |
rt_check_domain_state(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
179 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
180 |
if (!(cycle_counter % 1000)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
181 |
rt_check_master_state(); |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
182 |
} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
183 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
184 |
if (!(cycle_counter % 200)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
185 |
blink = !blink; |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
186 |
} |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
187 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
188 |
EC_WRITE_U8(domain1_pd + off_dig_out0, blink ? 0x00 : 0x0F); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
189 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
190 |
// send process data |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
191 |
ecrt_domain_queue(domain1); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
192 |
ecrt_master_send(master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
193 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
194 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
195 |
rt_make_soft_real_time(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
196 |
stop_rt_timer(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
197 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
198 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
199 |
/**************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
200 |
* Signal handler |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
201 |
***************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
202 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
203 |
void signal_handler(int sig) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
204 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
205 |
run = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
206 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
207 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
208 |
/**************************************************************************** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
209 |
* Main function |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
210 |
***************************************************************************/ |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
211 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
212 |
int main(int argc, char *argv[]) |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
213 |
{ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
214 |
ec_slave_config_t *sc; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
215 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
216 |
signal(SIGTERM, signal_handler); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
217 |
signal(SIGINT, signal_handler); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
218 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
219 |
mlockall(MCL_CURRENT | MCL_FUTURE); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
220 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
221 |
printf("Requesting master...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
222 |
master = ecrt_request_master(0); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
223 |
if (!master) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
224 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
225 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
226 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
227 |
domain1 = ecrt_master_create_domain(master); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
228 |
if (!domain1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
229 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
230 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
231 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
232 |
printf("Creating slave configurations...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
233 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
234 |
// Create configuration for bus coupler |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
235 |
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:
2059
diff
changeset
|
236 |
if (!sc) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
237 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
238 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
239 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
240 |
sc_dig_out_01 = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
241 |
ecrt_master_slave_config(master, DigOutSlave01_Pos, Beckhoff_EL2004); |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
242 |
if (!sc_dig_out_01) { |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
243 |
fprintf(stderr, "Failed to get slave configuration.\n"); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
244 |
return -1; |
543c4ce9e86e
Working RTAI RTDM module
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:
2059
diff
changeset
|
246 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
247 |
if (ecrt_slave_config_pdos(sc_dig_out_01, EC_END, slave_1_syncs)) { |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
248 |
fprintf(stderr, "Failed to configure PDOs.\n"); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
249 |
return -1; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
250 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
251 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
252 |
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
253 |
fprintf(stderr, "PDO entry registration failed!\n"); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
254 |
return -1; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
255 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
256 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
257 |
printf("Activating master...\n"); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
258 |
if (ecrt_master_activate(master)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
259 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
260 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
261 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
262 |
if (!(domain1_pd = ecrt_domain_data(domain1))) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
263 |
fprintf(stderr, "Failed to get domain data pointer.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
264 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
265 |
} |
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
266 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
267 |
/* Create cyclic RT-thread */ |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
268 |
struct sched_param param; |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
269 |
param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
270 |
if (sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
271 |
puts("ERROR IN SETTING THE SCHEDULER"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
272 |
perror("errno"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
273 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
274 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
275 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
276 |
task = rt_task_init(nam2num("ec_rtai_rtdm_example"), |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
277 |
0 /* priority */, 0 /* stack size */, 0 /* msg size */); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
278 |
|
2058
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
279 |
my_cyclic(); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
280 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
281 |
rt_task_delete(task); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
282 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
283 |
printf("End of Program\n"); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
284 |
ecrt_release_master(master); |
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
285 |
|
543c4ce9e86e
Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff
changeset
|
286 |
return 0; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
287 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
288 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2059
diff
changeset
|
289 |
/****************************************************************************/ |