author | Florian Pose <fp@igh-essen.com> |
Wed, 18 Jun 2008 11:16:30 +0000 | |
changeset 1025 | ae175095f09a |
parent 1019 | ed69d862ff44 |
child 1029 | 61ffe5f22306 |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT master character device. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "cdev.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "master.h" |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
45 |
#include "slave_config.h" |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "ioctl.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
/** \cond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
int eccdev_open(struct inode *, struct file *); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
int eccdev_release(struct inode *, struct file *); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
54 |
long eccdev_ioctl(struct file *, unsigned int, unsigned long); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
static struct file_operations eccdev_fops = { |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
59 |
.owner = THIS_MODULE, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
60 |
.open = eccdev_open, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
61 |
.release = eccdev_release, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
62 |
.unlocked_ioctl = eccdev_ioctl |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
/** \endcond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
/** Constructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
* \return 0 in case of success, else < 0 |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
int ec_cdev_init( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
ec_master_t *master, /**< Parent master. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
dev_t dev_num /**< Device number. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
cdev->master = master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
cdev_init(&cdev->cdev, &eccdev_fops); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
cdev->cdev.owner = THIS_MODULE; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
if (cdev_add(&cdev->cdev, |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
MKDEV(MAJOR(dev_num), master->index), 1)) { |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
EC_ERR("Failed to add character device!\n"); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
return -1; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/** Destructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
void ec_cdev_clear(ec_cdev_t *cdev /**< EtherCAT XML device */) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
cdev_del(&cdev->cdev); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
* File operations |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
int eccdev_open(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
ec_cdev_t *cdev = container_of(inode->i_cdev, ec_cdev_t, cdev); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
109 |
ec_master_t *master = cdev->master; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
filp->private_data = cdev; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
112 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
113 |
EC_DBG("File opened.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
int eccdev_release(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
121 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
122 |
ec_master_t *master = cdev->master; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
123 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
124 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
125 |
EC_DBG("File closed.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
131 |
long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
132 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
133 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
ec_master_t *master = cdev->master; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
135 |
long retval = 0; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
if (master->debug_level) |
981
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
138 |
EC_DBG("ioctl(filp = %x, cmd = %u (%u), arg = %x)\n", |
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
139 |
(u32) filp, (u32) cmd, (u32) _IOC_NR(cmd), (u32) arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
140 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
141 |
// FIXME lock |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
142 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
switch (cmd) { |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
144 |
case EC_IOCTL_MASTER: |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
145 |
{ |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
146 |
ec_ioctl_master_t data; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
147 |
|
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
148 |
data.slave_count = master->slave_count; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
149 |
data.config_count = ec_master_config_count(master); |
1001
a8eab75aa8e3
Removed EC_IOCTL_DOMAIN_COUNT.
Florian Pose <fp@igh-essen.com>
parents:
999
diff
changeset
|
150 |
data.domain_count = ec_master_domain_count(master); |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
151 |
data.mode = (uint8_t) master->mode; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
152 |
|
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
153 |
memcpy(data.devices[0].address, master->main_mac, ETH_ALEN); |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
154 |
data.devices[0].attached = master->main_device.dev ? 1 : 0; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
155 |
data.devices[0].tx_count = master->main_device.tx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
156 |
data.devices[0].rx_count = master->main_device.rx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
157 |
memcpy(data.devices[1].address, master->backup_mac, ETH_ALEN); |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
158 |
data.devices[1].attached = master->backup_device.dev ? 1 : 0; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
159 |
data.devices[1].tx_count = master->backup_device.tx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
160 |
data.devices[1].rx_count = master->backup_device.rx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
161 |
|
999 | 162 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
163 |
retval = -EFAULT; |
|
164 |
break; |
|
165 |
} |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
166 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
167 |
case EC_IOCTL_SLAVE: |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
169 |
ec_ioctl_slave_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
170 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
171 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
172 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
173 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
174 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
175 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
176 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
177 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
178 |
master, 0, data.position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
179 |
EC_ERR("Slave %u does not exist!\n", data.position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
180 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
181 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
182 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
183 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
184 |
data.vendor_id = slave->sii.vendor_id; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
185 |
data.product_code = slave->sii.product_code; |
938
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
935
diff
changeset
|
186 |
data.revision_number = slave->sii.revision_number; |
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
935
diff
changeset
|
187 |
data.serial_number = slave->sii.serial_number; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
188 |
data.alias = slave->sii.alias; |
989
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
189 |
data.rx_mailbox_offset = slave->sii.rx_mailbox_offset; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
190 |
data.rx_mailbox_size = slave->sii.rx_mailbox_size; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
191 |
data.tx_mailbox_offset = slave->sii.tx_mailbox_offset; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
192 |
data.tx_mailbox_size = slave->sii.tx_mailbox_size; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
193 |
data.mailbox_protocols = slave->sii.mailbox_protocols; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
194 |
data.has_general_category = slave->sii.has_general; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
195 |
data.coe_details = slave->sii.coe_details; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
196 |
data.general_flags = slave->sii.general_flags; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
197 |
data.current_on_ebus = slave->sii.current_on_ebus; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
198 |
data.state = slave->current_state; |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
981
diff
changeset
|
199 |
data.error_flag = slave->error_flag; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
200 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
201 |
data.sync_count = slave->sii.sync_count; |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
202 |
data.sdo_count = ec_slave_sdo_count(slave); |
978 | 203 |
data.sii_nwords = slave->sii_nwords; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
204 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
205 |
if (slave->sii.name) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
206 |
strncpy(data.name, slave->sii.name, |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
207 |
EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
208 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
209 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
210 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
211 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
212 |
|
999 | 213 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
214 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
215 |
break; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
218 |
case EC_IOCTL_SYNC: |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
220 |
ec_ioctl_sync_t data; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
const ec_slave_t *slave; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
222 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
223 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
224 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
225 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
226 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
227 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
228 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
229 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
230 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
231 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
232 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
233 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
234 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
235 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
236 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
237 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
238 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
239 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
240 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
241 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
242 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
243 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
244 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
245 |
data.physical_start_address = sync->physical_start_address; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
246 |
data.default_size = sync->length; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
247 |
data.control_register = sync->control_register; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
248 |
data.enable = sync->enable; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
249 |
data.assign_source = sync->assign_source; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
250 |
data.pdo_count = ec_pdo_list_count(&sync->pdos); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
251 |
|
999 | 252 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
253 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
254 |
break; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
257 |
case EC_IOCTL_PDO: |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
258 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
259 |
ec_ioctl_pdo_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
260 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
261 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
262 |
const ec_pdo_t *pdo; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
263 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
264 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
265 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
266 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
267 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
268 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
269 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
270 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
271 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
272 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
273 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
274 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
275 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
276 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
277 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
278 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
279 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
280 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
281 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
282 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
283 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
284 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
285 |
&sync->pdos, data.pdo_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
286 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
287 |
"position %u in slave %u!\n", data.sync_index, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
288 |
data.pdo_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
289 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
290 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
291 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
292 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
293 |
data.dir = pdo->dir; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
294 |
data.index = pdo->index; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
295 |
data.entry_count = ec_pdo_entry_count(pdo); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
296 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
297 |
if (pdo->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
298 |
strncpy(data.name, pdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
299 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
300 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
301 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
302 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
303 |
|
999 | 304 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
305 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
306 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
307 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
308 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
309 |
case EC_IOCTL_PDO_ENTRY: |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
310 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
311 |
ec_ioctl_pdo_entry_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
312 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
313 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
314 |
const ec_pdo_t *pdo; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
315 |
const ec_pdo_entry_t *entry; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
316 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
317 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
318 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
319 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
320 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
321 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
322 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
323 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
324 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
325 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
326 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
327 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
328 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
329 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
330 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
331 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
332 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
333 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
334 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
335 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
336 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
337 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
338 |
&sync->pdos, data.pdo_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
339 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
340 |
"position %u in slave %u!\n", data.sync_index, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
341 |
data.pdo_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
342 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
343 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
344 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
345 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
346 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
347 |
pdo, data.entry_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
348 |
EC_ERR("Pdo 0x%04X does not contain an entry with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
349 |
"position %u in slave %u!\n", data.pdo_pos, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
350 |
data.entry_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
351 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
352 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
353 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
354 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
355 |
data.index = entry->index; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
356 |
data.subindex = entry->subindex; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
357 |
data.bit_length = entry->bit_length; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
358 |
if (entry->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
359 |
strncpy(data.name, entry->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
360 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
361 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
362 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
363 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
364 |
|
999 | 365 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
366 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
367 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
368 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
369 |
|
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
370 |
case EC_IOCTL_DOMAIN: |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
371 |
{ |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
372 |
ec_ioctl_domain_t data; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
373 |
const ec_domain_t *domain; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
374 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
375 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
376 |
retval = -EFAULT; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
377 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
378 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
379 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
380 |
if (!(domain = ec_master_find_domain(master, data.index))) { |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
381 |
EC_ERR("Domain %u does not exist!\n", data.index); |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
382 |
retval = -EINVAL; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
383 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
384 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
385 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
386 |
data.data_size = domain->data_size; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
387 |
data.logical_base_address = domain->logical_base_address; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
388 |
data.working_counter = domain->working_counter; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
389 |
data.expected_working_counter = domain->expected_working_counter; |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
390 |
data.fmmu_count = ec_domain_fmmu_count(domain); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
391 |
|
999 | 392 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
393 |
retval = -EFAULT; |
|
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
394 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
395 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
396 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
397 |
case EC_IOCTL_DOMAIN_FMMU: |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
398 |
{ |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
399 |
ec_ioctl_domain_fmmu_t data; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
400 |
const ec_domain_t *domain; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
401 |
const ec_fmmu_config_t *fmmu; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
402 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
403 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
404 |
retval = -EFAULT; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
405 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
406 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
407 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
408 |
if (!(domain = ec_master_find_domain(master, data.domain_index))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
409 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
410 |
retval = -EINVAL; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
411 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
412 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
413 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
414 |
if (!(fmmu = ec_domain_find_fmmu(domain, data.fmmu_index))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
415 |
EC_ERR("Domain %u has less than %u fmmu configurations.\n", |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
416 |
data.domain_index, data.fmmu_index + 1); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
417 |
retval = -EINVAL; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
418 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
419 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
420 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
421 |
data.slave_config_alias = fmmu->sc->alias; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
422 |
data.slave_config_position = fmmu->sc->position; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
423 |
data.fmmu_dir = fmmu->dir; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
424 |
data.logical_address = fmmu->logical_start_address; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
425 |
data.data_size = fmmu->data_size; |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
426 |
|
999 | 427 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
428 |
retval = -EFAULT; |
|
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
429 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
430 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
431 |
|
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
432 |
case EC_IOCTL_DATA: |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
433 |
{ |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
434 |
ec_ioctl_data_t data; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
435 |
const ec_domain_t *domain; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
436 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
437 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
438 |
retval = -EFAULT; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
439 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
440 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
441 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
442 |
if (!(domain = ec_master_find_domain(master, data.domain_index))) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
443 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
444 |
retval = -EINVAL; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
445 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
446 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
447 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
448 |
if (domain->data_size != data.data_size) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
449 |
EC_ERR("Data size mismatch %u/%u!\n", |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
450 |
data.data_size, domain->data_size); |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
451 |
retval = -EFAULT; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
452 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
453 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
454 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
455 |
if (copy_to_user((void __user *) data.target, domain->data, |
999 | 456 |
domain->data_size)) |
457 |
retval = -EFAULT; |
|
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
458 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
459 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
460 |
|
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
461 |
case EC_IOCTL_SET_DEBUG: |
972 | 462 |
if (!(filp->f_mode & FMODE_WRITE)) |
463 |
return -EPERM; |
|
999 | 464 |
if (ec_master_debug_level(master, (unsigned int) arg)) |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
465 |
retval = -EINVAL; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
466 |
break; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
467 |
|
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
468 |
case EC_IOCTL_SLAVE_STATE: |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
469 |
{ |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
470 |
ec_ioctl_slave_state_t data; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
471 |
ec_slave_t *slave; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
472 |
|
972 | 473 |
if (!(filp->f_mode & FMODE_WRITE)) |
474 |
return -EPERM; |
|
475 |
||
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
476 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
477 |
retval = -EFAULT; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
478 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
479 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
480 |
|
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
481 |
if (!(slave = ec_master_find_slave( |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
482 |
master, 0, data.slave_position))) { |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
483 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
484 |
retval = -EINVAL; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
485 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
486 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
487 |
|
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
488 |
ec_slave_request_state(slave, data.requested_state); |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
489 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
490 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
491 |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
492 |
case EC_IOCTL_SDO: |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
493 |
{ |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
494 |
ec_ioctl_sdo_t data; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
495 |
const ec_slave_t *slave; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
496 |
const ec_sdo_t *sdo; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
497 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
498 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
499 |
retval = -EFAULT; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
500 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
501 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
502 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
503 |
if (!(slave = ec_master_find_slave( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
504 |
master, 0, data.slave_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
505 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
506 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
507 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
508 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
509 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
510 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
511 |
slave, data.sdo_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
512 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
513 |
data.sdo_position, data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
514 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
515 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
516 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
517 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
518 |
data.sdo_index = sdo->index; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
519 |
data.max_subindex = sdo->max_subindex; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
520 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
521 |
if (sdo->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
522 |
strncpy(data.name, sdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
523 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
524 |
} else { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
525 |
data.name[0] = 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
526 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
527 |
|
999 | 528 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
529 |
retval = -EFAULT; |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
530 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
531 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
532 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
533 |
case EC_IOCTL_SDO_ENTRY: |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
534 |
{ |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
535 |
ec_ioctl_sdo_entry_t data; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
536 |
const ec_slave_t *slave; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
537 |
const ec_sdo_t *sdo; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
538 |
const ec_sdo_entry_t *entry; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
539 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
540 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
541 |
retval = -EFAULT; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
542 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
543 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
544 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
545 |
if (!(slave = ec_master_find_slave( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
546 |
master, 0, data.slave_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
547 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
548 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
549 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
550 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
551 |
|
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
552 |
if (data.sdo_spec <= 0) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
553 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
554 |
slave, -data.sdo_spec))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
555 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
556 |
-data.sdo_spec, data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
557 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
558 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
559 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
560 |
} else { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
561 |
if (!(sdo = ec_slave_get_sdo_const( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
562 |
slave, data.sdo_spec))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
563 |
EC_ERR("Sdo 0x%04X does not exist in slave %u!\n", |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
564 |
data.sdo_spec, data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
565 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
566 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
567 |
} |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
568 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
569 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
570 |
if (!(entry = ec_sdo_get_entry_const( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
571 |
sdo, data.sdo_entry_subindex))) { |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
572 |
EC_ERR("Sdo entry 0x%04X:%02X does not exist " |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
573 |
"in slave %u!\n", sdo->index, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
574 |
data.sdo_entry_subindex, data.slave_position); |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
575 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
576 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
577 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
578 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
579 |
data.data_type = entry->data_type; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
580 |
data.bit_length = entry->bit_length; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
581 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
582 |
if (entry->description) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
583 |
strncpy(data.description, entry->description, |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
584 |
EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
585 |
data.description[EC_IOCTL_STRING_SIZE - 1] |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
586 |
= 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
587 |
} else { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
588 |
data.description[0] = 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
589 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
590 |
|
999 | 591 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
592 |
retval = -EFAULT; |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
593 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
594 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
595 |
|
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
596 |
case EC_IOCTL_SDO_UPLOAD: |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
597 |
{ |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
598 |
ec_ioctl_sdo_upload_t data; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
599 |
ec_master_sdo_request_t request; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
600 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
601 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
602 |
retval = -EFAULT; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
603 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
604 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
605 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
606 |
if (!(request.slave = ec_master_find_slave( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
607 |
master, 0, data.slave_position))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
608 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
609 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
610 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
611 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
612 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
613 |
ec_sdo_request_init(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
614 |
ec_sdo_request_address(&request.req, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
615 |
data.sdo_index, data.sdo_entry_subindex); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
616 |
ecrt_sdo_request_read(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
617 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
618 |
// schedule request. |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
619 |
down(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
620 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
621 |
up(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
622 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
623 |
// wait for processing through FSM |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
624 |
if (wait_event_interruptible(master->sdo_queue, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
625 |
request.req.state != EC_REQUEST_QUEUED)) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
626 |
// interrupted by signal |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
627 |
down(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
628 |
if (request.req.state == EC_REQUEST_QUEUED) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
629 |
list_del(&request.req.list); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
630 |
up(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
631 |
retval = -EINTR; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
632 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
633 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
634 |
// request already processing: interrupt not possible. |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
635 |
up(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
636 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
637 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
638 |
// wait until master FSM has finished processing |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
639 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
640 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
641 |
if (request.req.state != EC_REQUEST_SUCCESS) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
642 |
retval = -EIO; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
643 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
644 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
645 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
646 |
if (request.req.data_size > data.target_size) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
647 |
EC_ERR("Buffer too small.\n"); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
648 |
retval = -EOVERFLOW; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
649 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
650 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
651 |
data.data_size = request.req.data_size; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
652 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
653 |
if (copy_to_user((void __user *) data.target, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
654 |
request.req.data, data.data_size)) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
655 |
retval = -EFAULT; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
656 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
657 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
658 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
659 |
retval = -EFAULT; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
660 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
661 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
662 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
663 |
ec_sdo_request_clear(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
664 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
665 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
666 |
|
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
667 |
case EC_IOCTL_SDO_DOWNLOAD: |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
668 |
{ |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
669 |
ec_ioctl_sdo_download_t data; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
670 |
ec_master_sdo_request_t request; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
671 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
672 |
if (!(filp->f_mode & FMODE_WRITE)) |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
673 |
return -EPERM; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
674 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
675 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
676 |
retval = -EFAULT; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
677 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
678 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
679 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
680 |
if (!(request.slave = ec_master_find_slave( |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
681 |
master, 0, data.slave_position))) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
682 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
683 |
retval = -EINVAL; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
684 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
685 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
686 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
687 |
// copy data to download |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
688 |
if (!data.data_size) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
689 |
EC_ERR("Zero data size!\n"); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
690 |
retval = -EINVAL; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
691 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
692 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
693 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
694 |
ec_sdo_request_init(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
695 |
ec_sdo_request_address(&request.req, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
696 |
data.sdo_index, data.sdo_entry_subindex); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
697 |
if (ec_sdo_request_alloc(&request.req, data.data_size)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
698 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
699 |
retval = -ENOMEM; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
700 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
701 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
702 |
if (copy_from_user(request.req.data, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
703 |
(void __user *) data.data, data.data_size)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
704 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
705 |
retval = -EFAULT; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
706 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
707 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
708 |
request.req.data_size = data.data_size; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
709 |
ecrt_sdo_request_write(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
710 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
711 |
// schedule request. |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
712 |
down(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
713 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
714 |
up(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
715 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
716 |
// wait for processing through FSM |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
717 |
if (wait_event_interruptible(master->sdo_queue, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
718 |
request.req.state != EC_REQUEST_QUEUED)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
719 |
// interrupted by signal |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
720 |
down(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
721 |
if (request.req.state == EC_REQUEST_QUEUED) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
722 |
list_del(&request.req.list); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
723 |
up(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
724 |
retval = -EINTR; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
725 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
726 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
727 |
// request already processing: interrupt not possible. |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
728 |
up(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
729 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
730 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
731 |
// wait until master FSM has finished processing |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
732 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
733 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
734 |
if (request.req.state != EC_REQUEST_SUCCESS) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
735 |
retval = -EIO; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
736 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
737 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
738 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
739 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
740 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
741 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
742 |
|
978 | 743 |
case EC_IOCTL_SII_READ: |
744 |
{ |
|
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
745 |
ec_ioctl_sii_t data; |
978 | 746 |
const ec_slave_t *slave; |
747 |
||
748 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
749 |
retval = -EFAULT; |
|
750 |
break; |
|
751 |
} |
|
752 |
||
753 |
if (!(slave = ec_master_find_slave( |
|
754 |
master, 0, data.slave_position))) { |
|
755 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
756 |
retval = -EINVAL; |
|
757 |
break; |
|
758 |
} |
|
759 |
||
760 |
if (!data.nwords |
|
761 |
|| data.offset + data.nwords > slave->sii_nwords) { |
|
762 |
EC_ERR("Invalid SII read offset/size %u/%u for slave " |
|
763 |
"SII size %u!\n", data.offset, |
|
764 |
data.nwords, slave->sii_nwords); |
|
765 |
retval = -EINVAL; |
|
766 |
break; |
|
767 |
} |
|
768 |
||
769 |
if (copy_to_user((void __user *) data.words, |
|
999 | 770 |
slave->sii_words + data.offset, data.nwords * 2)) |
771 |
retval = -EFAULT; |
|
978 | 772 |
break; |
773 |
} |
|
774 |
||
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
775 |
case EC_IOCTL_SII_WRITE: |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
776 |
{ |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
777 |
ec_ioctl_sii_t data; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
778 |
ec_slave_t *slave; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
779 |
unsigned int byte_size; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
780 |
uint16_t *words; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
781 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
782 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
783 |
retval = -EFAULT; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
784 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
785 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
786 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
787 |
if (!(slave = ec_master_find_slave( |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
788 |
master, 0, data.slave_position))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
789 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
790 |
retval = -EINVAL; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
791 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
792 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
793 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
794 |
if (!data.nwords) |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
795 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
796 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
797 |
byte_size = sizeof(uint16_t) * data.nwords; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
798 |
if (!(words = kmalloc(byte_size, GFP_KERNEL))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
799 |
EC_ERR("Failed to allocate %u bytes for SII contents.\n", |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
800 |
byte_size); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
801 |
retval = -ENOMEM; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
802 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
803 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
804 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
805 |
if (copy_from_user(words, |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
806 |
(void __user *) data.words, byte_size)) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
807 |
retval = -EFAULT; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
808 |
kfree(words); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
809 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
810 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
811 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
812 |
if (ec_slave_write_sii(slave, |
999 | 813 |
data.offset, data.nwords, words)) |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
814 |
retval = -EIO; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
815 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
816 |
kfree(words); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
817 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
818 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
819 |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
820 |
case EC_IOCTL_CONFIG: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
821 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
822 |
ec_ioctl_config_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
823 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
824 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
825 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
826 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
827 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
828 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
829 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
830 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
831 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
832 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
833 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
834 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
835 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
836 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
837 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
838 |
data.alias = sc->alias; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
839 |
data.position = sc->position; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
840 |
data.vendor_id = sc->vendor_id; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
841 |
data.product_code = sc->product_code; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
842 |
data.pdo_count[EC_DIR_OUTPUT] = |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
843 |
ec_pdo_list_count(&sc->pdos[EC_DIR_OUTPUT]); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
844 |
data.pdo_count[EC_DIR_INPUT] = |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
845 |
ec_pdo_list_count(&sc->pdos[EC_DIR_INPUT]); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
846 |
data.sdo_count = ec_slave_config_sdo_count(sc); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
847 |
data.attached = sc->slave != NULL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
848 |
|
999 | 849 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
850 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
851 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
852 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
853 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
854 |
case EC_IOCTL_CONFIG_PDO: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
855 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
856 |
ec_ioctl_config_pdo_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
857 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
858 |
const ec_pdo_t *pdo; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
859 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
860 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
861 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
862 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
863 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
864 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
865 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
866 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
867 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
868 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
869 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
870 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
871 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
872 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
873 |
if (data.direction > EC_DIR_INPUT) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
874 |
EC_ERR("Invalid direction %u!\n", data.direction); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
875 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
876 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
877 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
878 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
879 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
880 |
&sc->pdos[data.direction], data.pdo_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
881 |
EC_ERR("Invalid Pdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
882 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
883 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
884 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
885 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
886 |
data.index = pdo->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
887 |
data.entry_count = ec_pdo_entry_count(pdo); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
888 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
889 |
if (pdo->name) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
890 |
strncpy(data.name, pdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
891 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
892 |
} else { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
893 |
data.name[0] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
894 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
895 |
|
999 | 896 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
897 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
898 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
899 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
900 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
901 |
case EC_IOCTL_CONFIG_PDO_ENTRY: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
902 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
903 |
ec_ioctl_config_pdo_entry_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
904 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
905 |
const ec_pdo_t *pdo; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
906 |
const ec_pdo_entry_t *entry; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
907 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
908 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
909 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
910 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
911 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
912 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
913 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
914 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
915 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
916 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
917 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
918 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
919 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
920 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
921 |
if (data.direction > EC_DIR_INPUT) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
922 |
EC_ERR("Invalid direction %u!\n", data.direction); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
923 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
924 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
925 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
926 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
927 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
928 |
&sc->pdos[data.direction], data.pdo_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
929 |
EC_ERR("Invalid Pdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
930 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
931 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
932 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
933 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
934 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
935 |
pdo, data.entry_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
936 |
EC_ERR("Entry not found!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
937 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
938 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
939 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
940 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
941 |
data.index = entry->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
942 |
data.subindex = entry->subindex; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
943 |
data.bit_length = entry->bit_length; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
944 |
if (entry->name) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
945 |
strncpy(data.name, entry->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
946 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
947 |
} else { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
948 |
data.name[0] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
949 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
950 |
|
999 | 951 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
952 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
953 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
954 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
955 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
956 |
case EC_IOCTL_CONFIG_SDO: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
957 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
958 |
ec_ioctl_config_sdo_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
959 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
960 |
const ec_sdo_request_t *req; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
961 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
962 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
963 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
964 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
965 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
966 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
967 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
968 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
969 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
970 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
971 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
972 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
973 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
974 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
975 |
if (!(req = ec_slave_config_get_sdo_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
976 |
sc, data.sdo_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
977 |
EC_ERR("Invalid Sdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
978 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
979 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
980 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
981 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
982 |
data.index = req->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
983 |
data.subindex = req->subindex; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
984 |
data.size = req->data_size; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
985 |
memcpy(&data.data, req->data, min((u32) data.size, (u32) 4)); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
986 |
|
999 | 987 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
988 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
989 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
990 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
991 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
992 |
default: |
972 | 993 |
retval = -ENOTTY; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
994 |
} |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
995 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
996 |
return retval; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
997 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
998 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
999 |
/*****************************************************************************/ |