├── .gitignore ├── LICENSE └── examples ├── Kbuild ├── Kbuild.in ├── Makefile ├── Makefile.am ├── Makefile.in ├── dc_rtai ├── .dc_rtai_sample.o.cmd ├── .dc_rtai_sample_yas.c.swp ├── .ec_dc_rtai_sample.ko.cmd ├── .ec_dc_rtai_sample.mod.o.cmd ├── .ec_dc_rtai_sample.o.cmd ├── .tmp_versions │ └── ec_dc_rtai_sample.mod ├── Kbuild ├── Kbuild.in ├── Makefile ├── Makefile.am ├── Makefile.in ├── Module.symvers ├── dc_rtai_sample_pano.c ├── dc_rtai_sample_pano2.c ├── dc_rtai_sample_pano3.c ├── dc_rtai_sample_yas.c ├── dc_rtai_sample_yas2.c └── modules.order ├── dc_user ├── .deps │ └── ec_dc_user_example-main.Po ├── .libs │ ├── ec_dc_user_example │ └── lt-ec_dc_user_example ├── .main_pano.c.swp ├── Makefile ├── Makefile.am ├── Makefile.in ├── ec_dc_user_example ├── main_pano.c ├── main_yas.c ├── main_yas2.c ├── realtime └── ~ ├── modules.order └── user ├── .deps └── ec_user_example-main.Po ├── .libs ├── ec_user_example └── lt-ec_user_example ├── Makefile ├── Makefile.am ├── Makefile.in ├── ec_user_example ├── main.c ├── main_pano.c ├── main_pano2.c ├── main_pano3.c └── main_yas.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /examples/Kbuild: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id$ 4 | # 5 | # Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with the IgH EtherCAT Master; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | # vi: syntax=make 29 | # 30 | #------------------------------------------------------------------------------ 31 | 32 | obj-m := mini/ 33 | 34 | ifeq (0,1) 35 | obj-m += tty/ 36 | endif 37 | 38 | ifeq (1,1) 39 | obj-m += rtai/ dc_rtai/ 40 | endif 41 | 42 | #------------------------------------------------------------------------------ 43 | -------------------------------------------------------------------------------- /examples/Kbuild.in: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id$ 4 | # 5 | # Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with the IgH EtherCAT Master; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | # vi: syntax=make 29 | # 30 | #------------------------------------------------------------------------------ 31 | 32 | obj-m := mini/ 33 | 34 | ifeq (@ENABLE_TTY@,1) 35 | obj-m += tty/ 36 | endif 37 | 38 | ifeq (@ENABLE_RTAI@,1) 39 | obj-m += rtai/ dc_rtai/ 40 | endif 41 | 42 | #------------------------------------------------------------------------------ 43 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id: Makefile.am,v e93efb4af231 2012/11/20 13:35:53 fp $ 4 | # 5 | # Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with the IgH EtherCAT Master; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | #------------------------------------------------------------------------------ 29 | 30 | SUBDIRS = 31 | 32 | if ENABLE_USERLIB 33 | SUBDIRS += \ 34 | dc_user \ 35 | user 36 | endif 37 | 38 | if ENABLE_TTY 39 | SUBDIRS += \ 40 | tty 41 | endif 42 | 43 | if ENABLE_RTDM 44 | if ENABLE_XENOMAI 45 | SUBDIRS += \ 46 | xenomai \ 47 | xenomai_posix 48 | endif 49 | 50 | if ENABLE_RTAI 51 | SUBDIRS += \ 52 | rtai_rtdm \ 53 | rtai_rtdm_dc 54 | endif 55 | endif 56 | 57 | DIST_SUBDIRS = \ 58 | dc_rtai \ 59 | dc_user \ 60 | mini \ 61 | rtai \ 62 | rtai_rtdm \ 63 | rtai_rtdm_dc \ 64 | tty \ 65 | user \ 66 | xenomai \ 67 | xenomai_posix 68 | 69 | EXTRA_DIST = \ 70 | Kbuild.in 71 | 72 | BUILT_SOURCES = \ 73 | Kbuild 74 | 75 | #------------------------------------------------------------------------------ 76 | -------------------------------------------------------------------------------- /examples/dc_rtai/.dc_rtai_sample_yas.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/dc_rtai/.dc_rtai_sample_yas.c.swp -------------------------------------------------------------------------------- /examples/dc_rtai/.ec_dc_rtai_sample.ko.cmd: -------------------------------------------------------------------------------- 1 | cmd_/home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.ko := ld -r -m elf_i386 -T /usr/src/linux-headers-2.6.32-122-rtai/scripts/module-common.lds --build-id -o /home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.ko /home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.o /home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.mod.o 2 | -------------------------------------------------------------------------------- /examples/dc_rtai/.ec_dc_rtai_sample.o.cmd: -------------------------------------------------------------------------------- 1 | cmd_/home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.o := ld -m elf_i386 -r -o /home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.o /home/lab428/ethercat-1.5.2/examples/dc_rtai/dc_rtai_sample.o 2 | -------------------------------------------------------------------------------- /examples/dc_rtai/.tmp_versions/ec_dc_rtai_sample.mod: -------------------------------------------------------------------------------- 1 | /home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.ko 2 | /home/lab428/ethercat-1.5.2/examples/dc_rtai/dc_rtai_sample.o 3 | -------------------------------------------------------------------------------- /examples/dc_rtai/Kbuild: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id$ 4 | # 5 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with the IgH EtherCAT Master; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | # --- 29 | # 30 | # vi: syntax=make 31 | # 32 | #------------------------------------------------------------------------------ 33 | 34 | obj-m := ec_dc_rtai_sample.o 35 | 36 | ec_dc_rtai_sample-objs := dc_rtai_sample.o 37 | 38 | EXTRA_CFLAGS := -I/usr/realtime-2.6.32-122-rtai//include 39 | 40 | KBUILD_EXTRA_SYMBOLS := \ 41 | /home/lab428/ethercat-1.5.2/$(LINUX_SYMVERS) \ 42 | /home/lab428/ethercat-1.5.2/master/$(LINUX_SYMVERS) 43 | 44 | #------------------------------------------------------------------------------ 45 | -------------------------------------------------------------------------------- /examples/dc_rtai/Kbuild.in: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id$ 4 | # 5 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with the IgH EtherCAT Master; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | # --- 29 | # 30 | # vi: syntax=make 31 | # 32 | #------------------------------------------------------------------------------ 33 | 34 | obj-m := ec_dc_rtai_sample.o 35 | 36 | ec_dc_rtai_sample-objs := dc_rtai_sample.o 37 | 38 | EXTRA_CFLAGS := -I@RTAI_DIR@/include 39 | 40 | KBUILD_EXTRA_SYMBOLS := \ 41 | @abs_top_builddir@/$(LINUX_SYMVERS) \ 42 | @abs_top_builddir@/master/$(LINUX_SYMVERS) 43 | 44 | #------------------------------------------------------------------------------ 45 | -------------------------------------------------------------------------------- /examples/dc_rtai/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 | # examples/dc_rtai/Makefile. Generated from Makefile.in by configure. 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | 17 | 18 | #------------------------------------------------------------------------------ 19 | # 20 | # IgH EtherCAT master module 21 | # 22 | # $Id: Makefile.am,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 23 | # 24 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 25 | # 26 | # This file is part of the IgH EtherCAT Master. 27 | # 28 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 29 | # modify it under the terms of the GNU General Public License version 2, as 30 | # published by the Free Software Foundation. 31 | # 32 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 33 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 35 | # Public License for more details. 36 | # 37 | # You should have received a copy of the GNU General Public License along 38 | # with the IgH EtherCAT Master; if not, write to the Free Software 39 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 40 | # 41 | # --- 42 | # 43 | # The license mentioned above concerns the source code only. Using the 44 | # EtherCAT technology and brand is only permitted in compliance with the 45 | # industrial property and similar rights of Beckhoff Automation GmbH. 46 | # 47 | #------------------------------------------------------------------------------ 48 | 49 | pkgdatadir = $(datadir)/ethercat 50 | pkgincludedir = $(includedir)/ethercat 51 | pkglibdir = $(libdir)/ethercat 52 | pkglibexecdir = $(libexecdir)/ethercat 53 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 54 | install_sh_DATA = $(install_sh) -c -m 644 55 | install_sh_PROGRAM = $(install_sh) -c 56 | install_sh_SCRIPT = $(install_sh) -c 57 | INSTALL_HEADER = $(INSTALL_DATA) 58 | transform = $(program_transform_name) 59 | NORMAL_INSTALL = : 60 | PRE_INSTALL = : 61 | POST_INSTALL = : 62 | NORMAL_UNINSTALL = : 63 | PRE_UNINSTALL = : 64 | POST_UNINSTALL = : 65 | build_triplet = i686-pc-linux-gnu 66 | host_triplet = i686-pc-linux-gnu 67 | subdir = examples/dc_rtai 68 | DIST_COMMON = $(srcdir)/Kbuild.in $(srcdir)/Makefile.am \ 69 | $(srcdir)/Makefile.in 70 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 71 | am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 72 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 73 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 74 | $(top_srcdir)/configure.ac 75 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 76 | $(ACLOCAL_M4) 77 | mkinstalldirs = $(install_sh) -d 78 | CONFIG_HEADER = $(top_builddir)/config.h 79 | CONFIG_CLEAN_FILES = Kbuild 80 | CONFIG_CLEAN_VPATH_FILES = 81 | SOURCES = 82 | DIST_SOURCES = 83 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 84 | ACLOCAL = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run aclocal-1.11 85 | AMTAR = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run tar 86 | AR = ar 87 | AUTOCONF = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run autoconf 88 | AUTOHEADER = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run autoheader 89 | AUTOMAKE = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run automake-1.11 90 | AWK = gawk 91 | CC = gcc 92 | CCDEPMODE = depmode=gcc3 93 | CFLAGS = -g -O2 94 | CPP = gcc -E 95 | CPPFLAGS = 96 | CXX = g++ 97 | CXXCPP = g++ -E 98 | CXXDEPMODE = depmode=gcc3 99 | CXXFLAGS = -g -O2 100 | CYGPATH_W = echo 101 | DEFS = -DHAVE_CONFIG_H 102 | DEPDIR = .deps 103 | DLLTOOL = false 104 | DSYMUTIL = 105 | DUMPBIN = 106 | E1000E_LAYOUT_3_4 = 0 107 | ECHO_C = 108 | ECHO_N = -n 109 | ECHO_T = 110 | EGREP = /bin/grep -E 111 | ENABLE_8139TOO = 0 112 | ENABLE_DEBUG_IF = 1 113 | ENABLE_E100 = 0 114 | ENABLE_E1000 = 0 115 | ENABLE_E1000E = 1 116 | ENABLE_EOE = 1 117 | ENABLE_GENERIC = 1 118 | ENABLE_R8169 = 0 119 | ENABLE_RTAI = 1 120 | ENABLE_RTDM = 0 121 | ENABLE_TTY = 0 122 | ENABLE_XENOMAI = 0 123 | EXEEXT = 124 | FGREP = /bin/grep -F 125 | GREP = /bin/grep 126 | INSTALL = /usr/bin/install -c 127 | INSTALL_DATA = ${INSTALL} -m 644 128 | INSTALL_MOD_DIR = ethercat 129 | INSTALL_PROGRAM = ${INSTALL} 130 | INSTALL_SCRIPT = ${INSTALL} 131 | INSTALL_STRIP_PROGRAM = $(install_sh) -c -s 132 | KERNEL_8139TOO = 2.6.32 133 | KERNEL_E100 = 2.6.32 134 | KERNEL_E1000 = 2.6.32 135 | KERNEL_E1000E = 2.6.32 136 | KERNEL_R8169 = 2.6.32 137 | LD = /usr/bin/ld 138 | LDFLAGS = 139 | LIBOBJS = 140 | LIBS = 141 | LIBTOOL = $(SHELL) $(top_builddir)/libtool 142 | LINUX_SOURCE_DIR = /usr/src/linux-headers-2.6.32-122-rtai 143 | LIPO = 144 | LN_S = ln -s 145 | LTLIBOBJS = 146 | MAKEINFO = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/missing --run makeinfo 147 | MANIFEST_TOOL = : 148 | MKDIR_P = /bin/mkdir -p 149 | NM = /usr/bin/nm -B 150 | NMEDIT = 151 | OBJDUMP = objdump 152 | OBJEXT = o 153 | OTOOL = 154 | OTOOL64 = 155 | PACKAGE = ethercat 156 | PACKAGE_BUGREPORT = fp@igh-essen.com 157 | PACKAGE_NAME = ethercat 158 | PACKAGE_STRING = ethercat 1.5.2 159 | PACKAGE_TARNAME = ethercat 160 | PACKAGE_URL = 161 | PACKAGE_VERSION = 1.5.2 162 | PATH_SEPARATOR = : 163 | RANLIB = ranlib 164 | RTAI_DIR = /usr/realtime-2.6.32-122-rtai/ 165 | RTAI_LXRT_CFLAGS = -I. -I/usr/realtime-2.6.32-122-rtai/include -O2 -I/usr/src/linux-headers-2.6.32-122-rtai/include -Wall -Wstrict-prototypes -pipe 166 | RTAI_LXRT_LDFLAGS = -L/usr/realtime-2.6.32-122-rtai/lib -lpthread 167 | SED = /bin/sed 168 | SET_MAKE = 169 | SHELL = /bin/bash 170 | STRIP = strip 171 | VERSION = 1.5.2 172 | XENOMAI_DIR = 173 | XENOMAI_NATIVE_CFLAGS = 174 | XENOMAI_NATIVE_LDFLAGS = 175 | XENOMAI_POSIX_CFLAGS = 176 | XENOMAI_POSIX_LDFLAGS = 177 | XENOMAI_RTDM_CFLAGS = 178 | XENOMAI_RTDM_LDFLAGS = 179 | abs_builddir = /home/lab428/ethercat-1.5.2/examples/dc_rtai 180 | abs_srcdir = /home/lab428/ethercat-1.5.2/examples/dc_rtai 181 | abs_top_builddir = /home/lab428/ethercat-1.5.2 182 | abs_top_srcdir = /home/lab428/ethercat-1.5.2 183 | ac_ct_AR = ar 184 | ac_ct_CC = gcc 185 | ac_ct_CXX = g++ 186 | ac_ct_DUMPBIN = 187 | am__include = include 188 | am__leading_dot = . 189 | am__quote = 190 | am__tar = ${AMTAR} chof - "$$tardir" 191 | am__untar = ${AMTAR} xf - 192 | bindir = ${exec_prefix}/bin 193 | build = i686-pc-linux-gnu 194 | build_alias = 195 | build_cpu = i686 196 | build_os = linux-gnu 197 | build_vendor = pc 198 | builddir = . 199 | datadir = ${datarootdir} 200 | datarootdir = ${prefix}/share 201 | docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} 202 | dvidir = ${docdir} 203 | exec_prefix = ${prefix} 204 | host = i686-pc-linux-gnu 205 | host_alias = 206 | host_cpu = i686 207 | host_os = linux-gnu 208 | host_vendor = pc 209 | htmldir = ${docdir} 210 | includedir = ${prefix}/include 211 | infodir = ${datarootdir}/info 212 | install_sh = ${SHELL} /home/lab428/ethercat-1.5.2/autoconf/install-sh 213 | libdir = ${exec_prefix}/lib 214 | libexecdir = ${exec_prefix}/libexec 215 | localedir = ${datarootdir}/locale 216 | localstatedir = ${prefix}/var 217 | mandir = ${datarootdir}/man 218 | mkdir_p = /bin/mkdir -p 219 | oldincludedir = /usr/include 220 | pdfdir = ${docdir} 221 | prefix = /opt/etherlab 222 | program_transform_name = s,x,x, 223 | psdir = ${docdir} 224 | sbindir = ${exec_prefix}/sbin 225 | sharedstatedir = ${prefix}/com 226 | srcdir = . 227 | sysconfdir = ${prefix}/etc 228 | target_alias = 229 | top_build_prefix = ../../ 230 | top_builddir = ../.. 231 | top_srcdir = ../.. 232 | EXTRA_DIST = \ 233 | Kbuild.in \ 234 | dc_rtai_sample.c 235 | 236 | BUILT_SOURCES = \ 237 | Kbuild 238 | 239 | all: $(BUILT_SOURCES) 240 | $(MAKE) $(AM_MAKEFLAGS) all-am 241 | 242 | .SUFFIXES: 243 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 244 | @for dep in $?; do \ 245 | case '$(am__configure_deps)' in \ 246 | *$$dep*) \ 247 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 248 | && { if test -f $@; then exit 0; else break; fi; }; \ 249 | exit 1;; \ 250 | esac; \ 251 | done; \ 252 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/dc_rtai/Makefile'; \ 253 | $(am__cd) $(top_srcdir) && \ 254 | $(AUTOMAKE) --gnu examples/dc_rtai/Makefile 255 | .PRECIOUS: Makefile 256 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 257 | @case '$?' in \ 258 | *config.status*) \ 259 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 260 | *) \ 261 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 262 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 263 | esac; 264 | 265 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 266 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 267 | 268 | $(top_srcdir)/configure: $(am__configure_deps) 269 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 270 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 271 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 272 | $(am__aclocal_m4_deps): 273 | Kbuild: $(top_builddir)/config.status $(srcdir)/Kbuild.in 274 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 275 | 276 | mostlyclean-libtool: 277 | -rm -f *.lo 278 | 279 | clean-libtool: 280 | -rm -rf .libs _libs 281 | tags: TAGS 282 | TAGS: 283 | 284 | ctags: CTAGS 285 | CTAGS: 286 | 287 | 288 | distdir: $(DISTFILES) 289 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 290 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 291 | list='$(DISTFILES)'; \ 292 | dist_files=`for file in $$list; do echo $$file; done | \ 293 | sed -e "s|^$$srcdirstrip/||;t" \ 294 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 295 | case $$dist_files in \ 296 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 297 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 298 | sort -u` ;; \ 299 | esac; \ 300 | for file in $$dist_files; do \ 301 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 302 | if test -d $$d/$$file; then \ 303 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 304 | if test -d "$(distdir)/$$file"; then \ 305 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 306 | fi; \ 307 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 308 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 309 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 310 | fi; \ 311 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 312 | else \ 313 | test -f "$(distdir)/$$file" \ 314 | || cp -p $$d/$$file "$(distdir)/$$file" \ 315 | || exit 1; \ 316 | fi; \ 317 | done 318 | check-am: all-am 319 | check: $(BUILT_SOURCES) 320 | $(MAKE) $(AM_MAKEFLAGS) check-am 321 | all-am: Makefile 322 | installdirs: 323 | install: $(BUILT_SOURCES) 324 | $(MAKE) $(AM_MAKEFLAGS) install-am 325 | install-exec: install-exec-am 326 | install-data: install-data-am 327 | uninstall: uninstall-am 328 | 329 | install-am: all-am 330 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 331 | 332 | installcheck: installcheck-am 333 | install-strip: 334 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 335 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 336 | `test -z '$(STRIP)' || \ 337 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 338 | mostlyclean-generic: 339 | 340 | clean-generic: 341 | 342 | distclean-generic: 343 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 344 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 345 | 346 | maintainer-clean-generic: 347 | @echo "This command is intended for maintainers to use" 348 | @echo "it deletes files that may require special tools to rebuild." 349 | -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 350 | clean: clean-am 351 | 352 | clean-am: clean-generic clean-libtool clean-local mostlyclean-am 353 | 354 | distclean: distclean-am 355 | -rm -f Makefile 356 | distclean-am: clean-am distclean-generic 357 | 358 | dvi: dvi-am 359 | 360 | dvi-am: 361 | 362 | html: html-am 363 | 364 | html-am: 365 | 366 | info: info-am 367 | 368 | info-am: 369 | 370 | install-data-am: 371 | 372 | install-dvi: install-dvi-am 373 | 374 | install-dvi-am: 375 | 376 | install-exec-am: 377 | 378 | install-html: install-html-am 379 | 380 | install-html-am: 381 | 382 | install-info: install-info-am 383 | 384 | install-info-am: 385 | 386 | install-man: 387 | 388 | install-pdf: install-pdf-am 389 | 390 | install-pdf-am: 391 | 392 | install-ps: install-ps-am 393 | 394 | install-ps-am: 395 | 396 | installcheck-am: 397 | 398 | maintainer-clean: maintainer-clean-am 399 | -rm -f Makefile 400 | maintainer-clean-am: distclean-am maintainer-clean-generic 401 | 402 | mostlyclean: mostlyclean-am 403 | 404 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool 405 | 406 | pdf: pdf-am 407 | 408 | pdf-am: 409 | 410 | ps: ps-am 411 | 412 | ps-am: 413 | 414 | uninstall-am: 415 | 416 | .MAKE: all check install install-am install-strip 417 | 418 | .PHONY: all all-am check check-am clean clean-generic clean-libtool \ 419 | clean-local distclean distclean-generic distclean-libtool \ 420 | distdir dvi dvi-am html html-am info info-am install \ 421 | install-am install-data install-data-am install-dvi \ 422 | install-dvi-am install-exec install-exec-am install-html \ 423 | install-html-am install-info install-info-am install-man \ 424 | install-pdf install-pdf-am install-ps install-ps-am \ 425 | install-strip installcheck installcheck-am installdirs \ 426 | maintainer-clean maintainer-clean-generic mostlyclean \ 427 | mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 428 | uninstall uninstall-am 429 | 430 | 431 | modules: 432 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="/home/lab428/ethercat-1.5.2/examples/dc_rtai" modules 433 | 434 | modules_install: 435 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="/home/lab428/ethercat-1.5.2/examples/dc_rtai" \ 436 | INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" modules_install 437 | 438 | clean-local: 439 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="/home/lab428/ethercat-1.5.2/examples/dc_rtai" clean 440 | 441 | #------------------------------------------------------------------------------ 442 | 443 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 444 | # Otherwise a system limit (for SysV at least) may be exceeded. 445 | .NOEXPORT: 446 | -------------------------------------------------------------------------------- /examples/dc_rtai/Makefile.am: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # IgH EtherCAT master module 4 | # 5 | # $Id: Makefile.am,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 6 | # 7 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 8 | # 9 | # This file is part of the IgH EtherCAT Master. 10 | # 11 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 12 | # modify it under the terms of the GNU General Public License version 2, as 13 | # published by the Free Software Foundation. 14 | # 15 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 18 | # Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with the IgH EtherCAT Master; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | # --- 25 | # 26 | # The license mentioned above concerns the source code only. Using the 27 | # EtherCAT technology and brand is only permitted in compliance with the 28 | # industrial property and similar rights of Beckhoff Automation GmbH. 29 | # 30 | #------------------------------------------------------------------------------ 31 | 32 | EXTRA_DIST = \ 33 | Kbuild.in \ 34 | dc_rtai_sample.c 35 | 36 | BUILT_SOURCES = \ 37 | Kbuild 38 | 39 | modules: 40 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules 41 | 42 | modules_install: 43 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \ 44 | INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" modules_install 45 | 46 | clean-local: 47 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean 48 | 49 | #------------------------------------------------------------------------------ 50 | -------------------------------------------------------------------------------- /examples/dc_rtai/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | #------------------------------------------------------------------------------ 19 | # 20 | # IgH EtherCAT master module 21 | # 22 | # $Id: Makefile.am,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 23 | # 24 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 25 | # 26 | # This file is part of the IgH EtherCAT Master. 27 | # 28 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 29 | # modify it under the terms of the GNU General Public License version 2, as 30 | # published by the Free Software Foundation. 31 | # 32 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 33 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 35 | # Public License for more details. 36 | # 37 | # You should have received a copy of the GNU General Public License along 38 | # with the IgH EtherCAT Master; if not, write to the Free Software 39 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 40 | # 41 | # --- 42 | # 43 | # The license mentioned above concerns the source code only. Using the 44 | # EtherCAT technology and brand is only permitted in compliance with the 45 | # industrial property and similar rights of Beckhoff Automation GmbH. 46 | # 47 | #------------------------------------------------------------------------------ 48 | VPATH = @srcdir@ 49 | pkgdatadir = $(datadir)/@PACKAGE@ 50 | pkgincludedir = $(includedir)/@PACKAGE@ 51 | pkglibdir = $(libdir)/@PACKAGE@ 52 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 53 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 54 | install_sh_DATA = $(install_sh) -c -m 644 55 | install_sh_PROGRAM = $(install_sh) -c 56 | install_sh_SCRIPT = $(install_sh) -c 57 | INSTALL_HEADER = $(INSTALL_DATA) 58 | transform = $(program_transform_name) 59 | NORMAL_INSTALL = : 60 | PRE_INSTALL = : 61 | POST_INSTALL = : 62 | NORMAL_UNINSTALL = : 63 | PRE_UNINSTALL = : 64 | POST_UNINSTALL = : 65 | build_triplet = @build@ 66 | host_triplet = @host@ 67 | subdir = examples/dc_rtai 68 | DIST_COMMON = $(srcdir)/Kbuild.in $(srcdir)/Makefile.am \ 69 | $(srcdir)/Makefile.in 70 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 71 | am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 72 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 73 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 74 | $(top_srcdir)/configure.ac 75 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 76 | $(ACLOCAL_M4) 77 | mkinstalldirs = $(install_sh) -d 78 | CONFIG_HEADER = $(top_builddir)/config.h 79 | CONFIG_CLEAN_FILES = Kbuild 80 | CONFIG_CLEAN_VPATH_FILES = 81 | SOURCES = 82 | DIST_SOURCES = 83 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 84 | ACLOCAL = @ACLOCAL@ 85 | AMTAR = @AMTAR@ 86 | AR = @AR@ 87 | AUTOCONF = @AUTOCONF@ 88 | AUTOHEADER = @AUTOHEADER@ 89 | AUTOMAKE = @AUTOMAKE@ 90 | AWK = @AWK@ 91 | CC = @CC@ 92 | CCDEPMODE = @CCDEPMODE@ 93 | CFLAGS = @CFLAGS@ 94 | CPP = @CPP@ 95 | CPPFLAGS = @CPPFLAGS@ 96 | CXX = @CXX@ 97 | CXXCPP = @CXXCPP@ 98 | CXXDEPMODE = @CXXDEPMODE@ 99 | CXXFLAGS = @CXXFLAGS@ 100 | CYGPATH_W = @CYGPATH_W@ 101 | DEFS = @DEFS@ 102 | DEPDIR = @DEPDIR@ 103 | DLLTOOL = @DLLTOOL@ 104 | DSYMUTIL = @DSYMUTIL@ 105 | DUMPBIN = @DUMPBIN@ 106 | E1000E_LAYOUT_3_4 = @E1000E_LAYOUT_3_4@ 107 | ECHO_C = @ECHO_C@ 108 | ECHO_N = @ECHO_N@ 109 | ECHO_T = @ECHO_T@ 110 | EGREP = @EGREP@ 111 | ENABLE_8139TOO = @ENABLE_8139TOO@ 112 | ENABLE_DEBUG_IF = @ENABLE_DEBUG_IF@ 113 | ENABLE_E100 = @ENABLE_E100@ 114 | ENABLE_E1000 = @ENABLE_E1000@ 115 | ENABLE_E1000E = @ENABLE_E1000E@ 116 | ENABLE_EOE = @ENABLE_EOE@ 117 | ENABLE_GENERIC = @ENABLE_GENERIC@ 118 | ENABLE_R8169 = @ENABLE_R8169@ 119 | ENABLE_RTAI = @ENABLE_RTAI@ 120 | ENABLE_RTDM = @ENABLE_RTDM@ 121 | ENABLE_TTY = @ENABLE_TTY@ 122 | ENABLE_XENOMAI = @ENABLE_XENOMAI@ 123 | EXEEXT = @EXEEXT@ 124 | FGREP = @FGREP@ 125 | GREP = @GREP@ 126 | INSTALL = @INSTALL@ 127 | INSTALL_DATA = @INSTALL_DATA@ 128 | INSTALL_MOD_DIR = @INSTALL_MOD_DIR@ 129 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 130 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 131 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 132 | KERNEL_8139TOO = @KERNEL_8139TOO@ 133 | KERNEL_E100 = @KERNEL_E100@ 134 | KERNEL_E1000 = @KERNEL_E1000@ 135 | KERNEL_E1000E = @KERNEL_E1000E@ 136 | KERNEL_R8169 = @KERNEL_R8169@ 137 | LD = @LD@ 138 | LDFLAGS = @LDFLAGS@ 139 | LIBOBJS = @LIBOBJS@ 140 | LIBS = @LIBS@ 141 | LIBTOOL = @LIBTOOL@ 142 | LINUX_SOURCE_DIR = @LINUX_SOURCE_DIR@ 143 | LIPO = @LIPO@ 144 | LN_S = @LN_S@ 145 | LTLIBOBJS = @LTLIBOBJS@ 146 | MAKEINFO = @MAKEINFO@ 147 | MANIFEST_TOOL = @MANIFEST_TOOL@ 148 | MKDIR_P = @MKDIR_P@ 149 | NM = @NM@ 150 | NMEDIT = @NMEDIT@ 151 | OBJDUMP = @OBJDUMP@ 152 | OBJEXT = @OBJEXT@ 153 | OTOOL = @OTOOL@ 154 | OTOOL64 = @OTOOL64@ 155 | PACKAGE = @PACKAGE@ 156 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 157 | PACKAGE_NAME = @PACKAGE_NAME@ 158 | PACKAGE_STRING = @PACKAGE_STRING@ 159 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 160 | PACKAGE_URL = @PACKAGE_URL@ 161 | PACKAGE_VERSION = @PACKAGE_VERSION@ 162 | PATH_SEPARATOR = @PATH_SEPARATOR@ 163 | RANLIB = @RANLIB@ 164 | RTAI_DIR = @RTAI_DIR@ 165 | RTAI_LXRT_CFLAGS = @RTAI_LXRT_CFLAGS@ 166 | RTAI_LXRT_LDFLAGS = @RTAI_LXRT_LDFLAGS@ 167 | SED = @SED@ 168 | SET_MAKE = @SET_MAKE@ 169 | SHELL = @SHELL@ 170 | STRIP = @STRIP@ 171 | VERSION = @VERSION@ 172 | XENOMAI_DIR = @XENOMAI_DIR@ 173 | XENOMAI_NATIVE_CFLAGS = @XENOMAI_NATIVE_CFLAGS@ 174 | XENOMAI_NATIVE_LDFLAGS = @XENOMAI_NATIVE_LDFLAGS@ 175 | XENOMAI_POSIX_CFLAGS = @XENOMAI_POSIX_CFLAGS@ 176 | XENOMAI_POSIX_LDFLAGS = @XENOMAI_POSIX_LDFLAGS@ 177 | XENOMAI_RTDM_CFLAGS = @XENOMAI_RTDM_CFLAGS@ 178 | XENOMAI_RTDM_LDFLAGS = @XENOMAI_RTDM_LDFLAGS@ 179 | abs_builddir = @abs_builddir@ 180 | abs_srcdir = @abs_srcdir@ 181 | abs_top_builddir = @abs_top_builddir@ 182 | abs_top_srcdir = @abs_top_srcdir@ 183 | ac_ct_AR = @ac_ct_AR@ 184 | ac_ct_CC = @ac_ct_CC@ 185 | ac_ct_CXX = @ac_ct_CXX@ 186 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 187 | am__include = @am__include@ 188 | am__leading_dot = @am__leading_dot@ 189 | am__quote = @am__quote@ 190 | am__tar = @am__tar@ 191 | am__untar = @am__untar@ 192 | bindir = @bindir@ 193 | build = @build@ 194 | build_alias = @build_alias@ 195 | build_cpu = @build_cpu@ 196 | build_os = @build_os@ 197 | build_vendor = @build_vendor@ 198 | builddir = @builddir@ 199 | datadir = @datadir@ 200 | datarootdir = @datarootdir@ 201 | docdir = @docdir@ 202 | dvidir = @dvidir@ 203 | exec_prefix = @exec_prefix@ 204 | host = @host@ 205 | host_alias = @host_alias@ 206 | host_cpu = @host_cpu@ 207 | host_os = @host_os@ 208 | host_vendor = @host_vendor@ 209 | htmldir = @htmldir@ 210 | includedir = @includedir@ 211 | infodir = @infodir@ 212 | install_sh = @install_sh@ 213 | libdir = @libdir@ 214 | libexecdir = @libexecdir@ 215 | localedir = @localedir@ 216 | localstatedir = @localstatedir@ 217 | mandir = @mandir@ 218 | mkdir_p = @mkdir_p@ 219 | oldincludedir = @oldincludedir@ 220 | pdfdir = @pdfdir@ 221 | prefix = @prefix@ 222 | program_transform_name = @program_transform_name@ 223 | psdir = @psdir@ 224 | sbindir = @sbindir@ 225 | sharedstatedir = @sharedstatedir@ 226 | srcdir = @srcdir@ 227 | sysconfdir = @sysconfdir@ 228 | target_alias = @target_alias@ 229 | top_build_prefix = @top_build_prefix@ 230 | top_builddir = @top_builddir@ 231 | top_srcdir = @top_srcdir@ 232 | EXTRA_DIST = \ 233 | Kbuild.in \ 234 | dc_rtai_sample.c 235 | 236 | BUILT_SOURCES = \ 237 | Kbuild 238 | 239 | all: $(BUILT_SOURCES) 240 | $(MAKE) $(AM_MAKEFLAGS) all-am 241 | 242 | .SUFFIXES: 243 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 244 | @for dep in $?; do \ 245 | case '$(am__configure_deps)' in \ 246 | *$$dep*) \ 247 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 248 | && { if test -f $@; then exit 0; else break; fi; }; \ 249 | exit 1;; \ 250 | esac; \ 251 | done; \ 252 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/dc_rtai/Makefile'; \ 253 | $(am__cd) $(top_srcdir) && \ 254 | $(AUTOMAKE) --gnu examples/dc_rtai/Makefile 255 | .PRECIOUS: Makefile 256 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 257 | @case '$?' in \ 258 | *config.status*) \ 259 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 260 | *) \ 261 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 262 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 263 | esac; 264 | 265 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 266 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 267 | 268 | $(top_srcdir)/configure: $(am__configure_deps) 269 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 270 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 271 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 272 | $(am__aclocal_m4_deps): 273 | Kbuild: $(top_builddir)/config.status $(srcdir)/Kbuild.in 274 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 275 | 276 | mostlyclean-libtool: 277 | -rm -f *.lo 278 | 279 | clean-libtool: 280 | -rm -rf .libs _libs 281 | tags: TAGS 282 | TAGS: 283 | 284 | ctags: CTAGS 285 | CTAGS: 286 | 287 | 288 | distdir: $(DISTFILES) 289 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 290 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 291 | list='$(DISTFILES)'; \ 292 | dist_files=`for file in $$list; do echo $$file; done | \ 293 | sed -e "s|^$$srcdirstrip/||;t" \ 294 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 295 | case $$dist_files in \ 296 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 297 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 298 | sort -u` ;; \ 299 | esac; \ 300 | for file in $$dist_files; do \ 301 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 302 | if test -d $$d/$$file; then \ 303 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 304 | if test -d "$(distdir)/$$file"; then \ 305 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 306 | fi; \ 307 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 308 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 309 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 310 | fi; \ 311 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 312 | else \ 313 | test -f "$(distdir)/$$file" \ 314 | || cp -p $$d/$$file "$(distdir)/$$file" \ 315 | || exit 1; \ 316 | fi; \ 317 | done 318 | check-am: all-am 319 | check: $(BUILT_SOURCES) 320 | $(MAKE) $(AM_MAKEFLAGS) check-am 321 | all-am: Makefile 322 | installdirs: 323 | install: $(BUILT_SOURCES) 324 | $(MAKE) $(AM_MAKEFLAGS) install-am 325 | install-exec: install-exec-am 326 | install-data: install-data-am 327 | uninstall: uninstall-am 328 | 329 | install-am: all-am 330 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 331 | 332 | installcheck: installcheck-am 333 | install-strip: 334 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 335 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 336 | `test -z '$(STRIP)' || \ 337 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 338 | mostlyclean-generic: 339 | 340 | clean-generic: 341 | 342 | distclean-generic: 343 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 344 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 345 | 346 | maintainer-clean-generic: 347 | @echo "This command is intended for maintainers to use" 348 | @echo "it deletes files that may require special tools to rebuild." 349 | -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 350 | clean: clean-am 351 | 352 | clean-am: clean-generic clean-libtool clean-local mostlyclean-am 353 | 354 | distclean: distclean-am 355 | -rm -f Makefile 356 | distclean-am: clean-am distclean-generic 357 | 358 | dvi: dvi-am 359 | 360 | dvi-am: 361 | 362 | html: html-am 363 | 364 | html-am: 365 | 366 | info: info-am 367 | 368 | info-am: 369 | 370 | install-data-am: 371 | 372 | install-dvi: install-dvi-am 373 | 374 | install-dvi-am: 375 | 376 | install-exec-am: 377 | 378 | install-html: install-html-am 379 | 380 | install-html-am: 381 | 382 | install-info: install-info-am 383 | 384 | install-info-am: 385 | 386 | install-man: 387 | 388 | install-pdf: install-pdf-am 389 | 390 | install-pdf-am: 391 | 392 | install-ps: install-ps-am 393 | 394 | install-ps-am: 395 | 396 | installcheck-am: 397 | 398 | maintainer-clean: maintainer-clean-am 399 | -rm -f Makefile 400 | maintainer-clean-am: distclean-am maintainer-clean-generic 401 | 402 | mostlyclean: mostlyclean-am 403 | 404 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool 405 | 406 | pdf: pdf-am 407 | 408 | pdf-am: 409 | 410 | ps: ps-am 411 | 412 | ps-am: 413 | 414 | uninstall-am: 415 | 416 | .MAKE: all check install install-am install-strip 417 | 418 | .PHONY: all all-am check check-am clean clean-generic clean-libtool \ 419 | clean-local distclean distclean-generic distclean-libtool \ 420 | distdir dvi dvi-am html html-am info info-am install \ 421 | install-am install-data install-data-am install-dvi \ 422 | install-dvi-am install-exec install-exec-am install-html \ 423 | install-html-am install-info install-info-am install-man \ 424 | install-pdf install-pdf-am install-ps install-ps-am \ 425 | install-strip installcheck installcheck-am installdirs \ 426 | maintainer-clean maintainer-clean-generic mostlyclean \ 427 | mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 428 | uninstall uninstall-am 429 | 430 | 431 | modules: 432 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules 433 | 434 | modules_install: 435 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \ 436 | INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" modules_install 437 | 438 | clean-local: 439 | $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean 440 | 441 | #------------------------------------------------------------------------------ 442 | 443 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 444 | # Otherwise a system limit (for SysV at least) may be exceeded. 445 | .NOEXPORT: 446 | -------------------------------------------------------------------------------- /examples/dc_rtai/Module.symvers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/dc_rtai/Module.symvers -------------------------------------------------------------------------------- /examples/dc_rtai/dc_rtai_sample_pano.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Distributed clocks sample for the IgH EtherCAT master. 4 | * 5 | * $Id: dc_rtai_sample.c,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 6 | * 7 | * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 8 | * 9 | * This file is part of the IgH EtherCAT Master. 10 | * 11 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License version 2, as 13 | * published by the Free Software Foundation. 14 | * 15 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 18 | * Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License along 21 | * with the IgH EtherCAT Master; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | * --- 25 | * 26 | * The license mentioned above concerns the source code only. Using the 27 | * EtherCAT technology and brand is only permitted in compliance with the 28 | * industrial property and similar rights of Beckhoff Automation GmbH. 29 | * 30 | *****************************************************************************/ 31 | 32 | // Linux 33 | #include 34 | #include 35 | 36 | // RTAI 37 | #include 38 | #include 39 | 40 | // EtherCAT 41 | #include "../../include/ecrt.h" 42 | 43 | /*****************************************************************************/ 44 | 45 | // Module parameters 46 | 47 | #define FREQUENCY 1000 // task frequency in Hz 48 | #define INHIBIT_TIME 20 49 | 50 | #define TIMERTICKS (1000000000 / FREQUENCY) 51 | 52 | #define NUM_DIG_OUT 1 53 | 54 | #define PFX "ec_dc_rtai_sample: " 55 | 56 | /*****************************************************************************/ 57 | 58 | // EtherCAT 59 | static ec_master_t *master = NULL; 60 | static ec_master_state_t master_state = {}; 61 | 62 | static ec_domain_t *domain1 = NULL; 63 | static ec_domain_state_t domain1_state = {}; 64 | 65 | //static ec_domain_t *domain2 = NULL; 66 | //static ec_domain_state_t domain2_state = {}; 67 | 68 | // RTAI 69 | static RT_TASK task; 70 | static SEM master_sem; 71 | static cycles_t t_last_cycle = 0, t_critical; 72 | 73 | /*****************************************************************************/ 74 | 75 | // process data 76 | static uint8_t *domain1_pd; // process data memory 77 | //static uint8_t *domain2_pd; 78 | 79 | /* 80 | #define DigOutSlavePos(X) 0, (1 + (X)) 81 | #define CounterSlavePos 0, 2 82 | 83 | #define Beckhoff_EK1100 0x00000002, 0x044c2c52 84 | #define Beckhoff_EL2008 0x00000002, 0x07d83052 85 | #define IDS_Counter 0x000012ad, 0x05de3052 86 | */ 87 | #define yas 0,0 88 | #define yaskawa 0x0000066f, 0x525100d1 89 | 90 | 91 | /* 92 | static int off_dig_out[NUM_DIG_OUT]; 93 | static int off_counter_in; 94 | static int off_counter_out; 95 | 96 | static unsigned int counter = 0; 97 | static unsigned int blink_counter = 0; 98 | static unsigned int blink = 0; 99 | static u32 counter_value = 0U; 100 | */ 101 | 102 | 103 | // offsets for PDO entries 104 | 105 | 106 | //signal to turn off servo on state 107 | static unsigned int servooff =0; 108 | static unsigned int deactive; 109 | // offsets for PDO entries 110 | static unsigned int ctrl_word ; 111 | static unsigned int mode ; 112 | static unsigned int tar_torq ; 113 | static unsigned int max_torq ; 114 | static unsigned int tar_pos ; 115 | static unsigned int max_speed ; 116 | static unsigned int touch_probe_func; 117 | static unsigned int tar_vel ; 118 | static unsigned int error_code ; 119 | static unsigned int status_word; 120 | static unsigned int mode_display ; 121 | static unsigned int pos_act; 122 | static unsigned int vel_act; 123 | static unsigned int torq_act; 124 | static unsigned int touch_probe_status; 125 | static unsigned int touch_probe_pos; 126 | static unsigned int digital_input; 127 | 128 | static unsigned int counter = 0; 129 | 130 | //somecounters // 131 | static signed long inpu[8]={}; 132 | static unsigned long change=0; 133 | int start,speedup,speeddown,stop; 134 | //variables for get date // 135 | static float data[80000][4]={}; 136 | static unsigned long datacount=0; 137 | int value =0; 138 | 139 | 140 | //rx pdo entry of 1st 2nd motor // 141 | const static ec_pdo_entry_reg_t domain1_regs[] = { 142 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 143 | {yas, yaskawa,0x6060, 00, &mode }, 144 | {yas, yaskawa,0x6071, 00, &tar_torq }, 145 | {yas, yaskawa,0x6072, 00, &max_torq }, 146 | {yas, yaskawa,0x607a, 00, &tar_pos }, 147 | {yas, yaskawa,0x6080, 00, &max_speed }, 148 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 149 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 150 | {yas, yaskawa,0x603f, 00, &error_code }, 151 | {yas, yaskawa,0x6041, 00, &status_word }, 152 | {yas, yaskawa,0x6061, 00, &mode_display }, 153 | {yas, yaskawa,0x6064, 00, &pos_act }, 154 | {yas, yaskawa,0x606c, 00, &vel_act }, 155 | {yas, yaskawa,0x6077, 00, &torq_act }, 156 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 157 | {yas, yaskawa,0x60ba, 00, &touch_probe_pos }, 158 | {yas, yaskawa,0x60fd, 00, &digital_input }, 159 | {} 160 | }; 161 | 162 | 163 | 164 | /*****************************************************************************/ 165 | //yaskawa 1st PDO mapping // 166 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 167 | {0x6040, 0x00, 16}, 168 | {0x6060, 0x00, 8 }, 169 | {0x6071, 0x00, 16}, 170 | {0x6072, 0x00, 16}, 171 | {0x607a, 0x00, 32}, 172 | {0x6080, 0x00, 32}, 173 | {0x60b8, 0x00, 16}, 174 | {0x60ff, 0x00, 32}, 175 | {0x603f, 0x00, 16}, 176 | {0x6041, 0x00, 16}, 177 | {0x6061, 0x00, 8 }, 178 | {0x6064, 0x00, 32}, 179 | {0x606c, 0x00, 32}, 180 | {0x6077, 0x00, 16}, 181 | {0x60b9, 0x00, 16}, 182 | {0x60ba, 0x00, 32}, 183 | {0x60fd, 0x00, 32}, 184 | };//{index,subindex,lenth} 185 | 186 | static ec_pdo_info_t slave_0_pdos[] = { 187 | {0x1600, 8, slave_0_pdo_entries + 0}, 188 | {0x1a00, 9, slave_0_pdo_entries + 8}, 189 | }; 190 | 191 | static ec_sync_info_t slave_0_syncs[] = { 192 | {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, 193 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 194 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 195 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 196 | {0xff} 197 | }; 198 | /*****************************************************************************/ 199 | 200 | 201 | void run(long data) 202 | { 203 | int i; 204 | struct timeval tv; 205 | unsigned int sync_ref_counter = 0; 206 | 207 | count2timeval(nano2count(rt_get_real_time_ns()), &tv); 208 | 209 | 210 | // while (deactive!=20) { 211 | while (1) { 212 | t_last_cycle = get_cycles(); 213 | 214 | 215 | 216 | // receive process data 217 | rt_sem_wait(&master_sem); 218 | ecrt_master_receive(master); 219 | ecrt_domain_process(domain1); 220 | rt_sem_signal(&master_sem); 221 | 222 | // check process data state (optional) 223 | //check_domain1_state(); 224 | 225 | inpu[0]=EC_READ_U16(domain1_pd + status_word); 226 | inpu[1]=EC_READ_U32(domain1_pd + pos_act); 227 | 228 | // if(servooff==1){//servo off 229 | // if(stop==1){ 230 | 231 | // if( ( inpu[0] == 0x1637 ) && ( inpu[2] == 0x1637 ) ){ 232 | // EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 233 | // EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 234 | // } 235 | // else if( ( inpu[0] == 0x0650 ) && ( inpu[2] == 0x0650 ) ){ 236 | // printk(KERN_INFO PFX "want to PREOP"); 237 | // deactive++; 238 | // } 239 | 240 | // } 241 | 242 | if( (inpu[0]&0x004f) == 0x0040 ){ 243 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 244 | } 245 | else if( (inpu[0]&0x006f) == 0x0021){ 246 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 247 | } 248 | else if( (inpu[0]&0x006f) == 0x0023){ 249 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f); 250 | EC_WRITE_S32(domain1_pd+tar_pos, 0); 251 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 252 | } 253 | else if( (inpu[0]&0x006f) == 0x0027){ 254 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 255 | EC_WRITE_S32(domain1_pd+tar_pos , value ); //for mode 8 no sin 256 | 257 | if(value==180000){ 258 | speedup=0; 259 | speeddown=1; 260 | //printk(KERN_INFO PFX "top"); 261 | value=value-1; 262 | } 263 | else if(speeddown==1 && value!=0){ 264 | value=value-1; 265 | //printk(KERN_INFO PFX "slow down"); 266 | } 267 | else if(speeddown==1 && value==0){ 268 | speedup=0; 269 | speeddown=0; 270 | // stop=1; 271 | //printk(KERN_INFO PFX "stop"); 272 | } 273 | else if(!stop){ 274 | speedup=1; 275 | speeddown=0; 276 | value=value+1; 277 | //printk(KERN_INFO PFX "fast up "); 278 | 279 | } 280 | 281 | 282 | // change++; 283 | 284 | // } 285 | // else 286 | // change = 0; 287 | } 288 | 289 | 290 | rt_sem_wait(&master_sem); 291 | 292 | tv.tv_usec += 1000; 293 | if (tv.tv_usec >= 1000000) { 294 | tv.tv_usec -= 1000000; 295 | tv.tv_sec++; 296 | } 297 | ecrt_master_application_time(master, EC_TIMEVAL2NANO(tv)); 298 | 299 | if (sync_ref_counter) { 300 | sync_ref_counter--; 301 | } else { 302 | sync_ref_counter = 1; //original = 9 303 | ecrt_master_sync_reference_clock(master); 304 | } 305 | 306 | ecrt_master_sync_slave_clocks(master); 307 | ecrt_domain_queue(domain1); 308 | ecrt_master_send(master); 309 | rt_sem_signal(&master_sem); 310 | 311 | rt_task_wait_period(); 312 | 313 | 314 | 315 | 316 | 317 | } 318 | } 319 | 320 | /*****************************************************************************/ 321 | 322 | void send_callback(void *cb_data) 323 | { 324 | ec_master_t *m = (ec_master_t *) cb_data; 325 | 326 | // too close to the next real time cycle: deny access... 327 | if (get_cycles() - t_last_cycle <= t_critical) { 328 | rt_sem_wait(&master_sem); 329 | ecrt_master_send_ext(m); 330 | rt_sem_signal(&master_sem); 331 | } 332 | } 333 | 334 | /*****************************************************************************/ 335 | 336 | void receive_callback(void *cb_data) 337 | { 338 | ec_master_t *m = (ec_master_t *) cb_data; 339 | 340 | // too close to the next real time cycle: deny access... 341 | if (get_cycles() - t_last_cycle <= t_critical) { 342 | rt_sem_wait(&master_sem); 343 | ecrt_master_receive(m); 344 | rt_sem_signal(&master_sem); 345 | } 346 | } 347 | 348 | /*****************************************************************************/ 349 | 350 | int __init init_mod(void) 351 | { 352 | int ret = -1, i; 353 | RTIME tick_period, requested_ticks, now; 354 | ec_slave_config_t *sc; 355 | 356 | printk(KERN_INFO PFX "Starting...\n"); 357 | 358 | rt_sem_init(&master_sem, 1); 359 | 360 | t_critical = cpu_khz * 1000 / FREQUENCY - cpu_khz * INHIBIT_TIME / 1000; 361 | 362 | master = ecrt_request_master(0); 363 | if (!master) { 364 | ret = -EBUSY; 365 | printk(KERN_ERR PFX "Requesting master 0 failed!\n"); 366 | goto out_return; 367 | } 368 | 369 | ecrt_master_callbacks(master, send_callback, receive_callback, master); 370 | 371 | printk(KERN_INFO PFX "Registering domain...\n"); 372 | if (!(domain1 = ecrt_master_create_domain(master))) { 373 | printk(KERN_ERR PFX "Domain creation failed!\n"); 374 | goto out_release_master; 375 | } 376 | // if (!(domain2 = ecrt_master_create_domain(master))) { 377 | // printk(KERN_ERR PFX "Domain2 creation failed!\n"); 378 | // goto out_release_master; 379 | // } 380 | 381 | printk(KERN_INFO PFX "Configuring PDOs...\n"); 382 | 383 | if (!(sc = ecrt_master_slave_config(master, yas, yaskawa))) { 384 | printk(KERN_ERR PFX "Failed to get slave configuration.\n"); 385 | goto out_release_master; 386 | } 387 | // ecrt_slave_config_dc(sc, 0x300, 1000000, 0, 0, 0); 388 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 389 | printk(KERN_ERR PFX "Failed to configure SDOs.\n"); 390 | goto out_release_master; 391 | } 392 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 393 | printk(KERN_ERR PFX "Failed to configure PDOs.\n"); 394 | goto out_release_master; 395 | } 396 | 397 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 398 | printk(KERN_ERR PFX "1st motor RX_PDO entry registration failed!\n"); 399 | goto out_release_master; 400 | } 401 | 402 | 403 | printk(KERN_INFO PFX "Activating master...\n"); 404 | 405 | if (ecrt_master_activate(master)) { 406 | printk(KERN_ERR PFX "Failed to activate master!\n"); 407 | goto out_release_master; 408 | } 409 | 410 | // Get internal process data for domain 411 | domain1_pd = ecrt_domain_data(domain1); 412 | // domain2_pd = ecrt_domain_data(domain2); 413 | 414 | printk(KERN_INFO PFX "Starting cyclic sample thread...\n"); 415 | requested_ticks = nano2count(TIMERTICKS); 416 | tick_period = start_rt_timer(requested_ticks); 417 | printk(KERN_INFO PFX "RT timer started with %i/%i ticks.\n", 418 | (int) tick_period, (int) requested_ticks); 419 | 420 | if (rt_task_init(&task, run, 0, 2000, 0, 1, NULL)) { 421 | printk(KERN_ERR PFX "Failed to init RTAI task!\n"); 422 | goto out_stop_timer; 423 | } 424 | 425 | now = rt_get_time(); 426 | if (rt_task_make_periodic(&task, now + tick_period, tick_period)) { 427 | printk(KERN_ERR PFX "Failed to run RTAI task!\n"); 428 | goto out_stop_task; 429 | } 430 | 431 | printk(KERN_INFO PFX "Initialized.\n"); 432 | return 0; 433 | 434 | out_stop_task: 435 | rt_task_delete(&task); 436 | out_stop_timer: 437 | stop_rt_timer(); 438 | out_release_master: 439 | printk(KERN_ERR PFX "Releasing master...\n"); 440 | ecrt_release_master(master); 441 | out_return: 442 | rt_sem_delete(&master_sem); 443 | printk(KERN_ERR PFX "Failed to load. Aborting.\n"); 444 | return ret; 445 | } 446 | 447 | /*****************************************************************************/ 448 | 449 | void __exit cleanup_mod(void) 450 | { 451 | printk(KERN_INFO PFX "Stopping...\n"); 452 | 453 | 454 | 455 | rt_task_delete(&task); 456 | stop_rt_timer(); 457 | ecrt_release_master(master); 458 | rt_sem_delete(&master_sem); 459 | 460 | printk(KERN_INFO PFX "Unloading.\n"); 461 | } 462 | 463 | /*****************************************************************************/ 464 | 465 | MODULE_LICENSE("GPL"); 466 | MODULE_AUTHOR("Florian Pose "); 467 | MODULE_DESCRIPTION("EtherCAT distributed clocks sample module"); 468 | 469 | module_init(init_mod); 470 | module_exit(cleanup_mod); 471 | 472 | /*****************************************************************************/ 473 | -------------------------------------------------------------------------------- /examples/dc_rtai/modules.order: -------------------------------------------------------------------------------- 1 | kernel//home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.ko 2 | -------------------------------------------------------------------------------- /examples/dc_user/.deps/ec_dc_user_example-main.Po: -------------------------------------------------------------------------------- 1 | ec_dc_user_example-main.o: main.c /usr/include/errno.h \ 2 | /usr/include/features.h /usr/include/bits/predefs.h \ 3 | /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ 4 | /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ 5 | /usr/include/bits/errno.h /usr/include/linux/errno.h \ 6 | /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ 7 | /usr/include/asm-generic/errno-base.h /usr/include/signal.h \ 8 | /usr/include/bits/sigset.h /usr/include/bits/types.h \ 9 | /usr/include/bits/typesizes.h /usr/include/bits/signum.h \ 10 | /usr/include/time.h /usr/include/bits/siginfo.h \ 11 | /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ 12 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stddef.h \ 13 | /usr/include/bits/sigstack.h /usr/include/bits/pthreadtypes.h \ 14 | /usr/include/bits/sigthread.h /usr/include/stdio.h /usr/include/libio.h \ 15 | /usr/include/_G_config.h /usr/include/wchar.h \ 16 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stdarg.h \ 17 | /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ 18 | /usr/include/string.h /usr/include/xlocale.h /usr/include/sys/resource.h \ 19 | /usr/include/bits/resource.h /usr/include/bits/time.h \ 20 | /usr/include/sys/time.h /usr/include/sys/select.h \ 21 | /usr/include/bits/select.h /usr/include/sys/types.h \ 22 | /usr/include/endian.h /usr/include/bits/endian.h \ 23 | /usr/include/bits/byteswap.h /usr/include/sys/sysmacros.h \ 24 | /usr/include/unistd.h /usr/include/bits/posix_opt.h \ 25 | /usr/include/bits/confname.h /usr/include/getopt.h \ 26 | /usr/include/sys/mman.h /usr/include/bits/mman.h /usr/include/malloc.h \ 27 | ../../include/ecrt.h /usr/include/stdlib.h /usr/include/alloca.h \ 28 | /usr/include/stdint.h /usr/include/bits/wchar.h 29 | 30 | /usr/include/errno.h: 31 | 32 | /usr/include/features.h: 33 | 34 | /usr/include/bits/predefs.h: 35 | 36 | /usr/include/sys/cdefs.h: 37 | 38 | /usr/include/bits/wordsize.h: 39 | 40 | /usr/include/gnu/stubs.h: 41 | 42 | /usr/include/gnu/stubs-32.h: 43 | 44 | /usr/include/bits/errno.h: 45 | 46 | /usr/include/linux/errno.h: 47 | 48 | /usr/include/asm/errno.h: 49 | 50 | /usr/include/asm-generic/errno.h: 51 | 52 | /usr/include/asm-generic/errno-base.h: 53 | 54 | /usr/include/signal.h: 55 | 56 | /usr/include/bits/sigset.h: 57 | 58 | /usr/include/bits/types.h: 59 | 60 | /usr/include/bits/typesizes.h: 61 | 62 | /usr/include/bits/signum.h: 63 | 64 | /usr/include/time.h: 65 | 66 | /usr/include/bits/siginfo.h: 67 | 68 | /usr/include/bits/sigaction.h: 69 | 70 | /usr/include/bits/sigcontext.h: 71 | 72 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stddef.h: 73 | 74 | /usr/include/bits/sigstack.h: 75 | 76 | /usr/include/bits/pthreadtypes.h: 77 | 78 | /usr/include/bits/sigthread.h: 79 | 80 | /usr/include/stdio.h: 81 | 82 | /usr/include/libio.h: 83 | 84 | /usr/include/_G_config.h: 85 | 86 | /usr/include/wchar.h: 87 | 88 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stdarg.h: 89 | 90 | /usr/include/bits/stdio_lim.h: 91 | 92 | /usr/include/bits/sys_errlist.h: 93 | 94 | /usr/include/string.h: 95 | 96 | /usr/include/xlocale.h: 97 | 98 | /usr/include/sys/resource.h: 99 | 100 | /usr/include/bits/resource.h: 101 | 102 | /usr/include/bits/time.h: 103 | 104 | /usr/include/sys/time.h: 105 | 106 | /usr/include/sys/select.h: 107 | 108 | /usr/include/bits/select.h: 109 | 110 | /usr/include/sys/types.h: 111 | 112 | /usr/include/endian.h: 113 | 114 | /usr/include/bits/endian.h: 115 | 116 | /usr/include/bits/byteswap.h: 117 | 118 | /usr/include/sys/sysmacros.h: 119 | 120 | /usr/include/unistd.h: 121 | 122 | /usr/include/bits/posix_opt.h: 123 | 124 | /usr/include/bits/confname.h: 125 | 126 | /usr/include/getopt.h: 127 | 128 | /usr/include/sys/mman.h: 129 | 130 | /usr/include/bits/mman.h: 131 | 132 | /usr/include/malloc.h: 133 | 134 | ../../include/ecrt.h: 135 | 136 | /usr/include/stdlib.h: 137 | 138 | /usr/include/alloca.h: 139 | 140 | /usr/include/stdint.h: 141 | 142 | /usr/include/bits/wchar.h: 143 | -------------------------------------------------------------------------------- /examples/dc_user/.libs/ec_dc_user_example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/dc_user/.libs/ec_dc_user_example -------------------------------------------------------------------------------- /examples/dc_user/.libs/lt-ec_dc_user_example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/dc_user/.libs/lt-ec_dc_user_example -------------------------------------------------------------------------------- /examples/dc_user/.main_pano.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/dc_user/.main_pano.c.swp -------------------------------------------------------------------------------- /examples/dc_user/Makefile.am: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id: Makefile.am,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | # 5 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along with 19 | # the IgH EtherCAT Master; if not, write to the Free Software Foundation, 20 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | #------------------------------------------------------------------------------ 29 | 30 | noinst_PROGRAMS = ec_dc_user_example 31 | 32 | ec_dc_user_example_SOURCES = main.c 33 | ec_dc_user_example_CFLAGS = -I$(top_srcdir)/include -Wall 34 | ec_dc_user_example_LDFLAGS = -L$(top_builddir)/lib/.libs -lethercat -lrt 35 | 36 | #------------------------------------------------------------------------------ 37 | -------------------------------------------------------------------------------- /examples/dc_user/ec_dc_user_example: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # ec_dc_user_example - temporary wrapper script for .libs/ec_dc_user_example 4 | # Generated by libtool (GNU libtool) 2.4 5 | # 6 | # The ec_dc_user_example program cannot be directly executed until all the libtool 7 | # libraries that it depends on are installed. 8 | # 9 | # This wrapper script should never be moved out of the build directory. 10 | # If it is, it will not operate correctly. 11 | 12 | # Sed substitution that helps us do robust quoting. It backslashifies 13 | # metacharacters that are still active within double-quoted strings. 14 | sed_quote_subst='s/\([`"$\\]\)/\\\1/g' 15 | 16 | # Be Bourne compatible 17 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 18 | emulate sh 19 | NULLCMD=: 20 | # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 21 | # is contrary to our usage. Disable this feature. 22 | alias -g '${1+"$@"}'='"$@"' 23 | setopt NO_GLOB_SUBST 24 | else 25 | case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 26 | fi 27 | BIN_SH=xpg4; export BIN_SH # for Tru64 28 | DUALCASE=1; export DUALCASE # for MKS sh 29 | 30 | # The HP-UX ksh and POSIX shell print the target directory to stdout 31 | # if CDPATH is set. 32 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH 33 | 34 | relink_command="(cd /home/lab428/ethercat-1.5.2/examples/dc_user; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; gcc -I../../include -Wall -Wall -g -o \$progdir/\$file ec_dc_user_example-main.o -lm -L../../lib/.libs /home/lab428/ethercat-1.5.2/lib/.libs/libethercat.so -lrt -Wl,-rpath -Wl,/home/lab428/ethercat-1.5.2/lib/.libs -Wl,-rpath -Wl,/opt/etherlab/lib)" 35 | 36 | # This environment variable determines our operation mode. 37 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then 38 | # install mode needs the following variables: 39 | generated_by_libtool_version='2.4' 40 | notinst_deplibs=' /home/lab428/ethercat-1.5.2/lib/.libs/libethercat.la' 41 | else 42 | # When we are sourced in execute mode, $file and $ECHO are already set. 43 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then 44 | file="$0" 45 | 46 | # A function that is used when there is no print builtin or printf. 47 | func_fallback_echo () 48 | { 49 | eval 'cat <<_LTECHO_EOF 50 | $1 51 | _LTECHO_EOF' 52 | } 53 | ECHO="printf %s\\n" 54 | fi 55 | 56 | # Very basic option parsing. These options are (a) specific to 57 | # the libtool wrapper, (b) are identical between the wrapper 58 | # /script/ and the wrapper /executable/ which is used only on 59 | # windows platforms, and (c) all begin with the string --lt- 60 | # (application programs are unlikely to have options which match 61 | # this pattern). 62 | # 63 | # There are only two supported options: --lt-debug and 64 | # --lt-dump-script. There is, deliberately, no --lt-help. 65 | # 66 | # The first argument to this parsing function should be the 67 | # script's ../../libtool value, followed by no. 68 | lt_option_debug= 69 | func_parse_lt_options () 70 | { 71 | lt_script_arg0=$0 72 | shift 73 | for lt_opt 74 | do 75 | case "$lt_opt" in 76 | --lt-debug) lt_option_debug=1 ;; 77 | --lt-dump-script) 78 | lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` 79 | test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. 80 | lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` 81 | cat "$lt_dump_D/$lt_dump_F" 82 | exit 0 83 | ;; 84 | --lt-*) 85 | $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 86 | exit 1 87 | ;; 88 | esac 89 | done 90 | 91 | # Print the debug banner immediately: 92 | if test -n "$lt_option_debug"; then 93 | echo "ec_dc_user_example:ec_dc_user_example:${LINENO}: libtool wrapper (GNU libtool) 2.4" 1>&2 94 | fi 95 | } 96 | 97 | # Used when --lt-debug. Prints its arguments to stdout 98 | # (redirection is the responsibility of the caller) 99 | func_lt_dump_args () 100 | { 101 | lt_dump_args_N=1; 102 | for lt_arg 103 | do 104 | $ECHO "ec_dc_user_example:ec_dc_user_example:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" 105 | lt_dump_args_N=`expr $lt_dump_args_N + 1` 106 | done 107 | } 108 | 109 | # Core function for launching the target application 110 | func_exec_program_core () 111 | { 112 | 113 | if test -n "$lt_option_debug"; then 114 | $ECHO "ec_dc_user_example:ec_dc_user_example:${LINENO}: newargv[0]: $progdir/$program" 1>&2 115 | func_lt_dump_args ${1+"$@"} 1>&2 116 | fi 117 | exec "$progdir/$program" ${1+"$@"} 118 | 119 | $ECHO "$0: cannot exec $program $*" 1>&2 120 | exit 1 121 | } 122 | 123 | # A function to encapsulate launching the target application 124 | # Strips options in the --lt-* namespace from $@ and 125 | # launches target application with the remaining arguments. 126 | func_exec_program () 127 | { 128 | for lt_wr_arg 129 | do 130 | case $lt_wr_arg in 131 | --lt-*) ;; 132 | *) set x "$@" "$lt_wr_arg"; shift;; 133 | esac 134 | shift 135 | done 136 | func_exec_program_core ${1+"$@"} 137 | } 138 | 139 | # Parse options 140 | func_parse_lt_options "$0" ${1+"$@"} 141 | 142 | # Find the directory that this script lives in. 143 | thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` 144 | test "x$thisdir" = "x$file" && thisdir=. 145 | 146 | # Follow symbolic links until we get to the real thisdir. 147 | file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` 148 | while test -n "$file"; do 149 | destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` 150 | 151 | # If there was a directory component, then change thisdir. 152 | if test "x$destdir" != "x$file"; then 153 | case "$destdir" in 154 | [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; 155 | *) thisdir="$thisdir/$destdir" ;; 156 | esac 157 | fi 158 | 159 | file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` 160 | file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` 161 | done 162 | 163 | # Usually 'no', except on cygwin/mingw when embedded into 164 | # the cwrapper. 165 | WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no 166 | if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then 167 | # special case for '.' 168 | if test "$thisdir" = "."; then 169 | thisdir=`pwd` 170 | fi 171 | # remove .libs from thisdir 172 | case "$thisdir" in 173 | *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; 174 | .libs ) thisdir=. ;; 175 | esac 176 | fi 177 | 178 | # Try to get the absolute directory name. 179 | absdir=`cd "$thisdir" && pwd` 180 | test -n "$absdir" && thisdir="$absdir" 181 | 182 | program=lt-'ec_dc_user_example' 183 | progdir="$thisdir/.libs" 184 | 185 | if test ! -f "$progdir/$program" || 186 | { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ 187 | test "X$file" != "X$progdir/$program"; }; then 188 | 189 | file="$$-$program" 190 | 191 | if test ! -d "$progdir"; then 192 | mkdir "$progdir" 193 | else 194 | rm -f "$progdir/$file" 195 | fi 196 | 197 | # relink executable if necessary 198 | if test -n "$relink_command"; then 199 | if relink_command_output=`eval $relink_command 2>&1`; then : 200 | else 201 | printf %s\n "$relink_command_output" >&2 202 | rm -f "$progdir/$file" 203 | exit 1 204 | fi 205 | fi 206 | 207 | mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || 208 | { rm -f "$progdir/$program"; 209 | mv -f "$progdir/$file" "$progdir/$program"; } 210 | rm -f "$progdir/$file" 211 | fi 212 | 213 | if test -f "$progdir/$program"; then 214 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then 215 | # Run the actual program with our arguments. 216 | func_exec_program ${1+"$@"} 217 | fi 218 | else 219 | # The program doesn't exist. 220 | $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 221 | $ECHO "This script is just a wrapper for $program." 1>&2 222 | $ECHO "See the libtool documentation for more information." 1>&2 223 | exit 1 224 | fi 225 | fi 226 | -------------------------------------------------------------------------------- /examples/dc_user/main_pano.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | /* 43 | #include 44 | #include 45 | */ 46 | /****************************************************************************/ 47 | 48 | #include "ecrt.h" 49 | 50 | /****************************************************************************/ 51 | 52 | // Application parameters 53 | #define FREQUENCY 4000 54 | #define CLOCK_TO_USE CLOCK_REALTIME 55 | #define CONFIGURE_PDOS 1 56 | 57 | // Optional features 58 | #define PDO_SETTING1 1 59 | #define SDO_ACCESS 1 60 | 61 | 62 | /****************************************************************************/ 63 | 64 | #define NSEC_PER_SEC (1000000000L) 65 | #define PERIOD_NS (NSEC_PER_SEC / FREQUENCY) 66 | 67 | #define DIFF_NS(A, B) (((B).tv_sec - (A).tv_sec) * NSEC_PER_SEC + \ 68 | (B).tv_nsec - (A).tv_nsec) 69 | 70 | #define TIMESPEC2NS(T) ((uint64_t) (T).tv_sec * NSEC_PER_SEC + (T).tv_nsec) 71 | 72 | /****************************************************************************/ 73 | 74 | // EtherCAT 75 | static ec_master_t *master = NULL; 76 | static ec_master_state_t master_state = {}; 77 | 78 | static ec_domain_t *domain1 = NULL; 79 | static ec_domain_state_t domain1_state = {}; 80 | static ec_domain_t *domain2 = NULL; 81 | static ec_domain_state_t domain2_state = {}; 82 | /****************************************************************************/ 83 | static ec_slave_config_t *sc = NULL; 84 | static ec_slave_config_state_t sc_state = {}; 85 | /****************************************************************************/ 86 | 87 | // process data 88 | static uint8_t *domain1_pd = NULL; 89 | static uint8_t *domain2_pd = NULL; 90 | #define yas 0,0 91 | #define yaskawa 0x0000066f, 0x525100d1 92 | 93 | /***************************** 20140224 ************************************/ 94 | 95 | //signal to turn off servo on state 96 | static unsigned int servooff =0; 97 | static unsigned int deactive; 98 | // offsets for PDO entries 99 | static unsigned int ctrl_word ; 100 | static unsigned int mode ; 101 | static unsigned int tar_torq ; 102 | static unsigned int max_torq ; 103 | static unsigned int tar_pos ; 104 | static unsigned int max_speed ; 105 | static unsigned int touch_probe_func ; 106 | static unsigned int tar_vel ; 107 | static unsigned int error_code ; 108 | static unsigned int status_word; 109 | static unsigned int mode_display ; 110 | static unsigned int pos_act; 111 | static unsigned int vel_act; 112 | static unsigned int torq_act; 113 | static unsigned int touch_probe_status; 114 | static unsigned int touch_probe_pos; 115 | static unsigned int digital_input; 116 | 117 | static signed long temp[8]={}; 118 | 119 | //rx pdo entry of 1st motor 120 | const static ec_pdo_entry_reg_t domain1_regs[] = { 121 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 122 | {yas, yaskawa,0x6060, 00, &mode }, 123 | {yas, yaskawa,0x6071, 00, &tar_torq }, 124 | {yas, yaskawa,0x6072, 00, &max_torq }, 125 | {yas, yaskawa,0x607a, 00, &tar_pos }, 126 | {yas, yaskawa,0x6080, 00, &max_speed }, 127 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 128 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 129 | {} 130 | }; 131 | const static ec_pdo_entry_reg_t domain2_regs[] = { 132 | {yas, yaskawa,0x603f, 00, &error_code }, 133 | {yas, yaskawa,0x6041, 00, &status_word }, 134 | {yas, yaskawa,0x6061, 00, &mode_display }, 135 | {yas, yaskawa,0x6064, 00, &pos_act }, 136 | {yas, yaskawa,0x606c, 00, &vel_act }, 137 | {yas, yaskawa,0x6077, 00, &torq_act }, 138 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 139 | {yas ,yaskawa,0x60ba, 00, &touch_probe_pos }, 140 | {yas, yaskawa,0x60fd, 00, &digital_input }, 141 | {} 142 | }; 143 | 144 | 145 | 146 | 147 | float value = 0; 148 | static unsigned int counter = 0; 149 | static unsigned int blink = 0; 150 | static unsigned int sync_ref_counter = 0; 151 | const struct timespec cycletime = {0, PERIOD_NS}; 152 | 153 | /*****************************************************************************/ 154 | 155 | #if PDO_SETTING1 156 | 157 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 158 | {0x6040, 0x00, 16}, 159 | {0x6060, 0x00, 8 }, 160 | {0x6071, 0x00, 16}, 161 | {0x6072, 0x00, 16}, 162 | {0x607a, 0x00, 32}, 163 | {0x6080, 0x00, 32}, 164 | {0x60b8, 0x00, 16}, 165 | {0x60ff, 0x00, 32}, 166 | {0x603f, 0x00, 16}, 167 | {0x6041, 0x00, 16}, 168 | {0x6061, 0x00, 8 }, 169 | {0x6064, 0x00, 32}, 170 | {0x606c, 0x00, 32}, 171 | {0x6077, 0x00, 16}, 172 | {0x60b9, 0x00, 16}, 173 | {0x60ba, 0x00, 32}, 174 | {0x60fd, 0x00, 32}, 175 | };//{index,subindex,lenth} 176 | 177 | static ec_pdo_info_t slave_0_pdos[] = { 178 | {0x1600, 8, slave_0_pdo_entries + 0}, 179 | {0x1a00, 9, slave_0_pdo_entries + 8}, 180 | }; 181 | 182 | 183 | static ec_sync_info_t slave_0_syncs[] = { 184 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 185 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 186 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 187 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 188 | {0xff} 189 | }; 190 | 191 | #endif 192 | /***********************************************************************/ 193 | 194 | struct timespec timespec_add(struct timespec time1, struct timespec time2) 195 | { 196 | struct timespec result; 197 | 198 | if ((time1.tv_nsec + time2.tv_nsec) >= NSEC_PER_SEC) { 199 | result.tv_sec = time1.tv_sec + time2.tv_sec + 1; 200 | result.tv_nsec = time1.tv_nsec + time2.tv_nsec - NSEC_PER_SEC; 201 | } else { 202 | result.tv_sec = time1.tv_sec + time2.tv_sec; 203 | result.tv_nsec = time1.tv_nsec + time2.tv_nsec; 204 | } 205 | 206 | return result; 207 | } 208 | 209 | /*****************************************************************************/ 210 | 211 | void endsignal(int sig) 212 | { 213 | 214 | servooff = 1; 215 | signal( SIGINT , SIG_DFL ); 216 | } 217 | 218 | /*****************************************************************************/ 219 | 220 | 221 | void check_domain1_state(void) 222 | { 223 | ec_domain_state_t ds; 224 | ecrt_domain_state(domain1, &ds); 225 | 226 | //struct timespec time_wc1,time_wc2; 227 | if (ds.working_counter != domain1_state.working_counter) 228 | printf("Domain1: WC %u.\n", ds.working_counter); 229 | if (ds.wc_state != domain1_state.wc_state) 230 | printf("Domain1: State %u.\n", ds.wc_state); 231 | 232 | domain1_state = ds; 233 | } 234 | 235 | /*****************************************************************************/ 236 | 237 | void check_domain2_state(void) 238 | { 239 | ec_domain_state_t ds2; 240 | ecrt_domain_state(domain2, &ds2); 241 | 242 | if (ds2.working_counter != domain2_state.working_counter) 243 | printf("Domain2: WC %u.\n", ds2.working_counter); 244 | if (ds2.wc_state != domain2_state.wc_state) 245 | printf("Domain2: State %u.\n", ds2.wc_state); 246 | 247 | domain2_state = ds2; 248 | } 249 | 250 | 251 | 252 | void check_master_state(void) 253 | { 254 | ec_master_state_t ms; 255 | 256 | ecrt_master_state(master, &ms); 257 | 258 | if (ms.slaves_responding != master_state.slaves_responding) 259 | printf("%u slave(s).\n", ms.slaves_responding); 260 | if (ms.al_states != master_state.al_states) 261 | printf("AL states: 0x%02X.\n", ms.al_states); 262 | if (ms.link_up != master_state.link_up) 263 | printf("Link is %s.\n", ms.link_up ? "up" : "down"); 264 | 265 | master_state = ms; 266 | } 267 | 268 | /****************************************************************************/ 269 | 270 | void cyclic_task() 271 | { 272 | struct timespec wakeupTime, time; 273 | // get current time 274 | clock_gettime(CLOCK_TO_USE, &wakeupTime); 275 | 276 | while(1) { 277 | 278 | if(deactive==1){ 279 | break; 280 | } 281 | 282 | wakeupTime = timespec_add(wakeupTime, cycletime); 283 | clock_nanosleep(CLOCK_TO_USE, TIMER_ABSTIME, &wakeupTime, NULL); 284 | 285 | 286 | // writter_receive(master); 287 | ecrt_master_receive(master); 288 | ecrt_domain_process(domain1); 289 | ecrt_domain_process(domain2); 290 | 291 | temp[0]=EC_READ_U16(domain2_pd + status_word); 292 | temp[1]=EC_READ_S32(domain2_pd + mode_display); 293 | // temp[2]=EC_READ_U16(domain2_pd + pos_act); 294 | // temp[3]=EC_READ_U32(domain2_pd + vel_act); 295 | // temp[4]=EC_READ_S32(domain2_pd + torq_act); 296 | // temp[5]=EC_READ_U32(domain2_pd + digital_input); 297 | if (counter) { 298 | counter--; 299 | } else { // do this at 1 Hz 300 | counter = FREQUENCY; 301 | check_master_state(); 302 | blink = !blink; 303 | } 304 | printf("after value =%x\n",temp[0]); 305 | // write process data 306 | if(servooff==1){//servo off 307 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 308 | printf("0 is ok\n"); 309 | } 310 | else if( (temp[0]&0x004f) == 0x0040 ){ 311 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 312 | printf("%x\n",temp[0]); 313 | printf("1 is ok\n"); 314 | } 315 | else if( (temp[0]&0x006f) == 0x0021){ 316 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 317 | printf("%x\n",temp[0]); 318 | printf("2 is ok\n"); 319 | } 320 | else if( (temp[0]&0x006f) == 0x0023){ 321 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f ); 322 | EC_WRITE_S32(domain1_pd+tar_pos,0); 323 | EC_WRITE_S32(domain1_pd+tar_vel, 0xffff); 324 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 325 | printf("%x\n",temp[0]); 326 | printf("3 is ok\n"); 327 | } 328 | else if( (temp[0]&0x006f) == 0x0027){ 329 | EC_WRITE_S32(domain1_pd+tar_pos, (value+=2000) ); 330 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 331 | // int q =0; 332 | // for (q =0; q<6; q++) 333 | // printf("q = %x\n",temp[q]); 334 | printf("4 is ok\n"); 335 | } 336 | clock_gettime(CLOCK_TO_USE, &time); 337 | ecrt_master_application_time(master, TIMESPEC2NS(time)); 338 | if (sync_ref_counter) { 339 | sync_ref_counter--; 340 | } 341 | else { 342 | sync_ref_counter = 1; // sync every cycle 343 | ecrt_master_sync_reference_clock(master); 344 | } 345 | ecrt_master_sync_slave_clocks(master); 346 | 347 | 348 | 349 | // send process data 350 | ecrt_domain_queue(domain1); 351 | ecrt_domain_queue(domain2); 352 | 353 | ecrt_master_send(master); 354 | 355 | 356 | 357 | } 358 | } 359 | 360 | /****************************************************************************/ 361 | 362 | int main(int argc, char **argv) 363 | { 364 | ec_slave_config_t *sc; 365 | 366 | 367 | if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) { 368 | perror("mlockall failed"); 369 | return -1; 370 | } 371 | master = ecrt_request_master(0); 372 | if (!master) 373 | return -1; 374 | 375 | domain1 = ecrt_master_create_domain(master); 376 | if (!domain1) 377 | return -1; 378 | 379 | domain2 = ecrt_master_create_domain(master); 380 | if (!domain2) 381 | return -1; 382 | 383 | 384 | 385 | if (!(sc = ecrt_master_slave_config( 386 | master, yas, yaskawa))) { 387 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 388 | return -1; 389 | } 390 | #if SDO_ACCESS 391 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 392 | return -1; 393 | } 394 | #endif 395 | 396 | 397 | #if CONFIGURE_PDOS 398 | printf("Configuring PDOs...\n"); 399 | 400 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 401 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 402 | return -1; 403 | } 404 | 405 | 406 | #endif 407 | 408 | /************************************************* motor1馬達domain註冊到domain_process data **********************************************/ 409 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 410 | fprintf(stderr, "1st motor RX_PDO entry registration failed!\n"); 411 | return -1; 412 | } 413 | 414 | if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 415 | fprintf(stderr, "1st motor TX_PDO entry registration failed!\n"); 416 | return -1; 417 | } 418 | 419 | 420 | ecrt_slave_config_dc(sc, 0x0300,500000 , 0, 0, 0); 421 | 422 | printf("Activating master...\n"); 423 | 424 | if (ecrt_master_activate(master)) 425 | return -1; 426 | 427 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 428 | return -1; 429 | } 430 | if (!(domain2_pd = ecrt_domain_data(domain2))) { 431 | return -1; 432 | } 433 | 434 | 435 | 436 | 437 | pid_t pid = getpid(); 438 | if (setpriority(PRIO_PROCESS, pid, -20)) 439 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 440 | strerror(errno)); 441 | 442 | signal( SIGINT , endsignal ); //按CTRL+C 利用中斷結束程式 443 | printf("Starting cyclic function.\n"); 444 | cyclic_task(); 445 | ecrt_release_master(master); 446 | 447 | return 0; 448 | } 449 | -------------------------------------------------------------------------------- /examples/dc_user/main_yas.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v bc2d4bf9cbe5 2012/09/06 18:22:24 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | /* 43 | #include 44 | #include 45 | */ 46 | /****************************************************************************/ 47 | 48 | #include "ecrt.h" 49 | 50 | /****************************************************************************/ 51 | 52 | // Application parameters 53 | #define FREQUENCY 500 54 | #define CLOCK_TO_USE CLOCK_REALTIME 55 | #define CONFIGURE_PDOS 1 56 | 57 | // Optional features 58 | #define PDO_SETTING1 1 59 | 60 | /****************************************************************************/ 61 | 62 | #define NSEC_PER_SEC (1000000000L) 63 | #define PERIOD_NS (NSEC_PER_SEC / FREQUENCY) 64 | 65 | #define DIFF_NS(A, B) (((B).tv_sec - (A).tv_sec) * NSEC_PER_SEC + \ 66 | (B).tv_nsec - (A).tv_nsec) 67 | 68 | #define TIMESPEC2NS(T) ((uint64_t) (T).tv_sec * NSEC_PER_SEC + (T).tv_nsec) 69 | 70 | /****************************************************************************/ 71 | 72 | // EtherCAT 73 | static ec_master_t *master = NULL; 74 | static ec_master_state_t master_state = {}; 75 | 76 | static ec_domain_t *domain1 = NULL; 77 | static ec_domain_state_t domain1_state = {}; 78 | static ec_domain_t *domain2 = NULL; 79 | static ec_domain_state_t domain2_state = {}; 80 | /****************************************************************************/ 81 | static ec_slave_config_t *sc = NULL; 82 | static ec_slave_config_state_t sc_state = {}; 83 | /****************************************************************************/ 84 | 85 | // process data 86 | static uint8_t *domain1_pd = NULL; 87 | static uint8_t *domain2_pd = NULL; 88 | #define yas 0,0 89 | #define yaskawa 0x00000539, 0x02200001 90 | 91 | /***************************** 20140224 ************************************/ 92 | 93 | //signal to turn off servo on state 94 | static unsigned int servooff; 95 | static unsigned int deactive; 96 | 97 | // offsets for PDO entries 98 | static unsigned int ctrl_word ; 99 | static unsigned int target_pos ; 100 | static unsigned int tar_velo ; 101 | static unsigned int tar_torq ; 102 | static unsigned int max_torq ; 103 | static unsigned int modeofoper ; 104 | static unsigned int interpolateddata ; 105 | 106 | static unsigned int status_word ; 107 | static unsigned int actual_pos ; 108 | static unsigned int torq_actu_val; 109 | static unsigned int following_actu_val; 110 | static unsigned int modeofop_display; 111 | static unsigned int touch_probe_stat; 112 | static unsigned int touch_probe_val; 113 | 114 | static signed long temp[8]={}; 115 | 116 | //rx pdo entry of 1st motor 117 | const static ec_pdo_entry_reg_t domain1_regs[] = { 118 | {yas, yaskawa,0x6040, 00, &ctrl_word },//rx 119 | {yas, yaskawa,0x607a, 00, &target_pos }, 120 | {yas, yaskawa,0x60ff, 00, &tar_velo }, 121 | {yas, yaskawa,0x6071, 00, &tar_torq }, 122 | {yas, yaskawa,0x6072, 00, &max_torq }, 123 | {yas, yaskawa,0x6060, 00, &modeofoper }, 124 | {yas, yaskawa,0x60c1, 01, &interpolateddata }, 125 | {} 126 | }; 127 | 128 | //tx pdo entry of 1st motor 129 | const static ec_pdo_entry_reg_t domain2_regs[] = { 130 | {yas, yaskawa,0x6041, 00, &status_word },//tx 131 | {yas, yaskawa,0x6064, 00, &actual_pos }, 132 | {yas, yaskawa,0x6077, 00, &torq_actu_val }, 133 | {yas, yaskawa,0x60f4, 00, &following_actu_val }, 134 | {yas, yaskawa,0x6061, 00, &modeofop_display }, 135 | {yas, yaskawa,0x60b9, 00, &touch_probe_stat }, 136 | {yas, yaskawa,0x60ba, 00, &touch_probe_val }, 137 | {} 138 | }; 139 | 140 | float value = 0; 141 | static unsigned int counter = 0; 142 | static unsigned int blink = 0; 143 | static unsigned int sync_ref_counter = 0; 144 | const struct timespec cycletime = {0, PERIOD_NS}; 145 | 146 | /*****************************************************************************/ 147 | 148 | #if PDO_SETTING1 149 | 150 | //yaskawa 1st PDO mapping 151 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 152 | {0x6040, 0x00, 16},//RXPDO 153 | {0x607a, 0x00, 32}, 154 | {0x60ff, 0x00, 32}, 155 | {0x6071, 0x00, 16}, 156 | {0x6072, 0x00, 16}, 157 | {0x6060, 0x00, 8}, 158 | {0x0000, 0x00, 8}, 159 | {0x60c1, 0x01, 32}, 160 | {0x6041, 0x00, 16},//TXPDO 161 | {0x6064, 0x00, 32}, 162 | {0x6077, 0x00, 16}, 163 | {0x60f4, 0x00, 32}, 164 | {0x6061, 0x00, 8}, 165 | {0x0000, 0x00, 32}, 166 | {0x60b9, 0x00, 16}, 167 | {0x60ba, 0x00, 32}, 168 | };//{index,subindex,lenth} 169 | 170 | static ec_pdo_info_t slave_0_pdos[] = { 171 | {0x1600, 8, slave_0_pdo_entries + 0}, 172 | {0x1a00, 8, slave_0_pdo_entries + 8}, 173 | }; 174 | 175 | static ec_sync_info_t slave_0_syncs[] = { 176 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 177 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 178 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 179 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 180 | {0xff} 181 | }; 182 | 183 | #endif 184 | 185 | 186 | 187 | /*****************************************************************************/ 188 | 189 | struct timespec timespec_add(struct timespec time1, struct timespec time2) 190 | { 191 | struct timespec result; 192 | 193 | if ((time1.tv_nsec + time2.tv_nsec) >= NSEC_PER_SEC) { 194 | result.tv_sec = time1.tv_sec + time2.tv_sec + 1; 195 | result.tv_nsec = time1.tv_nsec + time2.tv_nsec - NSEC_PER_SEC; 196 | } else { 197 | result.tv_sec = time1.tv_sec + time2.tv_sec; 198 | result.tv_nsec = time1.tv_nsec + time2.tv_nsec; 199 | } 200 | 201 | return result; 202 | } 203 | 204 | /*****************************************************************************/ 205 | 206 | void endsignal(int sig) 207 | { 208 | 209 | servooff = 1; 210 | signal( SIGINT , SIG_DFL ); 211 | } 212 | 213 | /*****************************************************************************/ 214 | 215 | 216 | void check_domain1_state(void) 217 | { 218 | ec_domain_state_t ds; 219 | ecrt_domain_state(domain1, &ds); 220 | 221 | //struct timespec time_wc1,time_wc2; 222 | if (ds.working_counter != domain1_state.working_counter) 223 | printf("Domain1: WC %u.\n", ds.working_counter); 224 | if (ds.wc_state != domain1_state.wc_state) 225 | printf("Domain1: State %u.\n", ds.wc_state); 226 | 227 | domain1_state = ds; 228 | } 229 | 230 | /*****************************************************************************/ 231 | 232 | void check_domain2_state(void) 233 | { 234 | ec_domain_state_t ds2; 235 | ecrt_domain_state(domain2, &ds2); 236 | 237 | if (ds2.working_counter != domain2_state.working_counter) 238 | printf("Domain2: WC %u.\n", ds2.working_counter); 239 | if (ds2.wc_state != domain2_state.wc_state) 240 | printf("Domain2: State %u.\n", ds2.wc_state); 241 | 242 | domain2_state = ds2; 243 | } 244 | 245 | 246 | 247 | void check_master_state(void) 248 | { 249 | ec_master_state_t ms; 250 | 251 | ecrt_master_state(master, &ms); 252 | 253 | if (ms.slaves_responding != master_state.slaves_responding) 254 | printf("%u slave(s).\n", ms.slaves_responding); 255 | if (ms.al_states != master_state.al_states) 256 | printf("AL states: 0x%02X.\n", ms.al_states); 257 | if (ms.link_up != master_state.link_up) 258 | printf("Link is %s.\n", ms.link_up ? "up" : "down"); 259 | 260 | master_state = ms; 261 | } 262 | 263 | /****************************************************************************/ 264 | 265 | void cyclic_task() 266 | { 267 | struct timespec wakeupTime, time; 268 | // get current time 269 | clock_gettime(CLOCK_TO_USE, &wakeupTime); 270 | 271 | while(1) { 272 | 273 | if(deactive==1){ 274 | break; 275 | } 276 | 277 | wakeupTime = timespec_add(wakeupTime, cycletime); 278 | clock_nanosleep(CLOCK_TO_USE, TIMER_ABSTIME, &wakeupTime, NULL); 279 | 280 | ecrt_master_receive(master); 281 | ecrt_domain_process(domain1); 282 | ecrt_domain_process(domain2); 283 | 284 | 285 | 286 | temp[0]=EC_READ_U16(domain2_pd + status_word); 287 | temp[1]=EC_READ_U32(domain2_pd + actual_pos); 288 | 289 | printf("\r%6f \t ",((float)temp[1]/1000) ); 290 | 291 | 292 | if (counter) { 293 | counter--; 294 | } else { // do this at 1 Hz 295 | counter = FREQUENCY; 296 | 297 | 298 | blink = !blink; 299 | } 300 | 301 | // if(servooff==1) 302 | // value=0; 303 | // else if(value<=6.28) 304 | // value=value+0.000628; 305 | // else 306 | // value=0; 307 | 308 | 309 | // printf("after value = %x\n",temp[0]); 310 | // write process data 311 | if(servooff==1){//servo off 312 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 313 | //deactive++; 314 | } 315 | else if( (temp[0]&0x004f) == 0x0040 ){ 316 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 317 | // printf("1.state = %x\n",temp[0]); 318 | } 319 | else if( (temp[0]&0x006f) == 0x0021){ 320 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 321 | // printf("2.state = %x\n",temp[0]); 322 | } 323 | else if( (temp[0]&0x027f) == 0x0233){ 324 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f); 325 | EC_WRITE_S32(domain1_pd+interpolateddata, 0); 326 | // EC_WRITE_S32(domain1_pd+tar_velo, 0xfffff); 327 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 328 | EC_WRITE_S32(domain1_pd+modeofoper, 7); 329 | // printf("3.state = %x\n",temp[0]); 330 | } 331 | else if( (temp[0]&0x027f) == 0x0237){//600 800 332 | EC_WRITE_S32(domain1_pd+interpolateddata,( value+=1000 )); 333 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 334 | // printf("4.state = %x\n",temp[0]); 335 | } 336 | 337 | 338 | 339 | // write application time to master 340 | clock_gettime(CLOCK_TO_USE, &time); 341 | ecrt_master_application_time(master, TIMESPEC2NS(time)); 342 | 343 | 344 | if (sync_ref_counter) { 345 | sync_ref_counter--; 346 | } 347 | else { 348 | sync_ref_counter = 1; // sync every cycle 349 | ecrt_master_sync_reference_clock(master); 350 | } 351 | ecrt_master_sync_slave_clocks(master); 352 | 353 | 354 | 355 | // send process data 356 | ecrt_domain_queue(domain1); 357 | ecrt_domain_queue(domain2); 358 | 359 | ecrt_master_send(master); 360 | 361 | 362 | 363 | } 364 | } 365 | 366 | /****************************************************************************/ 367 | 368 | int main(int argc, char **argv) 369 | { 370 | ec_slave_config_t *sc; 371 | 372 | 373 | if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) { 374 | perror("mlockall failed"); 375 | return -1; 376 | } 377 | 378 | master = ecrt_request_master(0); 379 | if (!master) 380 | return -1; 381 | 382 | domain1 = ecrt_master_create_domain(master); 383 | if (!domain1) 384 | return -1; 385 | 386 | domain2 = ecrt_master_create_domain(master); 387 | if (!domain2) 388 | return -1; 389 | 390 | 391 | 392 | if (!(sc = ecrt_master_slave_config( 393 | master, yas, yaskawa))) { 394 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 395 | return -1; 396 | } 397 | #if CONFIGURE_PDOS 398 | printf("Configuring PDOs...\n"); 399 | 400 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 401 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 402 | return -1; 403 | } 404 | 405 | 406 | #endif 407 | 408 | /************************************************* motor1馬達domain註冊到domain_process data **********************************************/ 409 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 410 | fprintf(stderr, "1st motor RX_PDO entry registration failed!\n"); 411 | return -1; 412 | } 413 | 414 | if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 415 | fprintf(stderr, "1st motor TX_PDO entry registration failed!\n"); 416 | return -1; 417 | } 418 | 419 | 420 | ecrt_slave_config_dc(sc, 0x0300, 4000000, 125000, 0, 0); 421 | 422 | printf("Activating master...\n"); 423 | 424 | if (ecrt_master_activate(master)) 425 | return -1; 426 | 427 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 428 | return -1; 429 | } 430 | if (!(domain2_pd = ecrt_domain_data(domain2))) { 431 | return -1; 432 | } 433 | 434 | 435 | 436 | 437 | pid_t pid = getpid(); 438 | if (setpriority(PRIO_PROCESS, pid, -20)) 439 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 440 | strerror(errno)); 441 | 442 | signal( SIGINT , endsignal ); //按CTRL+C 利用中斷結束程式 443 | printf("Starting cyclic function.\n"); 444 | cyclic_task(); 445 | ecrt_release_master(master); 446 | 447 | return 0; 448 | } 449 | -------------------------------------------------------------------------------- /examples/dc_user/realtime: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # ../scripts/realtime. Generated from realtime.in by configure. 4 | # on Tue Jul 23 20:06:32 UTC 2013 5 | # 6 | 7 | export LANG=C 8 | 9 | PIDOF=/bin/pidof 10 | 11 | CheckKernel() { 12 | case "2.6.32-122-rtai" in 13 | "") ;; 14 | *) 15 | if [ `uname -r` != "2.6.32-122-rtai" ]; then 16 | cat 1>&2 << EOF 17 | RTAPI requires the real-time kernel 2.6.32-122-rtai to run. Before running 18 | this realtime application, reboot and choose this kernel at the boot menu. 19 | EOF 20 | exit 1 21 | fi 22 | esac 23 | } 24 | 25 | RUN_IN_PLACE=no 26 | if [ $RUN_IN_PLACE = yes ]; then 27 | # When using RIP make sure PATH includes the directory where rtapi_app 28 | # resides 29 | PATH=/usr/bin:$PATH; export PATH 30 | fi 31 | 32 | CheckConfig(){ 33 | prefix=/usr 34 | exec_prefix=${prefix} 35 | sysconfdir=/etc 36 | if [ $RUN_IN_PLACE = yes ]; then 37 | RTAPICONF= 38 | # check in the LinuxCNC scripts directory 39 | # $0 is the command to run this script 40 | # strip the script name to leave the path 41 | SCRIPT_DIR=${0%/*} 42 | # the path might be relative 43 | # convert it to an absolute path 44 | SCRIPT_DIR=$(cd $SCRIPT_DIR ; pwd -P) 45 | # now look for rtapi.conf there 46 | if [ -f $SCRIPT_DIR/rtapi.conf ] ; then 47 | RTAPICONF=$SCRIPT_DIR/rtapi.conf 48 | fi 49 | else 50 | if [ -f $sysconfdir/linuxcnc/rtapi.conf ]; then 51 | RTAPICONF=$sysconfdir/linuxcnc/rtapi.conf 52 | fi 53 | fi 54 | if [ -z "$RTAPICONF" ] ; then 55 | echo "Missing rtapi.conf. Check your installation." 1>&2 56 | exit 1 57 | fi 58 | INSMOD="/usr/bin/linuxcnc_module_helper insert" 59 | RMMOD="/usr/bin/linuxcnc_module_helper remove" 60 | LSMOD="/sbin/lsmod" 61 | FUSER="" 62 | 63 | # Import the config 64 | source $RTAPICONF 65 | if [ ! -e $RTLIB_DIR/.runinfo -a -e $RTLIB_DIR/emc2/.runinfo ]; then 66 | # installed system: we don't want our modules mixed up with rtai 67 | RTLIB_DIR=$RTLIB_DIR/emc2 68 | fi 69 | # Export the module path specified in the config. 70 | export MODPATH 71 | # Generate module lists for loading and unloading 72 | # lists contain RTOS modules plus RTAPI and HAL 73 | # unload list is in reverse order 74 | # any module names that are symlinks are resolved to their real names 75 | MODULES_LOAD= 76 | MODULES_UNLOAD= 77 | case $RTPREFIX in 78 | sim) SHM_DEV=/dev/zero;; 79 | *) 80 | for MOD in $MODULES ; do 81 | eval MOD=\${MODPATH_$MOD} 82 | if [ -z "$MOD" ]; then continue; fi 83 | if [ -L $MOD ]; then 84 | MOD=${MOD%/*}/$(readlink $MOD) 85 | fi 86 | MODULES_LOAD="$MODULES_LOAD $MOD" 87 | MOD="${MOD##*/}" 88 | MOD="${MOD%$MODULE_EXT}" 89 | MODULES_UNLOAD="$MOD $MODULES_UNLOAD" 90 | done 91 | MODULES_LOAD="$MODULES_LOAD $RTLIB_DIR/rtapi$MODULE_EXT $RTLIB_DIR/hal_lib$MODULE_EXT" 92 | MODULES_UNLOAD="hal_lib rtapi $MODULES_UNLOAD" 93 | case "$MODULES" in 94 | *rtai_shm*) 95 | SHM_DEV=/dev/rtai_shm 96 | ;; 97 | *mbuff*) 98 | SHM_DEV=/dev/mbuff 99 | ;; 100 | esac 101 | esac 102 | } 103 | 104 | CheckStatus(){ 105 | case $RTPREFIX in 106 | sim) 107 | if [ -z "$($PIDOF rtapi_app)" ]; then 108 | exit 1 109 | else 110 | exit 0 111 | fi ;; 112 | *) 113 | # check loaded/unloaded status of modules 114 | unset NOTLOADED 115 | for MOD in $MODULES_UNLOAD ; do 116 | if /sbin/lsmod | awk '{print $1}' | grep -x $MOD >/dev/null ; then 117 | echo "$MOD is loaded" 118 | else 119 | echo "$MOD is not loaded" 120 | NOTLOADED=NOT 121 | fi 122 | done 123 | if [ -z $NOTLOADED ]; then 124 | exit 0 125 | else 126 | exit 1 127 | fi 128 | esac 129 | } 130 | 131 | CheckMem(){ 132 | # check for user space processes using shared memory 133 | if [ -e /dev/mbuff ] ; then 134 | # device file exists, check for processes using it 135 | if $FUSER -s /dev/mbuff 2>/dev/null; then 136 | # at least one process is using it 137 | echo "ERROR: Can't remove RTLinux modules, kill the following process(es) first" 138 | $FUSER -v /dev/mbuff 139 | exit 1 140 | fi 141 | elif [ -e /dev/rtai_shm ] ; then 142 | # device file exists, check for processes using it 143 | if $FUSER -s /dev/rtai_shm 2>/dev/null; then 144 | # at least one process is using it 145 | echo "ERROR: Can't remove RTAI modules, kill the following process(es) first" 146 | $FUSER -v /dev/rtai_shm 147 | exit 1 148 | fi 149 | fi 150 | } 151 | 152 | Load(){ 153 | CheckKernel 154 | case $RTPREFIX in 155 | sim) 156 | ;; 157 | *) 158 | for MOD in $MODULES_LOAD ; do 159 | $INSMOD $MOD || return $? 160 | done 161 | if [ "$DEBUG" != "" ] && [ -w /proc/rtapi/debug ] ; then 162 | echo "$DEBUG" > /proc/rtapi/debug 163 | fi 164 | esac 165 | } 166 | 167 | CheckLoaded(){ 168 | # this abomination is needed because udev sometimes doesn't 169 | # have the device ready for us in time. 170 | n=0 171 | while [ $n -lt 100 ]; do 172 | [ -w $SHM_DEV ] && return 0 173 | echo "." 1>&2 174 | sleep .1 175 | n=$(($n+1)) 176 | done 177 | echo "Can't write to $SHM_DEV - aborting" 1>&2 178 | exit 1 179 | } 180 | 181 | Unload(){ 182 | CheckKernel 183 | case $RTPREFIX in 184 | sim) 185 | rtapi_app exit 186 | ipcrm -M 0x48414c32 2>/dev/null ;# HAL_KEY 187 | ipcrm -M 0x90280A48 2>/dev/null ;# RTAPI_KEY 188 | ipcrm -M 0x48484c34 2>/dev/null ;# UUID_KEY 189 | ;; 190 | *) 191 | for module in $MODULES_UNLOAD ; do 192 | $RMMOD $module 193 | done 194 | esac 195 | } 196 | 197 | CheckUnloaded(){ 198 | # checks to see if all modules were unloaded 199 | STATUS= 200 | for module in $MODULES_UNLOAD ; do 201 | # check to see if the module is installed 202 | if /sbin/lsmod | awk '{print $1}' | grep -x $module >/dev/null ; then 203 | echo "ERROR: Could not unload '$module'" 204 | STATUS=error 205 | fi 206 | done 207 | if [ -n "$STATUS" ] ; then 208 | exit 1 209 | fi 210 | } 211 | 212 | CMD=$1 213 | 214 | case "$CMD" in 215 | start|load) 216 | CheckConfig 217 | Load || exit $? 218 | CheckLoaded 219 | ;; 220 | restart|force-reload) 221 | CheckConfig 222 | CheckMem 223 | Unload 224 | CheckUnloaded 225 | Load || exit $? 226 | CheckLoaded 227 | ;; 228 | stop|unload) 229 | CheckConfig 230 | CheckMem 231 | Unload || exit $? 232 | ;; 233 | status) 234 | CheckConfig 235 | CheckStatus 236 | ;; 237 | *) 238 | echo "Usage: $0 {start|load|stop|unload|restart|force-reload|status}" >&2 239 | exit 1 240 | ;; 241 | esac 242 | 243 | exit 0 244 | 245 | -------------------------------------------------------------------------------- /examples/modules.order: -------------------------------------------------------------------------------- 1 | kernel//home/lab428/ethercat-1.5.2/examples/mini/ec_mini.ko 2 | kernel//home/lab428/ethercat-1.5.2/examples/rtai/ec_rtai_sample.ko 3 | kernel//home/lab428/ethercat-1.5.2/examples/dc_rtai/ec_dc_rtai_sample.ko 4 | -------------------------------------------------------------------------------- /examples/user/.deps/ec_user_example-main.Po: -------------------------------------------------------------------------------- 1 | ec_user_example-main.o: main.c /usr/include/errno.h \ 2 | /usr/include/features.h /usr/include/bits/predefs.h \ 3 | /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ 4 | /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ 5 | /usr/include/bits/errno.h /usr/include/linux/errno.h \ 6 | /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ 7 | /usr/include/asm-generic/errno-base.h /usr/include/signal.h \ 8 | /usr/include/bits/sigset.h /usr/include/bits/types.h \ 9 | /usr/include/bits/typesizes.h /usr/include/bits/signum.h \ 10 | /usr/include/time.h /usr/include/bits/siginfo.h \ 11 | /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ 12 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stddef.h \ 13 | /usr/include/bits/sigstack.h /usr/include/bits/pthreadtypes.h \ 14 | /usr/include/bits/sigthread.h /usr/include/stdio.h /usr/include/libio.h \ 15 | /usr/include/_G_config.h /usr/include/wchar.h \ 16 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stdarg.h \ 17 | /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ 18 | /usr/include/string.h /usr/include/xlocale.h /usr/include/sys/resource.h \ 19 | /usr/include/bits/resource.h /usr/include/bits/time.h \ 20 | /usr/include/sys/time.h /usr/include/sys/select.h \ 21 | /usr/include/bits/select.h /usr/include/sys/types.h \ 22 | /usr/include/endian.h /usr/include/bits/endian.h \ 23 | /usr/include/bits/byteswap.h /usr/include/sys/sysmacros.h \ 24 | /usr/include/unistd.h /usr/include/bits/posix_opt.h \ 25 | /usr/include/bits/confname.h /usr/include/getopt.h ../../include/ecrt.h \ 26 | /usr/include/stdlib.h /usr/include/alloca.h /usr/include/stdint.h \ 27 | /usr/include/bits/wchar.h 28 | 29 | /usr/include/errno.h: 30 | 31 | /usr/include/features.h: 32 | 33 | /usr/include/bits/predefs.h: 34 | 35 | /usr/include/sys/cdefs.h: 36 | 37 | /usr/include/bits/wordsize.h: 38 | 39 | /usr/include/gnu/stubs.h: 40 | 41 | /usr/include/gnu/stubs-32.h: 42 | 43 | /usr/include/bits/errno.h: 44 | 45 | /usr/include/linux/errno.h: 46 | 47 | /usr/include/asm/errno.h: 48 | 49 | /usr/include/asm-generic/errno.h: 50 | 51 | /usr/include/asm-generic/errno-base.h: 52 | 53 | /usr/include/signal.h: 54 | 55 | /usr/include/bits/sigset.h: 56 | 57 | /usr/include/bits/types.h: 58 | 59 | /usr/include/bits/typesizes.h: 60 | 61 | /usr/include/bits/signum.h: 62 | 63 | /usr/include/time.h: 64 | 65 | /usr/include/bits/siginfo.h: 66 | 67 | /usr/include/bits/sigaction.h: 68 | 69 | /usr/include/bits/sigcontext.h: 70 | 71 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stddef.h: 72 | 73 | /usr/include/bits/sigstack.h: 74 | 75 | /usr/include/bits/pthreadtypes.h: 76 | 77 | /usr/include/bits/sigthread.h: 78 | 79 | /usr/include/stdio.h: 80 | 81 | /usr/include/libio.h: 82 | 83 | /usr/include/_G_config.h: 84 | 85 | /usr/include/wchar.h: 86 | 87 | /usr/lib/gcc/i486-linux-gnu/4.4.3/include/stdarg.h: 88 | 89 | /usr/include/bits/stdio_lim.h: 90 | 91 | /usr/include/bits/sys_errlist.h: 92 | 93 | /usr/include/string.h: 94 | 95 | /usr/include/xlocale.h: 96 | 97 | /usr/include/sys/resource.h: 98 | 99 | /usr/include/bits/resource.h: 100 | 101 | /usr/include/bits/time.h: 102 | 103 | /usr/include/sys/time.h: 104 | 105 | /usr/include/sys/select.h: 106 | 107 | /usr/include/bits/select.h: 108 | 109 | /usr/include/sys/types.h: 110 | 111 | /usr/include/endian.h: 112 | 113 | /usr/include/bits/endian.h: 114 | 115 | /usr/include/bits/byteswap.h: 116 | 117 | /usr/include/sys/sysmacros.h: 118 | 119 | /usr/include/unistd.h: 120 | 121 | /usr/include/bits/posix_opt.h: 122 | 123 | /usr/include/bits/confname.h: 124 | 125 | /usr/include/getopt.h: 126 | 127 | ../../include/ecrt.h: 128 | 129 | /usr/include/stdlib.h: 130 | 131 | /usr/include/alloca.h: 132 | 133 | /usr/include/stdint.h: 134 | 135 | /usr/include/bits/wchar.h: 136 | -------------------------------------------------------------------------------- /examples/user/.libs/ec_user_example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/user/.libs/ec_user_example -------------------------------------------------------------------------------- /examples/user/.libs/lt-ec_user_example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CalvinHsu1223/IGH-EtherCAT-motor-control-sample/a83ac25ecbc62574534491f2548aadbbd6ea6f7c/examples/user/.libs/lt-ec_user_example -------------------------------------------------------------------------------- /examples/user/Makefile.am: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # $Id: Makefile.am,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | # 5 | # Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 6 | # 7 | # This file is part of the IgH EtherCAT Master. 8 | # 9 | # The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License version 2, as 11 | # published by the Free Software Foundation. 12 | # 13 | # The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | # Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along with 19 | # the IgH EtherCAT Master; if not, write to the Free Software Foundation, 20 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | # 22 | # --- 23 | # 24 | # The license mentioned above concerns the source code only. Using the 25 | # EtherCAT technology and brand is only permitted in compliance with the 26 | # industrial property and similar rights of Beckhoff Automation GmbH. 27 | # 28 | #------------------------------------------------------------------------------ 29 | 30 | noinst_PROGRAMS = ec_user_example 31 | 32 | ec_user_example_SOURCES = main.c 33 | ec_user_example_CFLAGS = -I$(top_srcdir)/include -Wall 34 | ec_user_example_LDFLAGS = -L$(top_builddir)/lib/.libs -lethercat 35 | 36 | #------------------------------------------------------------------------------ 37 | -------------------------------------------------------------------------------- /examples/user/ec_user_example: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # ec_user_example - temporary wrapper script for .libs/ec_user_example 4 | # Generated by libtool (GNU libtool) 2.4 5 | # 6 | # The ec_user_example program cannot be directly executed until all the libtool 7 | # libraries that it depends on are installed. 8 | # 9 | # This wrapper script should never be moved out of the build directory. 10 | # If it is, it will not operate correctly. 11 | 12 | # Sed substitution that helps us do robust quoting. It backslashifies 13 | # metacharacters that are still active within double-quoted strings. 14 | sed_quote_subst='s/\([`"$\\]\)/\\\1/g' 15 | 16 | # Be Bourne compatible 17 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 18 | emulate sh 19 | NULLCMD=: 20 | # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 21 | # is contrary to our usage. Disable this feature. 22 | alias -g '${1+"$@"}'='"$@"' 23 | setopt NO_GLOB_SUBST 24 | else 25 | case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 26 | fi 27 | BIN_SH=xpg4; export BIN_SH # for Tru64 28 | DUALCASE=1; export DUALCASE # for MKS sh 29 | 30 | # The HP-UX ksh and POSIX shell print the target directory to stdout 31 | # if CDPATH is set. 32 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH 33 | 34 | relink_command="(cd /home/lab428/ethercat-1.5.2/examples/user; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; gcc -I../../include -Wall -g -o \$progdir/\$file ec_user_example-main.o -L../../lib/.libs /home/lab428/ethercat-1.5.2/lib/.libs/libethercat.so -Wl,-rpath -Wl,/home/lab428/ethercat-1.5.2/lib/.libs -Wl,-rpath -Wl,/opt/etherlab/lib)" 35 | 36 | # This environment variable determines our operation mode. 37 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then 38 | # install mode needs the following variables: 39 | generated_by_libtool_version='2.4' 40 | notinst_deplibs=' /home/lab428/ethercat-1.5.2/lib/.libs/libethercat.la' 41 | else 42 | # When we are sourced in execute mode, $file and $ECHO are already set. 43 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then 44 | file="$0" 45 | 46 | # A function that is used when there is no print builtin or printf. 47 | func_fallback_echo () 48 | { 49 | eval 'cat <<_LTECHO_EOF 50 | $1 51 | _LTECHO_EOF' 52 | } 53 | ECHO="printf %s\\n" 54 | fi 55 | 56 | # Very basic option parsing. These options are (a) specific to 57 | # the libtool wrapper, (b) are identical between the wrapper 58 | # /script/ and the wrapper /executable/ which is used only on 59 | # windows platforms, and (c) all begin with the string --lt- 60 | # (application programs are unlikely to have options which match 61 | # this pattern). 62 | # 63 | # There are only two supported options: --lt-debug and 64 | # --lt-dump-script. There is, deliberately, no --lt-help. 65 | # 66 | # The first argument to this parsing function should be the 67 | # script's ../../libtool value, followed by no. 68 | lt_option_debug= 69 | func_parse_lt_options () 70 | { 71 | lt_script_arg0=$0 72 | shift 73 | for lt_opt 74 | do 75 | case "$lt_opt" in 76 | --lt-debug) lt_option_debug=1 ;; 77 | --lt-dump-script) 78 | lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` 79 | test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. 80 | lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` 81 | cat "$lt_dump_D/$lt_dump_F" 82 | exit 0 83 | ;; 84 | --lt-*) 85 | $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 86 | exit 1 87 | ;; 88 | esac 89 | done 90 | 91 | # Print the debug banner immediately: 92 | if test -n "$lt_option_debug"; then 93 | echo "ec_user_example:ec_user_example:${LINENO}: libtool wrapper (GNU libtool) 2.4" 1>&2 94 | fi 95 | } 96 | 97 | # Used when --lt-debug. Prints its arguments to stdout 98 | # (redirection is the responsibility of the caller) 99 | func_lt_dump_args () 100 | { 101 | lt_dump_args_N=1; 102 | for lt_arg 103 | do 104 | $ECHO "ec_user_example:ec_user_example:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" 105 | lt_dump_args_N=`expr $lt_dump_args_N + 1` 106 | done 107 | } 108 | 109 | # Core function for launching the target application 110 | func_exec_program_core () 111 | { 112 | 113 | if test -n "$lt_option_debug"; then 114 | $ECHO "ec_user_example:ec_user_example:${LINENO}: newargv[0]: $progdir/$program" 1>&2 115 | func_lt_dump_args ${1+"$@"} 1>&2 116 | fi 117 | exec "$progdir/$program" ${1+"$@"} 118 | 119 | $ECHO "$0: cannot exec $program $*" 1>&2 120 | exit 1 121 | } 122 | 123 | # A function to encapsulate launching the target application 124 | # Strips options in the --lt-* namespace from $@ and 125 | # launches target application with the remaining arguments. 126 | func_exec_program () 127 | { 128 | for lt_wr_arg 129 | do 130 | case $lt_wr_arg in 131 | --lt-*) ;; 132 | *) set x "$@" "$lt_wr_arg"; shift;; 133 | esac 134 | shift 135 | done 136 | func_exec_program_core ${1+"$@"} 137 | } 138 | 139 | # Parse options 140 | func_parse_lt_options "$0" ${1+"$@"} 141 | 142 | # Find the directory that this script lives in. 143 | thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` 144 | test "x$thisdir" = "x$file" && thisdir=. 145 | 146 | # Follow symbolic links until we get to the real thisdir. 147 | file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` 148 | while test -n "$file"; do 149 | destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` 150 | 151 | # If there was a directory component, then change thisdir. 152 | if test "x$destdir" != "x$file"; then 153 | case "$destdir" in 154 | [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; 155 | *) thisdir="$thisdir/$destdir" ;; 156 | esac 157 | fi 158 | 159 | file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` 160 | file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` 161 | done 162 | 163 | # Usually 'no', except on cygwin/mingw when embedded into 164 | # the cwrapper. 165 | WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no 166 | if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then 167 | # special case for '.' 168 | if test "$thisdir" = "."; then 169 | thisdir=`pwd` 170 | fi 171 | # remove .libs from thisdir 172 | case "$thisdir" in 173 | *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; 174 | .libs ) thisdir=. ;; 175 | esac 176 | fi 177 | 178 | # Try to get the absolute directory name. 179 | absdir=`cd "$thisdir" && pwd` 180 | test -n "$absdir" && thisdir="$absdir" 181 | 182 | program=lt-'ec_user_example' 183 | progdir="$thisdir/.libs" 184 | 185 | if test ! -f "$progdir/$program" || 186 | { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ 187 | test "X$file" != "X$progdir/$program"; }; then 188 | 189 | file="$$-$program" 190 | 191 | if test ! -d "$progdir"; then 192 | mkdir "$progdir" 193 | else 194 | rm -f "$progdir/$file" 195 | fi 196 | 197 | # relink executable if necessary 198 | if test -n "$relink_command"; then 199 | if relink_command_output=`eval $relink_command 2>&1`; then : 200 | else 201 | printf %s\n "$relink_command_output" >&2 202 | rm -f "$progdir/$file" 203 | exit 1 204 | fi 205 | fi 206 | 207 | mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || 208 | { rm -f "$progdir/$program"; 209 | mv -f "$progdir/$file" "$progdir/$program"; } 210 | rm -f "$progdir/$file" 211 | fi 212 | 213 | if test -f "$progdir/$program"; then 214 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then 215 | # Run the actual program with our arguments. 216 | func_exec_program ${1+"$@"} 217 | fi 218 | else 219 | # The program doesn't exist. 220 | $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 221 | $ECHO "This script is just a wrapper for $program." 1>&2 222 | $ECHO "See the libtool documentation for more information." 1>&2 223 | exit 1 224 | fi 225 | fi 226 | -------------------------------------------------------------------------------- /examples/user/main.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /****************************************************************************/ 40 | 41 | #include "ecrt.h" 42 | 43 | /****************************************************************************/ 44 | // Application parameters 45 | #define FREQUENCY 4000 46 | #define CONFIGURE_PDOS 1 47 | 48 | // Optional features 49 | #define PDO_SETTING1 1 50 | #define SDO_ACCESS 1 51 | 52 | static ec_master_t *master = NULL; 53 | static ec_domain_t *domain1 = NULL; 54 | //static ec_domain_t *domain2 = NULL; 55 | /****************************************************************************/ 56 | static ec_slave_config_t *sc = NULL; 57 | static ec_slave_config_t *sc2 = NULL; 58 | static ec_slave_config_t *sc3 = NULL; 59 | /****************************************************************************/ 60 | 61 | // Timer 62 | static unsigned int sig_alarms = 0; 63 | static unsigned int user_alarms = 0; 64 | 65 | /****************************************************************************/ 66 | 67 | // process data 68 | static uint8_t *domain1_pd = NULL; 69 | //static uint8_t *domain2_pd = NULL; 70 | #define yas 0,0 71 | #define yas2 0,1 72 | #define yas3 0,2 73 | #define yaskawa 0x0000066f, 0x525100d1 74 | //signal to turn off servo on state 75 | static unsigned int servooff =0; 76 | 77 | // offsets for PDO entries 78 | static unsigned int ctrl_word, ctrl_word2, ctrl_word3 ; 79 | static unsigned int mode, mode2, mode3 ; 80 | static unsigned int tar_torq, tar_torq2, tar_torq3 ; 81 | static unsigned int max_torq, max_torq2, max_torq3 ; 82 | static unsigned int tar_pos, tar_pos2, tar_pos3 ; 83 | static unsigned int max_speed, max_speed2, max_speed3 ; 84 | static unsigned int touch_probe_func, touch_probe_func2, touch_probe_func3 ; 85 | static unsigned int tar_vel, tar_vel2, tar_vel3 ; 86 | static unsigned int error_code, error_code2, error_code3 ; 87 | static unsigned int status_word, status_word2, status_word3; 88 | static unsigned int mode_display, mode_display2, mode_display3 ; 89 | static unsigned int pos_act, pos_act2, pos_act3; 90 | static unsigned int vel_act, vel_act2, vel_act3; 91 | static unsigned int torq_act, torq_act2, torq_act3; 92 | static unsigned int touch_probe_status, touch_probe_status2, touch_probe_status3; 93 | static unsigned int touch_probe_pos, touch_probe_pos2, touch_probe_pos3; 94 | static unsigned int digital_input, digital_input2, digital_input3; 95 | 96 | static signed long temp[8]={}; 97 | 98 | const static ec_pdo_entry_reg_t domain1_regs[] = { 99 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 100 | {yas, yaskawa,0x6060, 00, &mode }, 101 | {yas, yaskawa,0x6071, 00, &tar_torq }, 102 | {yas, yaskawa,0x6072, 00, &max_torq }, 103 | {yas, yaskawa,0x607a, 00, &tar_pos }, 104 | {yas, yaskawa,0x6080, 00, &max_speed }, 105 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 106 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 107 | {yas, yaskawa,0x603f, 00, &error_code }, 108 | {yas, yaskawa,0x6041, 00, &status_word }, 109 | {yas, yaskawa,0x6061, 00, &mode_display }, 110 | {yas, yaskawa,0x6064, 00, &pos_act }, 111 | {yas, yaskawa,0x606c, 00, &vel_act }, 112 | {yas, yaskawa,0x6077, 00, &torq_act }, 113 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 114 | {yas, yaskawa,0x60ba, 00, &touch_probe_pos }, 115 | {yas, yaskawa,0x60fd, 00, &digital_input }, 116 | {yas2, yaskawa,0x6040, 00, &ctrl_word2 }, 117 | {yas2, yaskawa,0x6060, 00, &mode2 }, 118 | {yas2, yaskawa,0x6071, 00, &tar_torq2 }, 119 | {yas2, yaskawa,0x6072, 00, &max_torq2 }, 120 | {yas2, yaskawa,0x607a, 00, &tar_pos2 }, 121 | {yas2, yaskawa,0x6080, 00, &max_speed2 }, 122 | {yas2, yaskawa,0x60b8, 00, &touch_probe_func2 }, 123 | {yas2, yaskawa,0x60ff, 00, &tar_vel2 }, 124 | {yas2, yaskawa,0x603f, 00, &error_code2 }, 125 | {yas2, yaskawa,0x6041, 00, &status_word2 }, 126 | {yas2, yaskawa,0x6061, 00, &mode_display2 }, 127 | {yas2, yaskawa,0x6064, 00, &pos_act2 }, 128 | {yas2, yaskawa,0x606c, 00, &vel_act2 }, 129 | {yas2, yaskawa,0x6077, 00, &torq_act2 }, 130 | {yas2, yaskawa,0x60b9, 00, &touch_probe_status2 }, 131 | {yas2 ,yaskawa,0x60ba, 00, &touch_probe_pos2 }, 132 | {yas2, yaskawa,0x60fd, 00, &digital_input2 }, 133 | {yas3, yaskawa,0x6040, 00, &ctrl_word3 }, 134 | {yas3, yaskawa,0x6060, 00, &mode3 }, 135 | {yas3, yaskawa,0x6071, 00, &tar_torq3 }, 136 | {yas3, yaskawa,0x6072, 00, &max_torq3 }, 137 | {yas3, yaskawa,0x607a, 00, &tar_pos3 }, 138 | {yas3, yaskawa,0x6080, 00, &max_speed3 }, 139 | {yas3, yaskawa,0x60b8, 00, &touch_probe_func3 }, 140 | {yas3, yaskawa,0x60ff, 00, &tar_vel3 }, 141 | {yas3, yaskawa,0x603f, 00, &error_code3 }, 142 | {yas3, yaskawa,0x6041, 00, &status_word3 }, 143 | {yas3, yaskawa,0x6061, 00, &mode_display3 }, 144 | {yas3, yaskawa,0x6064, 00, &pos_act3 }, 145 | {yas3, yaskawa,0x606c, 00, &vel_act3 }, 146 | {yas3, yaskawa,0x6077, 00, &torq_act3 }, 147 | {yas3, yaskawa,0x60b9, 00, &touch_probe_status3 }, 148 | {yas3, yaskawa,0x60ba, 00, &touch_probe_pos3 }, 149 | {yas3, yaskawa,0x60fd, 00, &digital_input3 }, 150 | {} 151 | }; 152 | 153 | 154 | float value = 0; 155 | static unsigned int counter = 0; 156 | static unsigned int blink = 0; 157 | 158 | #if PDO_SETTING1 159 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 160 | {0x6040, 0x00, 16}, 161 | {0x6060, 0x00, 8 }, 162 | {0x6071, 0x00, 16}, 163 | {0x6072, 0x00, 16}, 164 | {0x607a, 0x00, 32}, 165 | {0x6080, 0x00, 32}, 166 | {0x60b8, 0x00, 16}, 167 | {0x60ff, 0x00, 32}, 168 | {0x603f, 0x00, 16}, 169 | {0x6041, 0x00, 16}, 170 | {0x6061, 0x00, 8 }, 171 | {0x6064, 0x00, 32}, 172 | {0x606c, 0x00, 32}, 173 | {0x6077, 0x00, 16}, 174 | {0x60b9, 0x00, 16}, 175 | {0x60ba, 0x00, 32}, 176 | {0x60fd, 0x00, 32}, 177 | };//{index,subindex,lenth} 178 | 179 | static ec_pdo_info_t slave_0_pdos[] = { 180 | {0x1600, 8, slave_0_pdo_entries + 0}, 181 | {0x1a00, 9, slave_0_pdo_entries + 8}, 182 | }; 183 | 184 | 185 | static ec_sync_info_t slave_0_syncs[] = { 186 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 187 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 188 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 189 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 190 | {0xff} 191 | }; 192 | 193 | static ec_pdo_entry_info_t slave_1_pdo_entries[] = { 194 | {0x6040, 0x00, 16}, 195 | {0x6060, 0x00, 8 }, 196 | {0x6071, 0x00, 16}, 197 | {0x6072, 0x00, 16}, 198 | {0x607a, 0x00, 32}, 199 | {0x6080, 0x00, 32}, 200 | {0x60b8, 0x00, 16}, 201 | {0x60ff, 0x00, 32}, 202 | {0x603f, 0x00, 16}, 203 | {0x6041, 0x00, 16}, 204 | {0x6061, 0x00, 8 }, 205 | {0x6064, 0x00, 32}, 206 | {0x606c, 0x00, 32}, 207 | {0x6077, 0x00, 16}, 208 | {0x60b9, 0x00, 16}, 209 | {0x60ba, 0x00, 32}, 210 | {0x60fd, 0x00, 32}, 211 | };//{index,subindex,lenth} 212 | 213 | static ec_pdo_info_t slave_1_pdos[] = { 214 | {0x1600, 8, slave_1_pdo_entries + 0}, 215 | {0x1a00, 9, slave_1_pdo_entries + 8}, 216 | }; 217 | 218 | 219 | static ec_sync_info_t slave_1_syncs[] = { 220 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 221 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 222 | {2, EC_DIR_OUTPUT, 1, slave_1_pdos + 0, EC_WD_DISABLE}, 223 | {3, EC_DIR_INPUT, 1, slave_1_pdos + 1, EC_WD_DISABLE}, 224 | {0xff} 225 | }; 226 | 227 | static ec_pdo_entry_info_t slave_2_pdo_entries[] = { 228 | {0x6040, 0x00, 16}, 229 | {0x6060, 0x00, 8 }, 230 | {0x6071, 0x00, 16}, 231 | {0x6072, 0x00, 16}, 232 | {0x607a, 0x00, 32}, 233 | {0x6080, 0x00, 32}, 234 | {0x60b8, 0x00, 16}, 235 | {0x60ff, 0x00, 32}, 236 | {0x603f, 0x00, 16}, 237 | {0x6041, 0x00, 16}, 238 | {0x6061, 0x00, 8 }, 239 | {0x6064, 0x00, 32}, 240 | {0x606c, 0x00, 32}, 241 | {0x6077, 0x00, 16}, 242 | {0x60b9, 0x00, 16}, 243 | {0x60ba, 0x00, 32}, 244 | {0x60fd, 0x00, 32}, 245 | };//{index,subindex,lenth} 246 | 247 | 248 | 249 | static ec_pdo_info_t slave_2_pdos[] = { 250 | {0x1600, 8, slave_2_pdo_entries + 0}, 251 | {0x1a00, 9, slave_2_pdo_entries + 8}, 252 | }; 253 | 254 | static ec_sync_info_t slave_2_syncs[] = { 255 | {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, 256 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 257 | {2, EC_DIR_OUTPUT, 1, slave_2_pdos + 0, EC_WD_DISABLE}, 258 | {3, EC_DIR_INPUT, 1, slave_2_pdos + 1, EC_WD_DISABLE}, 259 | {0xff} 260 | }; 261 | 262 | 263 | 264 | #endif 265 | 266 | 267 | 268 | /*****************************************************************************/ 269 | 270 | void cyclic_task() 271 | { 272 | // receive process data 273 | ecrt_master_receive(master); 274 | ecrt_domain_process(domain1); 275 | // ecrt_domain_process(domain2); 276 | 277 | temp[0]=EC_READ_U16(domain1_pd + status_word); 278 | temp[1]=EC_READ_U16(domain1_pd + status_word2); 279 | temp[2]=EC_READ_U16(domain1_pd + status_word3); 280 | // temp[2]=EC_READ_U16(domain2_pd + pos_act); 281 | // temp[3]=EC_READ_U32(domain2_pd + vel_act); 282 | // temp[4]=EC_READ_S32(domain2_pd + torq_act); 283 | // temp[5]=EC_READ_U32(domain2_pd + digital_input); 284 | if (counter) { 285 | counter--; 286 | } else { // do this at 1 Hz 287 | counter = FREQUENCY; 288 | 289 | blink = !blink; 290 | } 291 | printf("after value =%x\n",temp[0]); 292 | // write process data 293 | if(servooff==1){//servo off 294 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 295 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 296 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0006 ); 297 | printf("0 is ok\n"); 298 | } 299 | else if(((temp[0]&0x004f) == 0x0040) && ((temp[1]&0x004f) == 0x0040) && ((temp[2]&0x004f) == 0x0040) ){ 300 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 301 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 302 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0006 ); 303 | printf("%x\n",temp[0]); 304 | printf("1 is ok\n"); 305 | } 306 | else if(((temp[0]&0x006f) == 0x0021) && ((temp[1]&0x006f) == 0x0021) && ((temp[2]&0x006f) == 0x0021)){ 307 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 308 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0007 ); 309 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0007 ); 310 | printf("%x\n",temp[0]); 311 | printf("2 is ok\n"); 312 | } 313 | else if(((temp[0]&0x006f) == 0x0023) && ((temp[1]&0x006f) == 0x0023) && ((temp[2]&0x006f) == 0x0023)){ 314 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f ); 315 | EC_WRITE_S32(domain1_pd+tar_pos,0); 316 | EC_WRITE_S32(domain1_pd+tar_vel, 0xffff); 317 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 318 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x000f ); 319 | EC_WRITE_S32(domain1_pd+tar_pos2,0); 320 | EC_WRITE_S32(domain1_pd+tar_vel2, 0xffff); 321 | EC_WRITE_S32(domain1_pd+max_torq2, 0xf00); 322 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x000f ); 323 | EC_WRITE_S32(domain1_pd+tar_pos3,0); 324 | EC_WRITE_S32(domain1_pd+tar_vel3, 0xffff); 325 | EC_WRITE_S32(domain1_pd+max_torq3, 0xf00); 326 | 327 | printf("%x\n",temp[0]); 328 | printf("3 is ok\n"); 329 | } 330 | else if(((temp[0]&0x006f) == 0x0027) && ((temp[1]&0x006f) == 0x0027) && ((temp[2]&0x006f) == 0x0027)){ 331 | EC_WRITE_S32(domain1_pd+tar_pos, (value+=1) ); 332 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 333 | EC_WRITE_S32(domain1_pd+tar_pos2, (value) ); 334 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x001f); 335 | EC_WRITE_S32(domain1_pd+tar_pos3, (value) ); 336 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x001f); 337 | 338 | // int q =0; 339 | // for (q =0; q<6; q++) 340 | // printf("q = %x\n",temp[q]); 341 | printf("4 is ok\n"); 342 | } 343 | 344 | 345 | // send process data 346 | ecrt_domain_queue(domain1); 347 | // ecrt_domain_queue(domain2); 348 | ecrt_master_send(master); 349 | } 350 | 351 | /****************************************************************************/ 352 | 353 | void signal_handler(int signum) { 354 | switch (signum) { 355 | case SIGALRM: 356 | sig_alarms++; 357 | break; 358 | } 359 | } 360 | 361 | /****************************************************************************/ 362 | 363 | int main(int argc, char **argv) 364 | { 365 | struct sigaction sa; 366 | struct itimerval tv; 367 | 368 | master = ecrt_request_master(0); 369 | if (!master) 370 | return -1; 371 | 372 | domain1 = ecrt_master_create_domain(master); 373 | if (!domain1) 374 | return -1; 375 | 376 | // domain2 = ecrt_master_create_domain(master); 377 | // if (!domain2) 378 | // return -1; 379 | 380 | if (!(sc = ecrt_master_slave_config( 381 | master, yas, yaskawa))) { 382 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 383 | return -1; 384 | } 385 | 386 | if (!(sc2 = ecrt_master_slave_config( 387 | master, yas2, yaskawa))) { 388 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 389 | return -1; 390 | } 391 | 392 | if (!(sc3 = ecrt_master_slave_config( 393 | master, yas3, yaskawa))) { 394 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 395 | return -1; 396 | } 397 | 398 | 399 | #if SDO_ACCESS 400 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 401 | return -1; 402 | } 403 | if (ecrt_slave_config_sdo8(sc2, 0x6060, 0, 8)){ 404 | return -1; 405 | } 406 | if (ecrt_slave_config_sdo8(sc3, 0x6060, 0, 8)){ 407 | return -1; 408 | } 409 | 410 | #endif 411 | 412 | 413 | #if CONFIGURE_PDOS 414 | printf("Configuring PDOs...\n"); 415 | 416 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 417 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 418 | return -1; 419 | } 420 | 421 | if (ecrt_slave_config_pdos(sc2, EC_END, slave_1_syncs)) { 422 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 423 | return -1; 424 | } 425 | 426 | if (ecrt_slave_config_pdos(sc3, EC_END, slave_2_syncs)) { 427 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 428 | return -1; 429 | } 430 | 431 | #endif 432 | 433 | 434 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 435 | fprintf(stderr, "PDO entry registration failed!\n"); 436 | return -1; 437 | } 438 | // if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 439 | // fprintf(stderr, "PDO entry registration failed!\n"); 440 | // return -1; 441 | // } 442 | 443 | 444 | printf("Activating master...\n"); 445 | if (ecrt_master_activate(master)) 446 | return -1; 447 | 448 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 449 | return -1; 450 | } 451 | // if (!(domain2_pd = ecrt_domain_data(domain2))) { 452 | // return -1; 453 | // } 454 | 455 | 456 | 457 | pid_t pid = getpid(); 458 | if (setpriority(PRIO_PROCESS, pid, -19)) 459 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 460 | strerror(errno)); 461 | 462 | sa.sa_handler = signal_handler; 463 | sigemptyset(&sa.sa_mask); 464 | sa.sa_flags = 0; 465 | if (sigaction(SIGALRM, &sa, 0)) { 466 | fprintf(stderr, "Failed to install signal handler!\n"); 467 | return -1; 468 | } 469 | 470 | printf("Starting timer...\n"); 471 | tv.it_interval.tv_sec = 0; 472 | tv.it_interval.tv_usec = 1000000 / FREQUENCY; 473 | tv.it_value.tv_sec = 0; 474 | tv.it_value.tv_usec = 1000; 475 | if (setitimer(ITIMER_REAL, &tv, NULL)) { 476 | fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); 477 | return 1; 478 | } 479 | 480 | printf("Started.\n"); 481 | while (1) { 482 | pause(); 483 | 484 | while (sig_alarms != user_alarms) { 485 | cyclic_task(); 486 | user_alarms++; 487 | } 488 | } 489 | 490 | return 0; 491 | } 492 | 493 | /****************************************************************************/ 494 | -------------------------------------------------------------------------------- /examples/user/main_pano.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /****************************************************************************/ 40 | 41 | #include "ecrt.h" 42 | 43 | /****************************************************************************/ 44 | // Application parameters 45 | #define FREQUENCY 1000 46 | #define CONFIGURE_PDOS 1 47 | 48 | // Optional features 49 | #define PDO_SETTING1 1 50 | #define SDO_ACCESS 1 51 | 52 | static ec_master_t *master = NULL; 53 | static ec_domain_t *domain1 = NULL; 54 | /****************************************************************************/ 55 | static ec_slave_config_t *sc = NULL; 56 | /****************************************************************************/ 57 | 58 | // Timer 59 | static unsigned int sig_alarms = 0; 60 | static unsigned int user_alarms = 0; 61 | 62 | /****************************************************************************/ 63 | 64 | // process data 65 | static uint8_t *domain1_pd = NULL; 66 | #define yas 0,0 67 | #define yaskawa 0x0000066f, 0x525100d1 68 | //signal to turn off servo on state 69 | static unsigned int servooff =0; 70 | 71 | // offsets for PDO entries 72 | static unsigned int ctrl_word ; 73 | static unsigned int mode ; 74 | static unsigned int tar_torq ; 75 | static unsigned int max_torq ; 76 | static unsigned int tar_pos ; 77 | static unsigned int max_speed ; 78 | static unsigned int touch_probe_func ; 79 | static unsigned int tar_vel ; 80 | static unsigned int error_code ; 81 | static unsigned int status_word; 82 | static unsigned int mode_display ; 83 | static unsigned int pos_act; 84 | static unsigned int vel_act; 85 | static unsigned int torq_act; 86 | static unsigned int touch_probe_status; 87 | static unsigned int touch_probe_pos; 88 | static unsigned int digital_input; 89 | 90 | static signed long temp[8]={}; 91 | 92 | const static ec_pdo_entry_reg_t domain1_regs[] = { 93 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 94 | {yas, yaskawa,0x6060, 00, &mode }, 95 | {yas, yaskawa,0x6071, 00, &tar_torq }, 96 | {yas, yaskawa,0x6072, 00, &max_torq }, 97 | {yas, yaskawa,0x607a, 00, &tar_pos }, 98 | {yas, yaskawa,0x6080, 00, &max_speed }, 99 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 100 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 101 | {yas, yaskawa,0x603f, 00, &error_code }, 102 | {yas, yaskawa,0x6041, 00, &status_word }, 103 | {yas, yaskawa,0x6061, 00, &mode_display }, 104 | {yas, yaskawa,0x6064, 00, &pos_act }, 105 | {yas, yaskawa,0x606c, 00, &vel_act }, 106 | {yas, yaskawa,0x6077, 00, &torq_act }, 107 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 108 | {yas ,yaskawa,0x60ba, 00, &touch_probe_pos }, 109 | {yas, yaskawa,0x60fd, 00, &digital_input }, 110 | {} 111 | }; 112 | 113 | 114 | float value = 0; 115 | static unsigned int counter = 0; 116 | static unsigned int blink = 0; 117 | 118 | #if PDO_SETTING1 119 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 120 | {0x6040, 0x00, 16}, 121 | {0x6060, 0x00, 8 }, 122 | {0x6071, 0x00, 16}, 123 | {0x6072, 0x00, 16}, 124 | {0x607a, 0x00, 32}, 125 | {0x6080, 0x00, 32}, 126 | {0x60b8, 0x00, 16}, 127 | {0x60ff, 0x00, 32}, 128 | {0x603f, 0x00, 16}, 129 | {0x6041, 0x00, 16}, 130 | {0x6061, 0x00, 8 }, 131 | {0x6064, 0x00, 32}, 132 | {0x606c, 0x00, 32}, 133 | {0x6077, 0x00, 16}, 134 | {0x60b9, 0x00, 16}, 135 | {0x60ba, 0x00, 32}, 136 | {0x60fd, 0x00, 32}, 137 | };//{index,subindex,lenth} 138 | 139 | static ec_pdo_info_t slave_0_pdos[] = { 140 | {0x1600, 8, slave_0_pdo_entries + 0}, 141 | {0x1a00, 9, slave_0_pdo_entries + 8}, 142 | }; 143 | 144 | 145 | static ec_sync_info_t slave_0_syncs[] = { 146 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 147 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 148 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 149 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 150 | {0xff} 151 | }; 152 | 153 | #endif 154 | 155 | 156 | 157 | /*****************************************************************************/ 158 | 159 | void cyclic_task() 160 | { 161 | // receive process data 162 | ecrt_master_receive(master); 163 | ecrt_domain_process(domain1); 164 | 165 | temp[0]=EC_READ_U16(domain1_pd + status_word); 166 | temp[1]=EC_READ_S32(domain1_pd + mode_display); 167 | // temp[2]=EC_READ_U16(domain2_pd + pos_act); 168 | // temp[3]=EC_READ_U32(domain2_pd + vel_act); 169 | // temp[4]=EC_READ_S32(domain2_pd + torq_act); 170 | // temp[5]=EC_READ_U32(domain2_pd + digital_input); 171 | if (counter) { 172 | counter--; 173 | } else { // do this at 1 Hz 174 | counter = FREQUENCY; 175 | 176 | blink = !blink; 177 | } 178 | printf("after value =%x\n",temp[0]); 179 | // write process data 180 | if(servooff==1){//servo off 181 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 182 | printf("0 is ok\n"); 183 | } 184 | else if( (temp[0]&0x004f) == 0x0040 ){ 185 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 186 | printf("%x\n",temp[0]); 187 | printf("1 is ok\n"); 188 | } 189 | else if( (temp[0]&0x006f) == 0x0021){ 190 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 191 | printf("%x\n",temp[0]); 192 | printf("2 is ok\n"); 193 | } 194 | else if( (temp[0]&0x006f) == 0x0023){ 195 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f ); 196 | EC_WRITE_S32(domain1_pd+tar_pos,0); 197 | EC_WRITE_S32(domain1_pd+tar_vel, 0xffff); 198 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 199 | printf("%x\n",temp[0]); 200 | printf("3 is ok\n"); 201 | } 202 | else if( (temp[0]&0x006f) == 0x0027){ 203 | EC_WRITE_S32(domain1_pd+tar_pos, (value+=1) ); 204 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 205 | // int q =0; 206 | // for (q =0; q<6; q++) 207 | // printf("q = %x\n",temp[q]); 208 | printf("4 is ok\n"); 209 | } 210 | 211 | 212 | // send process data 213 | ecrt_domain_queue(domain1); 214 | ecrt_master_send(master); 215 | } 216 | 217 | /****************************************************************************/ 218 | 219 | void signal_handler(int signum) { 220 | switch (signum) { 221 | case SIGALRM: 222 | sig_alarms++; 223 | break; 224 | } 225 | } 226 | 227 | /****************************************************************************/ 228 | 229 | int main(int argc, char **argv) 230 | { 231 | struct sigaction sa; 232 | struct itimerval tv; 233 | 234 | master = ecrt_request_master(0); 235 | if (!master) 236 | return -1; 237 | 238 | domain1 = ecrt_master_create_domain(master); 239 | if (!domain1) 240 | return -1; 241 | 242 | 243 | if (!(sc = ecrt_master_slave_config( 244 | master, yas, yaskawa))) { 245 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 246 | return -1; 247 | } 248 | 249 | #if SDO_ACCESS 250 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 251 | return -1; 252 | } 253 | #endif 254 | 255 | 256 | #if CONFIGURE_PDOS 257 | printf("Configuring PDOs...\n"); 258 | 259 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 260 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 261 | return -1; 262 | } 263 | 264 | #endif 265 | 266 | 267 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 268 | fprintf(stderr, "PDO entry registration failed!\n"); 269 | return -1; 270 | } 271 | 272 | printf("Activating master...\n"); 273 | if (ecrt_master_activate(master)) 274 | return -1; 275 | 276 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 277 | return -1; 278 | } 279 | 280 | 281 | pid_t pid = getpid(); 282 | if (setpriority(PRIO_PROCESS, pid, -19)) 283 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 284 | strerror(errno)); 285 | 286 | sa.sa_handler = signal_handler; 287 | sigemptyset(&sa.sa_mask); 288 | sa.sa_flags = 0; 289 | if (sigaction(SIGALRM, &sa, 0)) { 290 | fprintf(stderr, "Failed to install signal handler!\n"); 291 | return -1; 292 | } 293 | 294 | printf("Starting timer...\n"); 295 | tv.it_interval.tv_sec = 0; 296 | tv.it_interval.tv_usec = 1000000 / FREQUENCY; 297 | tv.it_value.tv_sec = 0; 298 | tv.it_value.tv_usec = 1000; 299 | if (setitimer(ITIMER_REAL, &tv, NULL)) { 300 | fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); 301 | return 1; 302 | } 303 | 304 | printf("Started.\n"); 305 | while (1) { 306 | pause(); 307 | 308 | while (sig_alarms != user_alarms) { 309 | cyclic_task(); 310 | user_alarms++; 311 | } 312 | } 313 | 314 | return 0; 315 | } 316 | 317 | /****************************************************************************/ 318 | -------------------------------------------------------------------------------- /examples/user/main_pano2.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /****************************************************************************/ 40 | 41 | #include "ecrt.h" 42 | 43 | /****************************************************************************/ 44 | // Application parameters 45 | #define FREQUENCY 100 46 | #define CONFIGURE_PDOS 1 47 | 48 | // Optional features 49 | #define PDO_SETTING1 1 50 | #define SDO_ACCESS 1 51 | 52 | static ec_master_t *master = NULL; 53 | static ec_domain_t *domain1 = NULL; 54 | //static ec_domain_t *domain2 = NULL; 55 | /****************************************************************************/ 56 | static ec_slave_config_t *sc = NULL; 57 | static ec_slave_config_t *sc2 = NULL; 58 | /****************************************************************************/ 59 | 60 | // Timer 61 | static unsigned int sig_alarms = 0; 62 | static unsigned int user_alarms = 0; 63 | 64 | /****************************************************************************/ 65 | 66 | // process data 67 | static uint8_t *domain1_pd = NULL; 68 | //static uint8_t *domain2_pd = NULL; 69 | #define yas 0,0 70 | #define yas2 0,1 71 | #define yaskawa 0x0000066f, 0x525100d1 72 | //signal to turn off servo on state 73 | static unsigned int servooff =0; 74 | 75 | // offsets for PDO entries 76 | static unsigned int ctrl_word, ctrl_word2 ; 77 | static unsigned int mode, mode2 ; 78 | static unsigned int tar_torq, tar_torq2 ; 79 | static unsigned int max_torq, max_torq2 ; 80 | static unsigned int tar_pos, tar_pos2 ; 81 | static unsigned int max_speed, max_speed2 ; 82 | static unsigned int touch_probe_func, touch_probe_func2 ; 83 | static unsigned int tar_vel, tar_vel2 ; 84 | static unsigned int error_code, error_code2 ; 85 | static unsigned int status_word, status_word2; 86 | static unsigned int mode_display, mode_display2 ; 87 | static unsigned int pos_act, pos_act2; 88 | static unsigned int vel_act, vel_act2; 89 | static unsigned int torq_act, torq_act2; 90 | static unsigned int touch_probe_status, touch_probe_status2; 91 | static unsigned int touch_probe_pos, touch_probe_pos2; 92 | static unsigned int digital_input, digital_input2; 93 | 94 | static signed long temp[8]={}; 95 | 96 | const static ec_pdo_entry_reg_t domain1_regs[] = { 97 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 98 | {yas, yaskawa,0x6060, 00, &mode }, 99 | {yas, yaskawa,0x6071, 00, &tar_torq }, 100 | {yas, yaskawa,0x6072, 00, &max_torq }, 101 | {yas, yaskawa,0x607a, 00, &tar_pos }, 102 | {yas, yaskawa,0x6080, 00, &max_speed }, 103 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 104 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 105 | {yas, yaskawa,0x603f, 00, &error_code }, 106 | {yas, yaskawa,0x6041, 00, &status_word }, 107 | {yas, yaskawa,0x6061, 00, &mode_display }, 108 | {yas, yaskawa,0x6064, 00, &pos_act }, 109 | {yas, yaskawa,0x606c, 00, &vel_act }, 110 | {yas, yaskawa,0x6077, 00, &torq_act }, 111 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 112 | {yas, yaskawa,0x60ba, 00, &touch_probe_pos }, 113 | {yas, yaskawa,0x60fd, 00, &digital_input }, 114 | {yas2, yaskawa,0x6040, 00, &ctrl_word2 }, 115 | {yas2, yaskawa,0x6060, 00, &mode2 }, 116 | {yas2, yaskawa,0x6071, 00, &tar_torq2 }, 117 | {yas2, yaskawa,0x6072, 00, &max_torq2 }, 118 | {yas2, yaskawa,0x607a, 00, &tar_pos2 }, 119 | {yas2, yaskawa,0x6080, 00, &max_speed2 }, 120 | {yas2, yaskawa,0x60b8, 00, &touch_probe_func2 }, 121 | {yas2, yaskawa,0x60ff, 00, &tar_vel2 }, 122 | {yas2, yaskawa,0x603f, 00, &error_code2 }, 123 | {yas2, yaskawa,0x6041, 00, &status_word2 }, 124 | {yas2, yaskawa,0x6061, 00, &mode_display2 }, 125 | {yas2, yaskawa,0x6064, 00, &pos_act2 }, 126 | {yas2, yaskawa,0x606c, 00, &vel_act2 }, 127 | {yas2, yaskawa,0x6077, 00, &torq_act2 }, 128 | {yas2, yaskawa,0x60b9, 00, &touch_probe_status2 }, 129 | {yas2 ,yaskawa,0x60ba, 00, &touch_probe_pos2 }, 130 | {yas2, yaskawa,0x60fd, 00, &digital_input2 }, 131 | {} 132 | }; 133 | 134 | 135 | float value = 0; 136 | static unsigned int counter = 0; 137 | static unsigned int blink = 0; 138 | 139 | #if PDO_SETTING1 140 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 141 | {0x6040, 0x00, 16}, 142 | {0x6060, 0x00, 8 }, 143 | {0x6071, 0x00, 16}, 144 | {0x6072, 0x00, 16}, 145 | {0x607a, 0x00, 32}, 146 | {0x6080, 0x00, 32}, 147 | {0x60b8, 0x00, 16}, 148 | {0x60ff, 0x00, 32}, 149 | {0x603f, 0x00, 16}, 150 | {0x6041, 0x00, 16}, 151 | {0x6061, 0x00, 8 }, 152 | {0x6064, 0x00, 32}, 153 | {0x606c, 0x00, 32}, 154 | {0x6077, 0x00, 16}, 155 | {0x60b9, 0x00, 16}, 156 | {0x60ba, 0x00, 32}, 157 | {0x60fd, 0x00, 32}, 158 | };//{index,subindex,lenth} 159 | 160 | static ec_pdo_info_t slave_0_pdos[] = { 161 | {0x1600, 8, slave_0_pdo_entries + 0}, 162 | {0x1a00, 9, slave_0_pdo_entries + 8}, 163 | }; 164 | 165 | 166 | static ec_sync_info_t slave_0_syncs[] = { 167 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 168 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 169 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 170 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 171 | {0xff} 172 | }; 173 | 174 | static ec_pdo_entry_info_t slave_1_pdo_entries[] = { 175 | {0x6040, 0x00, 16}, 176 | {0x6060, 0x00, 8 }, 177 | {0x6071, 0x00, 16}, 178 | {0x6072, 0x00, 16}, 179 | {0x607a, 0x00, 32}, 180 | {0x6080, 0x00, 32}, 181 | {0x60b8, 0x00, 16}, 182 | {0x60ff, 0x00, 32}, 183 | {0x603f, 0x00, 16}, 184 | {0x6041, 0x00, 16}, 185 | {0x6061, 0x00, 8 }, 186 | {0x6064, 0x00, 32}, 187 | {0x606c, 0x00, 32}, 188 | {0x6077, 0x00, 16}, 189 | {0x60b9, 0x00, 16}, 190 | {0x60ba, 0x00, 32}, 191 | {0x60fd, 0x00, 32}, 192 | };//{index,subindex,lenth} 193 | 194 | static ec_pdo_info_t slave_1_pdos[] = { 195 | {0x1600, 8, slave_1_pdo_entries + 0}, 196 | {0x1a00, 9, slave_1_pdo_entries + 8}, 197 | }; 198 | 199 | 200 | static ec_sync_info_t slave_1_syncs[] = { 201 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 202 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 203 | {2, EC_DIR_OUTPUT, 1, slave_1_pdos + 0, EC_WD_DISABLE}, 204 | {3, EC_DIR_INPUT, 1, slave_1_pdos + 1, EC_WD_DISABLE}, 205 | {0xff} 206 | }; 207 | 208 | 209 | #endif 210 | 211 | 212 | 213 | /*****************************************************************************/ 214 | 215 | void cyclic_task() 216 | { 217 | // receive process data 218 | ecrt_master_receive(master); 219 | ecrt_domain_process(domain1); 220 | // ecrt_domain_process(domain2); 221 | 222 | temp[0]=EC_READ_U16(domain1_pd + status_word); 223 | temp[1]=EC_READ_U16(domain1_pd + status_word2); 224 | // temp[2]=EC_READ_U16(domain2_pd + pos_act); 225 | // temp[3]=EC_READ_U32(domain2_pd + vel_act); 226 | // temp[4]=EC_READ_S32(domain2_pd + torq_act); 227 | // temp[5]=EC_READ_U32(domain2_pd + digital_input); 228 | if (counter) { 229 | counter--; 230 | } else { // do this at 1 Hz 231 | counter = FREQUENCY; 232 | 233 | blink = !blink; 234 | } 235 | printf("after value =%x\n",temp[0]); 236 | // write process data 237 | if(servooff==1){//servo off 238 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 239 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 240 | printf("0 is ok\n"); 241 | } 242 | else if(((temp[0]&0x004f) == 0x0040) && ((temp[1]&0x004f) == 0x0040)){ 243 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 244 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 245 | printf("%x\n",temp[0]); 246 | printf("1 is ok\n"); 247 | } 248 | else if(((temp[0]&0x006f) == 0x0021) && ((temp[1]&0x006f) == 0x0021)){ 249 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 250 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0007 ); 251 | printf("%x\n",temp[0]); 252 | printf("2 is ok\n"); 253 | } 254 | else if(((temp[0]&0x006f) == 0x0023) && ((temp[1]&0x006f) == 0x0023)){ 255 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f ); 256 | EC_WRITE_S32(domain1_pd+tar_pos,0); 257 | EC_WRITE_S32(domain1_pd+tar_vel, 0xffff); 258 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 259 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x000f ); 260 | EC_WRITE_S32(domain1_pd+tar_pos2,0); 261 | EC_WRITE_S32(domain1_pd+tar_vel2, 0xffff); 262 | EC_WRITE_S32(domain1_pd+max_torq2, 0xf00); 263 | printf("%x\n",temp[0]); 264 | printf("3 is ok\n"); 265 | } 266 | else if(((temp[0]&0x006f) == 0x0027) && ((temp[1]&0x006f) == 0x0027)){ 267 | EC_WRITE_S32(domain1_pd+tar_pos, (value+=1) ); 268 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 269 | EC_WRITE_S32(domain1_pd+tar_pos2, (value+=1) ); 270 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x001f); 271 | // int q =0; 272 | // for (q =0; q<6; q++) 273 | // printf("q = %x\n",temp[q]); 274 | printf("4 is ok\n"); 275 | } 276 | 277 | 278 | // send process data 279 | ecrt_domain_queue(domain1); 280 | // ecrt_domain_queue(domain2); 281 | ecrt_master_send(master); 282 | } 283 | 284 | /****************************************************************************/ 285 | 286 | void signal_handler(int signum) { 287 | switch (signum) { 288 | case SIGALRM: 289 | sig_alarms++; 290 | break; 291 | } 292 | } 293 | 294 | /****************************************************************************/ 295 | 296 | int main(int argc, char **argv) 297 | { 298 | struct sigaction sa; 299 | struct itimerval tv; 300 | 301 | master = ecrt_request_master(0); 302 | if (!master) 303 | return -1; 304 | 305 | domain1 = ecrt_master_create_domain(master); 306 | if (!domain1) 307 | return -1; 308 | 309 | // domain2 = ecrt_master_create_domain(master); 310 | // if (!domain2) 311 | // return -1; 312 | 313 | if (!(sc = ecrt_master_slave_config( 314 | master, yas, yaskawa))) { 315 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 316 | return -1; 317 | } 318 | 319 | if (!(sc2 = ecrt_master_slave_config( 320 | master, yas2, yaskawa))) { 321 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 322 | return -1; 323 | } 324 | 325 | 326 | #if SDO_ACCESS 327 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 328 | return -1; 329 | } 330 | if (ecrt_slave_config_sdo8(sc2, 0x6060, 0, 8)){ 331 | return -1; 332 | } 333 | 334 | #endif 335 | 336 | 337 | #if CONFIGURE_PDOS 338 | printf("Configuring PDOs...\n"); 339 | 340 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 341 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 342 | return -1; 343 | } 344 | 345 | if (ecrt_slave_config_pdos(sc2, EC_END, slave_1_syncs)) { 346 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 347 | return -1; 348 | } 349 | 350 | #endif 351 | 352 | 353 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 354 | fprintf(stderr, "PDO entry registration failed!\n"); 355 | return -1; 356 | } 357 | // if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 358 | // fprintf(stderr, "PDO entry registration failed!\n"); 359 | // return -1; 360 | // } 361 | 362 | 363 | printf("Activating master...\n"); 364 | if (ecrt_master_activate(master)) 365 | return -1; 366 | 367 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 368 | return -1; 369 | } 370 | // if (!(domain2_pd = ecrt_domain_data(domain2))) { 371 | // return -1; 372 | // } 373 | 374 | 375 | 376 | pid_t pid = getpid(); 377 | if (setpriority(PRIO_PROCESS, pid, -19)) 378 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 379 | strerror(errno)); 380 | 381 | sa.sa_handler = signal_handler; 382 | sigemptyset(&sa.sa_mask); 383 | sa.sa_flags = 0; 384 | if (sigaction(SIGALRM, &sa, 0)) { 385 | fprintf(stderr, "Failed to install signal handler!\n"); 386 | return -1; 387 | } 388 | 389 | printf("Starting timer...\n"); 390 | tv.it_interval.tv_sec = 0; 391 | tv.it_interval.tv_usec = 1000000 / FREQUENCY; 392 | tv.it_value.tv_sec = 0; 393 | tv.it_value.tv_usec = 1000; 394 | if (setitimer(ITIMER_REAL, &tv, NULL)) { 395 | fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); 396 | return 1; 397 | } 398 | 399 | printf("Started.\n"); 400 | while (1) { 401 | pause(); 402 | 403 | while (sig_alarms != user_alarms) { 404 | cyclic_task(); 405 | user_alarms++; 406 | } 407 | } 408 | 409 | return 0; 410 | } 411 | 412 | /****************************************************************************/ 413 | -------------------------------------------------------------------------------- /examples/user/main_pano3.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /****************************************************************************/ 40 | 41 | #include "ecrt.h" 42 | 43 | /****************************************************************************/ 44 | // Application parameters 45 | #define FREQUENCY 100 46 | #define CONFIGURE_PDOS 1 47 | 48 | // Optional features 49 | #define PDO_SETTING1 1 50 | #define SDO_ACCESS 1 51 | 52 | static ec_master_t *master = NULL; 53 | static ec_domain_t *domain1 = NULL; 54 | //static ec_domain_t *domain2 = NULL; 55 | /****************************************************************************/ 56 | static ec_slave_config_t *sc = NULL; 57 | static ec_slave_config_t *sc2 = NULL; 58 | static ec_slave_config_t *sc3 = NULL; 59 | /****************************************************************************/ 60 | 61 | // Timer 62 | static unsigned int sig_alarms = 0; 63 | static unsigned int user_alarms = 0; 64 | 65 | /****************************************************************************/ 66 | 67 | // process data 68 | static uint8_t *domain1_pd = NULL; 69 | //static uint8_t *domain2_pd = NULL; 70 | #define yas 0,0 71 | #define yas2 0,1 72 | #define yas3 0,2 73 | #define yaskawa 0x0000066f, 0x525100d1 74 | //signal to turn off servo on state 75 | static unsigned int servooff =0; 76 | 77 | // offsets for PDO entries 78 | static unsigned int ctrl_word, ctrl_word2, ctrl_word3 ; 79 | static unsigned int mode, mode2, mode3 ; 80 | static unsigned int tar_torq, tar_torq2, tar_torq3 ; 81 | static unsigned int max_torq, max_torq2, max_torq3 ; 82 | static unsigned int tar_pos, tar_pos2, tar_pos3 ; 83 | static unsigned int max_speed, max_speed2, max_speed3 ; 84 | static unsigned int touch_probe_func, touch_probe_func2, touch_probe_func3 ; 85 | static unsigned int tar_vel, tar_vel2, tar_vel3 ; 86 | static unsigned int error_code, error_code2, error_code3 ; 87 | static unsigned int status_word, status_word2, status_word3; 88 | static unsigned int mode_display, mode_display2, mode_display3 ; 89 | static unsigned int pos_act, pos_act2, pos_act3; 90 | static unsigned int vel_act, vel_act2, vel_act3; 91 | static unsigned int torq_act, torq_act2, torq_act3; 92 | static unsigned int touch_probe_status, touch_probe_status2, touch_probe_status3; 93 | static unsigned int touch_probe_pos, touch_probe_pos2, touch_probe_pos3; 94 | static unsigned int digital_input, digital_input2, digital_input3; 95 | 96 | static signed long temp[8]={}; 97 | 98 | const static ec_pdo_entry_reg_t domain1_regs[] = { 99 | {yas, yaskawa,0x6040, 00, &ctrl_word }, 100 | {yas, yaskawa,0x6060, 00, &mode }, 101 | {yas, yaskawa,0x6071, 00, &tar_torq }, 102 | {yas, yaskawa,0x6072, 00, &max_torq }, 103 | {yas, yaskawa,0x607a, 00, &tar_pos }, 104 | {yas, yaskawa,0x6080, 00, &max_speed }, 105 | {yas, yaskawa,0x60b8, 00, &touch_probe_func }, 106 | {yas, yaskawa,0x60ff, 00, &tar_vel }, 107 | {yas, yaskawa,0x603f, 00, &error_code }, 108 | {yas, yaskawa,0x6041, 00, &status_word }, 109 | {yas, yaskawa,0x6061, 00, &mode_display }, 110 | {yas, yaskawa,0x6064, 00, &pos_act }, 111 | {yas, yaskawa,0x606c, 00, &vel_act }, 112 | {yas, yaskawa,0x6077, 00, &torq_act }, 113 | {yas, yaskawa,0x60b9, 00, &touch_probe_status }, 114 | {yas, yaskawa,0x60ba, 00, &touch_probe_pos }, 115 | {yas, yaskawa,0x60fd, 00, &digital_input }, 116 | {yas2, yaskawa,0x6040, 00, &ctrl_word2 }, 117 | {yas2, yaskawa,0x6060, 00, &mode2 }, 118 | {yas2, yaskawa,0x6071, 00, &tar_torq2 }, 119 | {yas2, yaskawa,0x6072, 00, &max_torq2 }, 120 | {yas2, yaskawa,0x607a, 00, &tar_pos2 }, 121 | {yas2, yaskawa,0x6080, 00, &max_speed2 }, 122 | {yas2, yaskawa,0x60b8, 00, &touch_probe_func2 }, 123 | {yas2, yaskawa,0x60ff, 00, &tar_vel2 }, 124 | {yas2, yaskawa,0x603f, 00, &error_code2 }, 125 | {yas2, yaskawa,0x6041, 00, &status_word2 }, 126 | {yas2, yaskawa,0x6061, 00, &mode_display2 }, 127 | {yas2, yaskawa,0x6064, 00, &pos_act2 }, 128 | {yas2, yaskawa,0x606c, 00, &vel_act2 }, 129 | {yas2, yaskawa,0x6077, 00, &torq_act2 }, 130 | {yas2, yaskawa,0x60b9, 00, &touch_probe_status2 }, 131 | {yas2 ,yaskawa,0x60ba, 00, &touch_probe_pos2 }, 132 | {yas2, yaskawa,0x60fd, 00, &digital_input2 }, 133 | {yas3, yaskawa,0x6040, 00, &ctrl_word3 }, 134 | {yas3, yaskawa,0x6060, 00, &mode3 }, 135 | {yas3, yaskawa,0x6071, 00, &tar_torq3 }, 136 | {yas3, yaskawa,0x6072, 00, &max_torq3 }, 137 | {yas3, yaskawa,0x607a, 00, &tar_pos3 }, 138 | {yas3, yaskawa,0x6080, 00, &max_speed3 }, 139 | {yas3, yaskawa,0x60b8, 00, &touch_probe_func3 }, 140 | {yas3, yaskawa,0x60ff, 00, &tar_vel3 }, 141 | {yas3, yaskawa,0x603f, 00, &error_code3 }, 142 | {yas3, yaskawa,0x6041, 00, &status_word3 }, 143 | {yas3, yaskawa,0x6061, 00, &mode_display3 }, 144 | {yas3, yaskawa,0x6064, 00, &pos_act3 }, 145 | {yas3, yaskawa,0x606c, 00, &vel_act3 }, 146 | {yas3, yaskawa,0x6077, 00, &torq_act3 }, 147 | {yas3, yaskawa,0x60b9, 00, &touch_probe_status3 }, 148 | {yas3, yaskawa,0x60ba, 00, &touch_probe_pos3 }, 149 | {yas3, yaskawa,0x60fd, 00, &digital_input3 }, 150 | {} 151 | }; 152 | 153 | 154 | float value = 0; 155 | static unsigned int counter = 0; 156 | static unsigned int blink = 0; 157 | 158 | #if PDO_SETTING1 159 | static ec_pdo_entry_info_t slave_0_pdo_entries[] = { 160 | {0x6040, 0x00, 16}, 161 | {0x6060, 0x00, 8 }, 162 | {0x6071, 0x00, 16}, 163 | {0x6072, 0x00, 16}, 164 | {0x607a, 0x00, 32}, 165 | {0x6080, 0x00, 32}, 166 | {0x60b8, 0x00, 16}, 167 | {0x60ff, 0x00, 32}, 168 | {0x603f, 0x00, 16}, 169 | {0x6041, 0x00, 16}, 170 | {0x6061, 0x00, 8 }, 171 | {0x6064, 0x00, 32}, 172 | {0x606c, 0x00, 32}, 173 | {0x6077, 0x00, 16}, 174 | {0x60b9, 0x00, 16}, 175 | {0x60ba, 0x00, 32}, 176 | {0x60fd, 0x00, 32}, 177 | };//{index,subindex,lenth} 178 | 179 | static ec_pdo_info_t slave_0_pdos[] = { 180 | {0x1600, 8, slave_0_pdo_entries + 0}, 181 | {0x1a00, 9, slave_0_pdo_entries + 8}, 182 | }; 183 | 184 | 185 | static ec_sync_info_t slave_0_syncs[] = { 186 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 187 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 188 | {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE}, 189 | {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE}, 190 | {0xff} 191 | }; 192 | 193 | static ec_pdo_entry_info_t slave_1_pdo_entries[] = { 194 | {0x6040, 0x00, 16}, 195 | {0x6060, 0x00, 8 }, 196 | {0x6071, 0x00, 16}, 197 | {0x6072, 0x00, 16}, 198 | {0x607a, 0x00, 32}, 199 | {0x6080, 0x00, 32}, 200 | {0x60b8, 0x00, 16}, 201 | {0x60ff, 0x00, 32}, 202 | {0x603f, 0x00, 16}, 203 | {0x6041, 0x00, 16}, 204 | {0x6061, 0x00, 8 }, 205 | {0x6064, 0x00, 32}, 206 | {0x606c, 0x00, 32}, 207 | {0x6077, 0x00, 16}, 208 | {0x60b9, 0x00, 16}, 209 | {0x60ba, 0x00, 32}, 210 | {0x60fd, 0x00, 32}, 211 | };//{index,subindex,lenth} 212 | 213 | static ec_pdo_info_t slave_1_pdos[] = { 214 | {0x1600, 8, slave_1_pdo_entries + 0}, 215 | {0x1a00, 9, slave_1_pdo_entries + 8}, 216 | }; 217 | 218 | 219 | static ec_sync_info_t slave_1_syncs[] = { 220 | {0, EC_DIR_OUTPUT, 0, NULL,EC_WD_DISABLE}, 221 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 222 | {2, EC_DIR_OUTPUT, 1, slave_1_pdos + 0, EC_WD_DISABLE}, 223 | {3, EC_DIR_INPUT, 1, slave_1_pdos + 1, EC_WD_DISABLE}, 224 | {0xff} 225 | }; 226 | 227 | static ec_pdo_entry_info_t slave_2_pdo_entries[] = { 228 | {0x6040, 0x00, 16}, 229 | {0x6060, 0x00, 8 }, 230 | {0x6071, 0x00, 16}, 231 | {0x6072, 0x00, 16}, 232 | {0x607a, 0x00, 32}, 233 | {0x6080, 0x00, 32}, 234 | {0x60b8, 0x00, 16}, 235 | {0x60ff, 0x00, 32}, 236 | {0x603f, 0x00, 16}, 237 | {0x6041, 0x00, 16}, 238 | {0x6061, 0x00, 8 }, 239 | {0x6064, 0x00, 32}, 240 | {0x606c, 0x00, 32}, 241 | {0x6077, 0x00, 16}, 242 | {0x60b9, 0x00, 16}, 243 | {0x60ba, 0x00, 32}, 244 | {0x60fd, 0x00, 32}, 245 | };//{index,subindex,lenth} 246 | 247 | 248 | 249 | static ec_pdo_info_t slave_2_pdos[] = { 250 | {0x1600, 8, slave_2_pdo_entries + 0}, 251 | {0x1a00, 9, slave_2_pdo_entries + 8}, 252 | }; 253 | 254 | static ec_sync_info_t slave_2_syncs[] = { 255 | {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, 256 | {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, 257 | {2, EC_DIR_OUTPUT, 1, slave_2_pdos + 0, EC_WD_DISABLE}, 258 | {3, EC_DIR_INPUT, 1, slave_2_pdos + 1, EC_WD_DISABLE}, 259 | {0xff} 260 | }; 261 | 262 | 263 | 264 | #endif 265 | 266 | 267 | 268 | /*****************************************************************************/ 269 | 270 | void cyclic_task() 271 | { 272 | // receive process data 273 | ecrt_master_receive(master); 274 | ecrt_domain_process(domain1); 275 | // ecrt_domain_process(domain2); 276 | 277 | temp[0]=EC_READ_U16(domain1_pd + status_word); 278 | temp[1]=EC_READ_U16(domain1_pd + status_word2); 279 | temp[2]=EC_READ_U16(domain1_pd + status_word3); 280 | // temp[2]=EC_READ_U16(domain2_pd + pos_act); 281 | // temp[3]=EC_READ_U32(domain2_pd + vel_act); 282 | // temp[4]=EC_READ_S32(domain2_pd + torq_act); 283 | // temp[5]=EC_READ_U32(domain2_pd + digital_input); 284 | if (counter) { 285 | counter--; 286 | } else { // do this at 1 Hz 287 | counter = FREQUENCY; 288 | 289 | blink = !blink; 290 | } 291 | printf("after value =%x\n",temp[0]); 292 | // write process data 293 | if(servooff==1){//servo off 294 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 295 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 296 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0006 ); 297 | printf("0 is ok\n"); 298 | } 299 | else if(((temp[0]&0x004f) == 0x0040) && ((temp[1]&0x004f) == 0x0040) && ((temp[2]&0x004f) == 0x0040) ){ 300 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 301 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0006 ); 302 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0006 ); 303 | printf("%x\n",temp[0]); 304 | printf("1 is ok\n"); 305 | } 306 | else if(((temp[0]&0x006f) == 0x0021) && ((temp[1]&0x006f) == 0x0021) && ((temp[2]&0x006f) == 0x0021)){ 307 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 308 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x0007 ); 309 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x0007 ); 310 | printf("%x\n",temp[0]); 311 | printf("2 is ok\n"); 312 | } 313 | else if(((temp[0]&0x006f) == 0x0023) && ((temp[1]&0x006f) == 0x0023) && ((temp[2]&0x006f) == 0x0023)){ 314 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f ); 315 | EC_WRITE_S32(domain1_pd+tar_pos,0); 316 | EC_WRITE_S32(domain1_pd+tar_vel, 0xffff); 317 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 318 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x000f ); 319 | EC_WRITE_S32(domain1_pd+tar_pos2,0); 320 | EC_WRITE_S32(domain1_pd+tar_vel2, 0xffff); 321 | EC_WRITE_S32(domain1_pd+max_torq2, 0xf00); 322 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x000f ); 323 | EC_WRITE_S32(domain1_pd+tar_pos3,0); 324 | EC_WRITE_S32(domain1_pd+tar_vel3, 0xffff); 325 | EC_WRITE_S32(domain1_pd+max_torq3, 0xf00); 326 | 327 | printf("%x\n",temp[0]); 328 | printf("3 is ok\n"); 329 | } 330 | else if(((temp[0]&0x006f) == 0x0027) && ((temp[1]&0x006f) == 0x0027) && ((temp[2]&0x006f) == 0x0027)){ 331 | EC_WRITE_S32(domain1_pd+tar_pos, (value+=1) ); 332 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 333 | EC_WRITE_S32(domain1_pd+tar_pos2, (value+=1) ); 334 | EC_WRITE_U16(domain1_pd+ctrl_word2, 0x001f); 335 | EC_WRITE_S32(domain1_pd+tar_pos3, (value+=1) ); 336 | EC_WRITE_U16(domain1_pd+ctrl_word3, 0x001f); 337 | 338 | // int q =0; 339 | // for (q =0; q<6; q++) 340 | // printf("q = %x\n",temp[q]); 341 | printf("4 is ok\n"); 342 | } 343 | 344 | 345 | // send process data 346 | ecrt_domain_queue(domain1); 347 | // ecrt_domain_queue(domain2); 348 | ecrt_master_send(master); 349 | } 350 | 351 | /****************************************************************************/ 352 | 353 | void signal_handler(int signum) { 354 | switch (signum) { 355 | case SIGALRM: 356 | sig_alarms++; 357 | break; 358 | } 359 | } 360 | 361 | /****************************************************************************/ 362 | 363 | int main(int argc, char **argv) 364 | { 365 | struct sigaction sa; 366 | struct itimerval tv; 367 | 368 | master = ecrt_request_master(0); 369 | if (!master) 370 | return -1; 371 | 372 | domain1 = ecrt_master_create_domain(master); 373 | if (!domain1) 374 | return -1; 375 | 376 | // domain2 = ecrt_master_create_domain(master); 377 | // if (!domain2) 378 | // return -1; 379 | 380 | if (!(sc = ecrt_master_slave_config( 381 | master, yas, yaskawa))) { 382 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 383 | return -1; 384 | } 385 | 386 | if (!(sc2 = ecrt_master_slave_config( 387 | master, yas2, yaskawa))) { 388 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 389 | return -1; 390 | } 391 | 392 | if (!(sc3 = ecrt_master_slave_config( 393 | master, yas3, yaskawa))) { 394 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 395 | return -1; 396 | } 397 | 398 | 399 | #if SDO_ACCESS 400 | if (ecrt_slave_config_sdo8(sc, 0x6060, 0, 8)){ 401 | return -1; 402 | } 403 | if (ecrt_slave_config_sdo8(sc2, 0x6060, 0, 8)){ 404 | return -1; 405 | } 406 | if (ecrt_slave_config_sdo8(sc3, 0x6060, 0, 8)){ 407 | return -1; 408 | } 409 | 410 | #endif 411 | 412 | 413 | #if CONFIGURE_PDOS 414 | printf("Configuring PDOs...\n"); 415 | 416 | if (ecrt_slave_config_pdos(sc, EC_END, slave_0_syncs)) { 417 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 418 | return -1; 419 | } 420 | 421 | if (ecrt_slave_config_pdos(sc2, EC_END, slave_1_syncs)) { 422 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 423 | return -1; 424 | } 425 | 426 | if (ecrt_slave_config_pdos(sc3, EC_END, slave_2_syncs)) { 427 | fprintf(stderr, "Failed to configure 1st PDOs.\n"); 428 | return -1; 429 | } 430 | 431 | #endif 432 | 433 | 434 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 435 | fprintf(stderr, "PDO entry registration failed!\n"); 436 | return -1; 437 | } 438 | // if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 439 | // fprintf(stderr, "PDO entry registration failed!\n"); 440 | // return -1; 441 | // } 442 | 443 | 444 | printf("Activating master...\n"); 445 | if (ecrt_master_activate(master)) 446 | return -1; 447 | 448 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 449 | return -1; 450 | } 451 | // if (!(domain2_pd = ecrt_domain_data(domain2))) { 452 | // return -1; 453 | // } 454 | 455 | 456 | 457 | pid_t pid = getpid(); 458 | if (setpriority(PRIO_PROCESS, pid, -19)) 459 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 460 | strerror(errno)); 461 | 462 | sa.sa_handler = signal_handler; 463 | sigemptyset(&sa.sa_mask); 464 | sa.sa_flags = 0; 465 | if (sigaction(SIGALRM, &sa, 0)) { 466 | fprintf(stderr, "Failed to install signal handler!\n"); 467 | return -1; 468 | } 469 | 470 | printf("Starting timer...\n"); 471 | tv.it_interval.tv_sec = 0; 472 | tv.it_interval.tv_usec = 1000000 / FREQUENCY; 473 | tv.it_value.tv_sec = 0; 474 | tv.it_value.tv_usec = 1000; 475 | if (setitimer(ITIMER_REAL, &tv, NULL)) { 476 | fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); 477 | return 1; 478 | } 479 | 480 | printf("Started.\n"); 481 | while (1) { 482 | pause(); 483 | 484 | while (sig_alarms != user_alarms) { 485 | cyclic_task(); 486 | user_alarms++; 487 | } 488 | } 489 | 490 | return 0; 491 | } 492 | 493 | /****************************************************************************/ 494 | -------------------------------------------------------------------------------- /examples/user/main_yas.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * $Id: main.c,v 6a6dec6fc806 2012/09/19 17:46:58 fp $ 4 | * 5 | * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH 6 | * 7 | * This file is part of the IgH EtherCAT Master. 8 | * 9 | * The IgH EtherCAT Master is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License version 2, as 11 | * published by the Free Software Foundation. 12 | * 13 | * The IgH EtherCAT Master is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with the IgH EtherCAT Master; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * --- 23 | * 24 | * The license mentioned above concerns the source code only. Using the 25 | * EtherCAT technology and brand is only permitted in compliance with the 26 | * industrial property and similar rights of Beckhoff Automation GmbH. 27 | * 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /****************************************************************************/ 40 | 41 | #include "ecrt.h" 42 | 43 | /****************************************************************************/ 44 | // Application parameters 45 | #define FREQUENCY 1000 46 | 47 | 48 | static ec_master_t *master = NULL; 49 | static ec_domain_t *domain1 = NULL; 50 | static ec_domain_t *domain2 = NULL; 51 | /****************************************************************************/ 52 | static ec_slave_config_t *sc = NULL; 53 | /****************************************************************************/ 54 | 55 | // Timer 56 | static unsigned int sig_alarms = 0; 57 | static unsigned int user_alarms = 0; 58 | 59 | /****************************************************************************/ 60 | 61 | // process data 62 | static uint8_t *domain1_pd = NULL; 63 | static uint8_t *domain2_pd = NULL; 64 | #define yas 1,0 65 | #define yaskawa 0x00000539, 0x02200001 66 | //signal to turn off servo on state 67 | static unsigned int servooff; 68 | 69 | // offsets for PDO entries 70 | static unsigned int ctrl_word ; 71 | static unsigned int target_pos ; 72 | static unsigned int tar_velo ; 73 | static unsigned int tar_torq ; 74 | static unsigned int max_torq ; 75 | static unsigned int modeofoper ; 76 | static unsigned int interpolateddata ; 77 | 78 | static unsigned int status_word ; 79 | static unsigned int actual_pos ; 80 | static unsigned int torq_actu_val; 81 | static unsigned int following_actu_val; 82 | static unsigned int modeofop_display; 83 | static unsigned int touch_probe_stat; 84 | static unsigned int touch_probe_val; 85 | 86 | static signed long temp[8]={}; 87 | //rx pdo entry of 1st motor 88 | const static ec_pdo_entry_reg_t domain1_regs[] = { 89 | {yas, yaskawa,0x6040, 00, &ctrl_word },//rx 90 | {yas, yaskawa,0x607a, 00, &target_pos }, 91 | {yas, yaskawa,0x60ff, 00, &tar_velo }, 92 | {yas, yaskawa,0x6071, 00, &tar_torq }, 93 | {yas, yaskawa,0x6072, 00, &max_torq }, 94 | {yas, yaskawa,0x6060, 00, &modeofoper }, 95 | {yas, yaskawa,0x60c1, 01, &interpolateddata }, 96 | {} 97 | }; 98 | 99 | const static ec_pdo_entry_reg_t domain2_regs[] = { 100 | {yas, yaskawa,0x6041, 00, &status_word },//tx 101 | {yas, yaskawa,0x6064, 00, &actual_pos }, 102 | {yas, yaskawa,0x6077, 00, &torq_actu_val }, 103 | {yas, yaskawa,0x60f4, 00, &following_actu_val }, 104 | {yas, yaskawa,0x6061, 00, &modeofop_display }, 105 | {yas, yaskawa,0x60b9, 00, &touch_probe_stat }, 106 | {yas, yaskawa,0x60ba, 00, &touch_probe_val }, 107 | {} 108 | }; 109 | 110 | 111 | 112 | float value = 0; 113 | static unsigned int counter = 0; 114 | static unsigned int blink = 0; 115 | 116 | 117 | 118 | 119 | /*****************************************************************************/ 120 | 121 | void cyclic_task() 122 | { 123 | // receive process data 124 | ecrt_master_receive(master); 125 | ecrt_domain_process(domain1); 126 | ecrt_domain_process(domain2); 127 | 128 | temp[0]=EC_READ_U16(domain2_pd + status_word); 129 | temp[1]=EC_READ_U32(domain2_pd + actual_pos); 130 | if (counter) { 131 | counter--; 132 | } else { // do this at 1 Hz 133 | counter = FREQUENCY; 134 | 135 | blink = !blink; 136 | } 137 | 138 | // write process data 139 | if(servooff==1){//servo off 140 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 141 | //deactive++; 142 | } 143 | else if( (temp[0]&0x004f) == 0x0040 ){ 144 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0006 ); 145 | printf("%x\n",temp[0]); 146 | } 147 | else if( (temp[0]&0x006f) == 0x0021){ 148 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x0007 ); 149 | printf("%x\n",temp[0]); 150 | } 151 | // else if( (temp[0]&0x027f) == 0x0233){ 152 | else if( (temp[0]&0x006f) == 0x0023){ 153 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x000f); 154 | EC_WRITE_S32(domain1_pd+target_pos, 0); 155 | EC_WRITE_S32(domain1_pd+tar_velo, 0xfffff); 156 | EC_WRITE_S32(domain1_pd+max_torq, 0xf00); 157 | EC_WRITE_S32(domain1_pd+modeofoper, 8); 158 | printf("%x\n",temp[0]); 159 | } 160 | // else if( (temp[0]&0x027f) == 0x0237){//600 800 161 | else if( (temp[0]&0x006f) == 0x0027){ 162 | EC_WRITE_S32(domain1_pd+target_pos, (value+=2000) ); 163 | EC_WRITE_U16(domain1_pd+ctrl_word, 0x001f); 164 | printf("%x\n",temp[0]); 165 | } 166 | 167 | // send process data 168 | ecrt_domain_queue(domain1); 169 | ecrt_domain_queue(domain2); 170 | ecrt_master_send(master); 171 | } 172 | 173 | /****************************************************************************/ 174 | 175 | void signal_handler(int signum) { 176 | switch (signum) { 177 | case SIGALRM: 178 | sig_alarms++; 179 | break; 180 | } 181 | } 182 | 183 | /****************************************************************************/ 184 | 185 | int main(int argc, char **argv) 186 | { 187 | struct sigaction sa; 188 | struct itimerval tv; 189 | 190 | master = ecrt_request_master(0); 191 | if (!master) 192 | return -1; 193 | 194 | domain1 = ecrt_master_create_domain(master); 195 | if (!domain1) 196 | return -1; 197 | domain2 = ecrt_master_create_domain(master); 198 | if (!domain2) 199 | return -1; 200 | 201 | if (!(sc = ecrt_master_slave_config( 202 | master, yas, yaskawa))) { 203 | fprintf(stderr, "Failed to get slave1 configuration.\n"); 204 | return -1; 205 | } 206 | 207 | 208 | if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { 209 | fprintf(stderr, "PDO entry registration failed!\n"); 210 | return -1; 211 | } 212 | if (ecrt_domain_reg_pdo_entry_list(domain2, domain2_regs)) { 213 | fprintf(stderr, "PDO entry registration failed!\n"); 214 | return -1; 215 | } 216 | 217 | printf("Activating master...\n"); 218 | if (ecrt_master_activate(master)) 219 | return -1; 220 | 221 | if (!(domain1_pd = ecrt_domain_data(domain1))) { 222 | return -1; 223 | } 224 | if (!(domain2_pd = ecrt_domain_data(domain2))) { 225 | return -1; 226 | } 227 | 228 | 229 | pid_t pid = getpid(); 230 | if (setpriority(PRIO_PROCESS, pid, -19)) 231 | fprintf(stderr, "Warning: Failed to set priority: %s\n", 232 | strerror(errno)); 233 | 234 | sa.sa_handler = signal_handler; 235 | sigemptyset(&sa.sa_mask); 236 | sa.sa_flags = 0; 237 | if (sigaction(SIGALRM, &sa, 0)) { 238 | fprintf(stderr, "Failed to install signal handler!\n"); 239 | return -1; 240 | } 241 | 242 | printf("Starting timer...\n"); 243 | tv.it_interval.tv_sec = 0; 244 | tv.it_interval.tv_usec = 1000000 / FREQUENCY; 245 | tv.it_value.tv_sec = 0; 246 | tv.it_value.tv_usec = 1000; 247 | if (setitimer(ITIMER_REAL, &tv, NULL)) { 248 | fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); 249 | return 1; 250 | } 251 | 252 | printf("Started.\n"); 253 | while (1) { 254 | pause(); 255 | 256 | while (sig_alarms != user_alarms) { 257 | cyclic_task(); 258 | user_alarms++; 259 | } 260 | } 261 | 262 | return 0; 263 | } 264 | 265 | /****************************************************************************/ 266 | --------------------------------------------------------------------------------