├── CMakeLists.txt ├── ChangeLog ├── Doxyfile ├── LICENSE ├── README.md ├── demo ├── CMakeLists.txt ├── eCoder_fake.py ├── eRob_CSP.cpp ├── eRob_CSP_subscriber.cpp ├── eRob_CST.cpp ├── eRob_CSV.cpp ├── eRob_PP_subscriber.cpp ├── eRob_PT.cpp └── eRob_TC.cpp ├── doc ├── images │ ├── legacy_iomap.png │ ├── memory_layout.png │ └── overlapping_iomap.png ├── soem.dox └── tutorial.txt ├── drvcomment.txt ├── osal ├── erika │ ├── osal.c │ └── osal_defs.h ├── intime │ ├── osal.c │ └── osal_defs.h ├── linux │ ├── osal.c │ └── osal_defs.h ├── macosx │ ├── osal.c │ └── osal_defs.h ├── osal.h ├── rtems │ ├── osal.c │ └── osal_defs.h ├── rtk │ ├── osal.c │ └── osal_defs.h ├── vxworks │ ├── osal.c │ └── osal_defs.h └── win32 │ ├── inttypes.h │ ├── osal.c │ ├── osal_defs.h │ ├── osal_win32.h │ └── stdint.h ├── oshw ├── erika │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── intime │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── linux │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── macosx │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── rtems │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── rtk │ ├── fec │ │ ├── fec_ecat.c │ │ └── fec_ecat.h │ ├── lw_mac │ │ ├── lw_emac.c │ │ └── lw_emac.h │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h ├── vxworks │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ └── oshw.h └── win32 │ ├── nicdrv.c │ ├── nicdrv.h │ ├── oshw.c │ ├── oshw.h │ └── wpcap │ ├── Include │ ├── Packet32.h │ ├── Win32-Extensions.h │ ├── bittypes.h │ ├── ip6_misc.h │ ├── pcap-bpf.h │ ├── pcap-namedb.h │ ├── pcap-stdinc.h │ ├── pcap.h │ ├── pcap │ │ ├── bluetooth.h │ │ ├── bpf.h │ │ ├── namedb.h │ │ ├── pcap.h │ │ ├── sll.h │ │ ├── usb.h │ │ └── vlan.h │ └── remote-ext.h │ └── Lib │ ├── Packet.lib │ ├── libpacket.a │ ├── libwpcap.a │ ├── wpcap.lib │ └── x64 │ ├── Packet.lib │ └── wpcap.lib ├── soem ├── ethercat.h ├── ethercatbase.c ├── ethercatbase.h ├── ethercatcoe.c ├── ethercatcoe.h ├── ethercatconfig.c ├── ethercatconfig.h ├── ethercatconfiglist.h ├── ethercatdc.c ├── ethercatdc.h ├── ethercateoe.c ├── ethercateoe.h ├── ethercatfoe.c ├── ethercatfoe.h ├── ethercatmain.c ├── ethercatmain.h ├── ethercatprint.c ├── ethercatprint.h ├── ethercatsoe.c ├── ethercatsoe.h └── ethercattype.h └── test ├── intime └── ec_master │ └── ec_master.c ├── linux ├── aliastool.c ├── ebox │ └── ebox.c ├── eepromtool │ ├── CMakeLists.txt │ └── eepromtool.c ├── eoe_test │ └── eoe_test.c ├── firm_update │ └── firm_update.c ├── red_test │ └── red_test.c ├── simple_test │ ├── CMakeLists.txt │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-f87ad9eea6b44cf17ff1.json │ │ │ │ ├── cmakeFiles-v1-f9c3ad20eee0b952595f.json │ │ │ │ ├── codemodel-v2-9aa1cbdb6a802b85206c.json │ │ │ │ ├── directory-.-Debug-b325d41ce6d3ee02aa0e.json │ │ │ │ ├── index-2024-10-23T12-04-06-0220.json │ │ │ │ ├── target-eRob_test-Debug-16138a9a78b739c30419.json │ │ │ │ ├── target-github_test-Debug-249137b88ece3a0b5028.json │ │ │ │ ├── target-simple_test-Debug-7c03d7d505b4e4e23035.json │ │ │ │ └── toolchains-v1-7096c62e23c342eb06a8.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.29.6 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── a.out │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── a.out │ │ │ ├── CMakeConfigureLog.yaml │ │ │ ├── TargetDirectories.txt │ │ │ ├── clion-Debug-log.txt │ │ │ ├── clion-environment.txt │ │ │ ├── cmake.check_cache │ │ │ ├── eRob_test.dir │ │ │ │ └── eRob_test.cpp.o │ │ │ ├── rules.ninja │ │ │ └── simple_test.dir │ │ │ │ └── simple_test.c.o │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── build.ninja │ │ ├── cmake_install.cmake │ │ ├── eRob_test │ │ ├── github_test │ │ └── simple_test │ ├── eRob_test.cpp │ ├── github.cpp │ └── simple_test.c └── slaveinfo │ ├── CMakeLists.txt │ └── slaveinfo.c ├── rtk ├── main.c └── schedule.tt ├── simple_ng ├── CMakeLists.txt └── simple_ng.c └── win32 ├── ebox └── ebox.c ├── eepromtool └── eepromtool.c ├── firm_update └── firm_update.c ├── red_test └── red_test.c ├── simple_test └── simple_test.c └── slaveinfo └── slaveinfo.c /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") 3 | project(SOEM 4 | DESCRIPTION "Simple Open EtherCAT Master" 5 | VERSION 1.4.0 6 | LANGUAGES C 7 | ) 8 | 9 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Default to installing in SOEM source directory 10 | set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install) 11 | endif() 12 | 13 | set(SOEM_INCLUDE_INSTALL_DIR include/soem) 14 | set(SOEM_LIB_INSTALL_DIR lib) 15 | 16 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 17 | set(BUILD_TESTS TRUE) 18 | else() 19 | message(STATUS "SOEM: not building tests when built as dependency") 20 | set(BUILD_TESTS FALSE) 21 | endif() 22 | 23 | if(WIN32) 24 | set(OS "win32") 25 | include_directories(oshw/win32/wpcap/Include) 26 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 27 | link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib/x64) 28 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) 29 | link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib) 30 | endif() 31 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS") 32 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") 33 | set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib) 34 | elseif(UNIX AND NOT APPLE) 35 | set(OS "linux") 36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") 37 | set(OS_LIBS pthread rt) 38 | elseif(APPLE) 39 | # This must come *before* linux or MacOSX will identify as Unix. 40 | set(OS "macosx") 41 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") 42 | set(OS_LIBS pthread pcap) 43 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel") 44 | set(OS "rtk") 45 | message(STATUS "ARCH is ${ARCH}") 46 | message(STATUS "BSP is ${BSP}") 47 | include_directories(oshw/${OS}/${ARCH}) 48 | file(GLOB OSHW_EXTRA_SOURCES oshw/${OS}/${ARCH}/*.c) 49 | set(OSHW_SOURCES "${OS_HW_SOURCES} ${OSHW_ARCHSOURCES}") 50 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") 51 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable") 52 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") 53 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") 54 | set(OS_LIBS "-Wl,--start-group -l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lc -lm -Wl,--end-group") 55 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "rtems") 56 | message(STATUS "Building for RTEMS") 57 | set(OS "rtems") 58 | set(SOEM_LIB_INSTALL_DIR ${LIB_DIR}) 59 | set(BUILD_TESTS FALSE) 60 | endif() 61 | 62 | message(STATUS "OS is ${OS}") 63 | 64 | file(GLOB SOEM_SOURCES soem/*.c) 65 | file(GLOB OSAL_SOURCES osal/${OS}/*.c) 66 | file(GLOB OSHW_SOURCES oshw/${OS}/*.c) 67 | 68 | file(GLOB SOEM_HEADERS soem/*.h) 69 | file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h) 70 | file(GLOB OSHW_HEADERS oshw/${OS}/*.h) 71 | 72 | # Change to SHARED here 73 | add_library(soem SHARED 74 | ${SOEM_SOURCES} 75 | ${OSAL_SOURCES} 76 | ${OSHW_SOURCES} 77 | ${OSHW_EXTRA_SOURCES} 78 | ) 79 | 80 | # Link necessary system libraries 81 | target_link_libraries(soem ${OS_LIBS}) 82 | 83 | # Specify include directories 84 | target_include_directories(soem PUBLIC 85 | $ 86 | $ 87 | ) 88 | target_include_directories(soem PUBLIC 89 | $ 90 | $ 91 | ) 92 | target_include_directories(soem PUBLIC 93 | $ 94 | $ 95 | ) 96 | target_include_directories(soem 97 | PUBLIC $ 98 | $ 99 | ) 100 | 101 | message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}") 102 | 103 | # Install targets 104 | install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR}) 105 | install(EXPORT soemConfig DESTINATION share/soem/cmake) 106 | 107 | # Install header files 108 | install(FILES 109 | ${SOEM_HEADERS} 110 | ${OSAL_HEADERS} 111 | ${OSHW_HEADERS} 112 | DESTINATION ${SOEM_INCLUDE_INSTALL_DIR} 113 | ) 114 | 115 | if(BUILD_TESTS) 116 | add_subdirectory(test/simple_ng) 117 | add_subdirectory(test/linux/slaveinfo) 118 | add_subdirectory(test/linux/eepromtool) 119 | add_subdirectory(test/linux/simple_test) 120 | add_subdirectory(demo) 121 | endif() 122 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Version 1.1.2 : 2008-12-23 2 | - First public release 3 | Version 1.1.3 : 2009-01-18 4 | - Added CoE, RxPDO and TxPDO (still Beta) 5 | - Added FoE, Read and Write (still Beta) 6 | - Fixed BigEndian conversion missing in ethercatconfig.c (credit:Serge Bloch) 7 | - Fixed segmented transfer bug in ethercatcoe.c 8 | Version 1.1.4 : 2009-04-22 9 | - Changed FMMU configuration algorithm 10 | - Changed ec_slave structure around SM and FMMU storage 11 | - Added SYNC1 configuration 12 | - Fixed bug in FoE write 13 | Version 1.2.0 : 2009-09-12 14 | - Changed the license to GPLv2 only 15 | - Added note to usage terms (please read carefully) 16 | - Eeprom acces is released to slave after preop 17 | - Fixed linux-64 define bug (uint32 and int32) 18 | - Fixed maximum frame size 19 | Version 1.2.2 : 2010-02-22 20 | - Fixed bugs in ec_adddatagram. 21 | - Fixed several bugs in CoE object dictionary read functions. 22 | - Fixed bug in PDO mapping read function. 23 | - Changed ec_slave structure around topology and delay variables. 24 | - Added several constants in ethercattype.c 25 | Version 1.2.3 : 2010-03-07 26 | - Clear SM enable if size is 0, even if enable is set in SII. 27 | - Fixed bug in DC propagation delay calculation. Branches with only non DC slaves now correctly close root port. 28 | - Fixed bug in ec_receive_processdata(), wkc now checks for EC_NOFRAME instead of 0. 29 | - Fixed bug in makefile 30 | Version 1.2.4 : 2010-04-10 31 | - Added SoE, servo over EtherCAT support. 32 | - Added SoE read request and write request. 33 | - Added SoE segmented transfers. 34 | - Added SoE error response. 35 | - Added SoE errors to print module. 36 | - Added Auto config of SoE process data. 37 | Version 1.2.5 : 2011-06-13 38 | - Added eepromtool, it can read and write the ESC eeprom of a designated slave. 39 | - Rewrite of eeprom read/write functions. 40 | - Added infrastructure change to allow slave groups. 41 | - Added recovery and reconfiguration of slaves after connection loss. 42 | - Improved CoE PDO assignment read from slaves, no longer assume assign indexes as functionally fixed. 43 | - Fixed bugs in ec_config_map(). 44 | - Added EC_STATE_BOOT constant. 45 | - Fixed mailbox size bug, In and Out mailbox can now be of different size. 46 | - Fixed SM type bug. 47 | - Fixed FoE bugs. 48 | - Fixed siigetbyte() unaligned copy. 49 | - Fixed bug in nicdrv.c, socket handles are 0 included. 50 | - Fixed bug in ethercatconfig.c causing memory corruption. 51 | Version 1.2.8 : 2012-06-14 52 | - Changed directory structure. 53 | - Changed make file. 54 | - Moved hardware / OS dependend part in separate directories. 55 | - Added firm_update tool to upload firmware to slaves in Boot state, use with care. 56 | - Added DC for LRD/LWR case. 57 | - Separated expectedWKC to inputsWKC and outputsWKC. 58 | - Added PreOP->SafeOP hooks in configuration functions. 59 | - With CoE use expedited download if mailbox size is very small and object <= 4 bytes. 60 | - Fixed NetX mailbox configuration behaviour. 61 | - Fixed FoE write bug. 62 | - Added mailbox error handling. 63 | - Fixed SII string read bug. 64 | - Fixed bug in table lookup for printing 65 | - Rewrite of ec_recover_slave() and ec_reconfigure_slave() 66 | - Added -map option in slaveinfo, shows SOEM IO mapping of all slaves found. 67 | Version 1.3.0 : 2013-02-24 68 | - Added win32 target. 69 | - Added rtk target. 70 | - Compiles under gcc / visual-c / borland-c. 71 | - Multiple port support. One master can run concurrent stacks on multiple network ports. 72 | - All global vars are encapsulated in context struct. 73 | - All timing abstracted in osal.c. 74 | - Linux timing converted to get_clock(CLOCK_MONOTONIC). 75 | - Error messages updated to latest ETG1020 document. 76 | - FoE transfers now support busy response. 77 | - Fixed NetX100 configuration behaviour. 78 | - Fixed linux gettimeofday() to get_clock(). 79 | - Fixed eeprom cache flush on reinit. 80 | - Fixed make for new gcc linker version. 81 | Version 1.3.1 : 2015-03-11 82 | - Added intime target. 83 | - Added rtk\fec target. 84 | - Compiles under gcc / visual-c / borland-c / intime. 85 | - Added multi-threaded configuration for parallel configurations of slaves 86 | Version 1.3.2 : 2018-02-02 87 | - Made a mistake. DON'T USE! 88 | Version 1.3.3 : 2018-02-02 89 | - Added rtems target. 90 | - Added support for overlapping IOmap. 91 | 92 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Simple Open EtherCAT Master Library 2 | 3 | Copyright (C) 2005-2017 Speciaal Machinefabriek Ketels v.o.f. 4 | Copyright (C) 2005-2017 Arthur Ketels 5 | Copyright (C) 2008-2009 TU/e Technische Universiteit Eindhoven 6 | Copyright (C) 2009-2017 rt-labs AB, Sweden 7 | 8 | SOEM is free software; you can redistribute it and/or modify it under the terms 9 | of the GNU General Public License version 2 as published by the Free Software 10 | Foundation. 11 | 12 | SOEM is distributed in the hope that it will be useful, but WITHOUT ANY 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 | 16 | As a special exception, if other files instantiate templates or use macros or 17 | inline functions from this file, or you compile this file and link it with other 18 | works to produce a work based on this file, this file does not by itself cause 19 | the resulting work to be covered by the GNU General Public License. However the 20 | source code for this file must still be made available in accordance with 21 | section (3) of the GNU General Public License. 22 | 23 | This exception does not invalidate any other reasons why a work based on this 24 | file might be covered by the GNU General Public License. 25 | 26 | The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual 27 | property of, and protected by Beckhoff Automation GmbH. You can use SOEM for the 28 | sole purpose of creating, using and/or selling or otherwise distributing an 29 | EtherCAT network master provided that an EtherCAT Master License is obtained 30 | from Beckhoff Automation GmbH. 31 | 32 | In case you did not receive a copy of the EtherCAT Master License along with 33 | SOEM write to Beckhoff Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany 34 | (www.beckhoff.com). 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ***This is an open-source demo related to the eRob product, provided solely for reference by developers. Please note that issues within the open-source project are independent of the quality of eRob products. Users are advised to exercise caution while using the demo. We are not responsible for any damage caused by improper operations. For any project errors, please raise a query in the Issues section. Collaboration and forks to resolve open-source project issues are welcome.*** 2 | 3 | ## Recommendations for EtherCAT Open-Source Master Users 4 | 5 | 1. **Use a Real-Time Kernel System** 6 | Ensure your operating system has a real-time kernel to guarantee consistent and precise communication. 7 | 8 | 2. **Isolate CPU Cores** 9 | Perform CPU isolation to dedicate specific cores to EtherCAT processes, reducing interruptions and improving stability. 10 | 11 | 3. **Troubleshooting OP State Issues** 12 | - Failure to enter OP state may be caused by errors in the **object dictionary mapping** or improper configuration of **DC (Distributed Clock) mode**. 13 | - **eRob** only supports **DC mode**, and proper configuration of DC mode is crucial for system synchronization and precision. 14 | 15 | 4. **Read Mode-Specific Instructions** 16 | Before using each mode, read the relevant operational instructions to ensure correct configuration and usage. 17 | 18 | 5. **Use the Official eRob Upper Computer Software** 19 | eRob provides official upper computer software. Mastering the built-in **oscilloscope tool** will allow you to quickly locate issues with the EtherCAT master. 20 | 21 | 6. **Capture and Analyze EtherCAT Data** 22 | Use packet capture tools to analyze EtherCAT output and log information to identify errors. 23 | 24 | 25 | ## Installation 26 | 27 | 1. install eRob-SOEM-Linux 28 | ``` bash 29 | git clone https://github.com/ZeroErrControl/eRob_SOEM_linux.git 30 | cd eRob_SOEM_linux 31 | mkdir build 32 | cd build 33 | cmake .. 34 | make 35 | 36 | ``` 37 | 38 | ## Usage 39 | ### Running demo: 40 | 41 | 1. CSV mode: 42 | ```bash 43 | sudo ./build/demo/eRob_CSV 44 | ``` 45 | 46 | 2. Launch the position subscriber (PP): 47 | ```bash 48 | sudo ./build/demo/eRob_PP_subscriber 49 | python3 src/erob_ros/src/eCoder_fake.py 50 | ``` 51 | 52 | 3. Launch the position subscriber (CSP): 53 | ```bash 54 | sudo ./build/demo/eRob_CSP_subscriber 55 | python3 src/erob_ros/src/eCoder_fake.py 56 | ``` 57 | 58 | 4. Launch the cyclic synchronous position mode (CSP): 59 | ```bash 60 | sudo ./build/demo/eRob_CSP 61 | ``` 62 | 63 | 5. Launch the profile torque mode (PT): 64 | In this mode, we can control the torque of the servo motor and have added PDO mapping to obtain the position, speed, torque, and status word of the servo motor. 65 | 66 | ```bash 67 | sudo ./build/demo/eRob_PT 68 | ``` 69 | If you want to consult the object dictionary, you can run the following command and then run `sudo ./build/test/linux/slaveinfo -map` to view the object dictionary. 70 | 71 | 72 | 6. Launch the cyclic synchronous torque mode (CST): 73 | In this mode, we can control the torque of the servo motor and have added PDO mapping to obtain the position, speed, torque, and status word of the servo motor. 74 | 75 | ```bash 76 | sudo ./build/demo/eRob_CST 77 | ``` 78 | If you want to consult the object dictionary, you can run the following command and then run `sudo ./build/test/linux/slaveinfo -map` to view the object dictionary. 79 | -------------------------------------------------------------------------------- /demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(erob_soem_demo) 3 | 4 | 5 | project(erob_soem_demo LANGUAGES C CXX) 6 | find_package(Threads REQUIRED) 7 | 8 | include_directories(/home/erobman/SOEM_ethercat/install/SOEM/include/soem) 9 | link_directories(/home/erobman/SOEM_ethercat/install/SOEM/lib) 10 | 11 | 12 | 13 | add_executable(eRob_CSV eRob_CSV.cpp) 14 | target_link_libraries(eRob_CSV soem) 15 | install(TARGETS eRob_CSV DESTINATION bin) 16 | 17 | add_executable(eRob_CSP_subscriber eRob_CSP_subscriber.cpp) 18 | target_link_libraries(eRob_CSP_subscriber soem) 19 | install(TARGETS eRob_CSP_subscriber DESTINATION bin) 20 | 21 | add_executable(eRob_PP_subscriber eRob_PP_subscriber.cpp) 22 | target_link_libraries(eRob_PP_subscriber soem) 23 | install(TARGETS eRob_PP_subscriber DESTINATION bin) 24 | 25 | add_executable(eRob_PT eRob_PT.cpp) 26 | target_link_libraries(eRob_PT soem) 27 | install(TARGETS eRob_PT DESTINATION bin) 28 | 29 | add_executable(eRob_CST eRob_CST.cpp) 30 | target_link_libraries(eRob_CST soem) 31 | install(TARGETS eRob_CST DESTINATION bin) 32 | 33 | add_executable(eRob_CSP eRob_CSP.cpp) 34 | target_link_libraries(eRob_CSP soem) 35 | install(TARGETS eRob_CSP DESTINATION bin) 36 | 37 | # add a test program 38 | #add_executable(eRob_TC eRob_TC.cpp) 39 | #target_link_libraries(eRob_TC soem) 40 | #install(TARGETS eRob_TC DESTINATION bin) -------------------------------------------------------------------------------- /demo/eCoder_fake.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import time 3 | import select 4 | import sys 5 | 6 | def angle_to_pulses(angle): 7 | # Convert angle to pulses (524287 pulses per 360 degrees) 8 | full_turns = int(angle / 360) 9 | remaining_angle = angle % 360 10 | pulses = (full_turns * 524287) + int((remaining_angle / 360) * 524287) 11 | return pulses 12 | 13 | def main(): 14 | # Setup Socket communication 15 | server_ip = "127.0.0.1" 16 | server_port = 8080 17 | 18 | try: 19 | # Create socket connection 20 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 21 | sock.connect((server_ip, server_port)) 22 | 23 | # Initial angle input 24 | print("Enter angle: ", end='', flush=True) 25 | angle = float(input()) 26 | pulses = angle_to_pulses(angle) 27 | 28 | while True: 29 | # Check if there's input available 30 | if select.select([sys.stdin], [], [], 0.0)[0]: 31 | try: 32 | print("Enter angle: ", end='', flush=True) 33 | angle = float(input()) 34 | pulses = angle_to_pulses(angle) 35 | except ValueError: 36 | print("Please enter a valid number") 37 | continue 38 | 39 | try: 40 | # Send pulses through socket continuously 41 | sock.send(f"{pulses}".encode()) 42 | time.sleep(0.1) # Add a small delay 43 | 44 | except Exception as e: 45 | print(f"Error: {e}") 46 | break 47 | 48 | except Exception as e: 49 | print(f"Connection error: {e}") 50 | finally: 51 | sock.close() 52 | 53 | if __name__ == "__main__": 54 | main() -------------------------------------------------------------------------------- /doc/images/legacy_iomap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/doc/images/legacy_iomap.png -------------------------------------------------------------------------------- /doc/images/memory_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/doc/images/memory_layout.png -------------------------------------------------------------------------------- /doc/images/overlapping_iomap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/doc/images/overlapping_iomap.png -------------------------------------------------------------------------------- /drvcomment.txt: -------------------------------------------------------------------------------- 1 | For faster irq response through the NIC/NAPI/Socket layer set for TG3 (at eth0) 2 | ethtool -C eth0 rx-usecs 0 rx-frames 1 tx-usecs 0 tx-frames 1 3 | -------------------------------------------------------------------------------- /osal/erika/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "ee_x86_64_tsc.h" 14 | 15 | #define USECS_PER_SEC 1000000 16 | #define NSECS_PER_SEC 1000000000 17 | 18 | uint64_t osEE_x86_64_tsc_read(void); 19 | 20 | void ee_usleep(uint32 usec); 21 | 22 | inline int osal_usleep (uint32 usec) 23 | { 24 | ee_usleep(usec); 25 | return 0; 26 | } 27 | 28 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz) 29 | { 30 | uint64_t time = osEE_x86_64_tsc_read(); 31 | tv->tv_sec = time/NSECS_PER_SEC; 32 | tv->tv_sec += 946684800UL; /* EtherCAT uses 2000-01-01 as epoch start */ 33 | tv->tv_usec = (time%NSECS_PER_SEC)/1000; 34 | return 0; 35 | } 36 | 37 | ec_timet osal_current_time(void) 38 | { 39 | struct timeval current_time; 40 | ec_timet ret; 41 | 42 | osal_gettimeofday(¤t_time, 0); 43 | ret.sec = current_time.tv_sec; 44 | ret.usec = current_time.tv_usec; 45 | return ret; 46 | } 47 | 48 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff) 49 | { 50 | if (end->usec < start->usec) { 51 | diff->sec = end->sec - start->sec - 1; 52 | diff->usec = end->usec + USECS_PER_SEC - start->usec; 53 | } else { 54 | diff->sec = end->sec - start->sec; 55 | diff->usec = end->usec - start->usec; 56 | } 57 | } 58 | 59 | void osal_timer_start(osal_timert *self, uint32 timeout_usec) 60 | { 61 | struct timeval start_time; 62 | struct timeval timeout; 63 | struct timeval stop_time; 64 | 65 | osal_gettimeofday(&start_time, 0); 66 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 67 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 68 | timeradd(&start_time, &timeout, &stop_time); 69 | 70 | self->stop_time.sec = stop_time.tv_sec; 71 | self->stop_time.usec = stop_time.tv_usec; 72 | } 73 | 74 | boolean osal_timer_is_expired (osal_timert *self) 75 | { 76 | struct timeval current_time; 77 | struct timeval stop_time; 78 | int is_not_yet_expired; 79 | 80 | osal_gettimeofday (¤t_time, 0); 81 | stop_time.tv_sec = self->stop_time.sec; 82 | stop_time.tv_usec = self->stop_time.usec; 83 | is_not_yet_expired = timercmp (¤t_time, &stop_time, <); 84 | /* OSEE_PRINT("current: %d:%d -- expire: %d:%d -- result: %d\n", */ 85 | /* current_time.tv_sec, */ 86 | /* current_time.tv_usec, */ 87 | /* stop_time.tv_sec, */ 88 | /* stop_time.tv_usec, */ 89 | /* is_not_yet_expired); */ 90 | 91 | return is_not_yet_expired == FALSE; 92 | } 93 | 94 | void *osal_malloc(size_t size) 95 | { 96 | return malloc(size); 97 | } 98 | 99 | void osal_free(void *ptr) 100 | { 101 | free(ptr); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /osal/erika/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // define if debug print is needed 19 | #define EC_DEBUG 20 | 21 | #ifdef EC_DEBUG 22 | #define EC_PRINT OSEE_PRINT 23 | #else 24 | #define EC_PRINT(...) do {} while (0) 25 | #endif 26 | 27 | #ifndef PACKED 28 | #define PACKED_BEGIN 29 | #define PACKED __attribute__((__packed__)) 30 | #define PACKED_END 31 | #endif 32 | 33 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz); 34 | void *osal_malloc(size_t size); 35 | void osal_free(void *ptr); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /osal/intime/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | static int64_t sysfrequency; 11 | static double qpc2usec; 12 | 13 | #define USECS_PER_SEC 1000000 14 | 15 | int osal_gettimeofday (struct timeval *tv, struct timezone *tz) 16 | { 17 | return gettimeofday (tv, tz); 18 | } 19 | 20 | ec_timet osal_current_time (void) 21 | { 22 | struct timeval current_time; 23 | ec_timet return_value; 24 | 25 | osal_gettimeofday (¤t_time, 0); 26 | return_value.sec = current_time.tv_sec; 27 | return_value.usec = current_time.tv_usec; 28 | return return_value; 29 | } 30 | 31 | void osal_timer_start (osal_timert * self, uint32 timeout_usec) 32 | { 33 | struct timeval start_time; 34 | struct timeval timeout; 35 | struct timeval stop_time; 36 | 37 | osal_gettimeofday (&start_time, 0); 38 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 39 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 40 | timeradd (&start_time, &timeout, &stop_time); 41 | 42 | self->stop_time.sec = stop_time.tv_sec; 43 | self->stop_time.usec = stop_time.tv_usec; 44 | } 45 | 46 | boolean osal_timer_is_expired (osal_timert * self) 47 | { 48 | struct timeval current_time; 49 | struct timeval stop_time; 50 | int is_not_yet_expired; 51 | 52 | osal_gettimeofday (¤t_time, 0); 53 | stop_time.tv_sec = self->stop_time.sec; 54 | stop_time.tv_usec = self->stop_time.usec; 55 | is_not_yet_expired = timercmp (¤t_time, &stop_time, <); 56 | 57 | return is_not_yet_expired == FALSE; 58 | } 59 | 60 | int osal_usleep(uint32 usec) 61 | { 62 | RtSleepEx (usec / 1000); 63 | return 1; 64 | } 65 | 66 | /* Mutex is not needed when running single threaded */ 67 | 68 | void osal_mtx_lock(osal_mutex_t * mtx) 69 | { 70 | /* RtWaitForSingleObject((HANDLE)mtx, INFINITE); */ 71 | } 72 | 73 | void osal_mtx_unlock(osal_mutex_t * mtx) 74 | { 75 | /* RtReleaseMutex((HANDLE)mtx); */ 76 | } 77 | 78 | int osal_mtx_lock_timeout(osal_mutex_t * mtx, uint32_t time_ms) 79 | { 80 | /* return RtWaitForSingleObject((HANDLE)mtx, time_ms); */ 81 | return 0; 82 | } 83 | 84 | osal_mutex_t * osal_mtx_create(void) 85 | { 86 | /* return (void*)RtCreateMutex(NULL, FALSE, NULL); */ 87 | return (void *)0; 88 | } 89 | -------------------------------------------------------------------------------- /osal/intime/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #ifdef _MSC_VER 25 | #define PACKED_BEGIN __pragma(pack(push, 1)) 26 | #define PACKED 27 | #define PACKED_END __pragma(pack(pop)) 28 | #elif defined(__GNUC__) 29 | #define PACKED_BEGIN 30 | #define PACKED __attribute__((__packed__)) 31 | #define PACKED_END 32 | #endif 33 | #endif 34 | 35 | #define OSAL_THREAD_HANDLE RTHANDLE 36 | #define OSAL_THREAD_FUNC void 37 | #define OSAL_THREAD_FUNC_RT void 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /osal/linux/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define USECS_PER_SEC 1000000 14 | 15 | int osal_usleep (uint32 usec) 16 | { 17 | struct timespec ts; 18 | ts.tv_sec = usec / USECS_PER_SEC; 19 | ts.tv_nsec = (usec % USECS_PER_SEC) * 1000; 20 | /* usleep is deprecated, use nanosleep instead */ 21 | return nanosleep(&ts, NULL); 22 | } 23 | 24 | ec_timet osal_current_time(void) 25 | { 26 | struct timespec current_time; 27 | ec_timet return_value; 28 | 29 | clock_gettime(CLOCK_REALTIME, ¤t_time); 30 | return_value.sec = current_time.tv_sec; 31 | return_value.usec = current_time.tv_nsec / 1000; 32 | 33 | return return_value; 34 | } 35 | 36 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff) 37 | { 38 | if (end->usec < start->usec) { 39 | diff->sec = end->sec - start->sec - 1; 40 | diff->usec = end->usec + 1000000 - start->usec; 41 | } 42 | else { 43 | diff->sec = end->sec - start->sec; 44 | diff->usec = end->usec - start->usec; 45 | } 46 | } 47 | 48 | /* Returns time from some unspecified moment in past, 49 | * strictly increasing, used for time intervals measurement. */ 50 | static void osal_getrelativetime(struct timeval *tv) 51 | { 52 | struct timespec ts; 53 | 54 | /* Use clock_gettime to prevent possible live-lock. 55 | * Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust. 56 | * If this function preempts timeadjust and it uses vpage it live-locks. 57 | * Also when using XENOMAI, only clock_gettime is RT safe */ 58 | clock_gettime(CLOCK_MONOTONIC, &ts); 59 | tv->tv_sec = ts.tv_sec; 60 | tv->tv_usec = ts.tv_nsec / 1000; 61 | } 62 | 63 | void osal_timer_start(osal_timert * self, uint32 timeout_usec) 64 | { 65 | struct timeval start_time; 66 | struct timeval timeout; 67 | struct timeval stop_time; 68 | 69 | osal_getrelativetime(&start_time); 70 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 71 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 72 | timeradd(&start_time, &timeout, &stop_time); 73 | 74 | self->stop_time.sec = stop_time.tv_sec; 75 | self->stop_time.usec = stop_time.tv_usec; 76 | } 77 | 78 | boolean osal_timer_is_expired (osal_timert * self) 79 | { 80 | struct timeval current_time; 81 | struct timeval stop_time; 82 | int is_not_yet_expired; 83 | 84 | osal_getrelativetime(¤t_time); 85 | stop_time.tv_sec = self->stop_time.sec; 86 | stop_time.tv_usec = self->stop_time.usec; 87 | is_not_yet_expired = timercmp(¤t_time, &stop_time, <); 88 | 89 | return is_not_yet_expired == FALSE; 90 | } 91 | 92 | void *osal_malloc(size_t size) 93 | { 94 | return malloc(size); 95 | } 96 | 97 | void osal_free(void *ptr) 98 | { 99 | free(ptr); 100 | } 101 | 102 | int osal_thread_create(void *thandle, int stacksize, void *func, void *param) 103 | { 104 | int ret; 105 | pthread_attr_t attr; 106 | pthread_t *threadp; 107 | 108 | threadp = thandle; 109 | pthread_attr_init(&attr); 110 | pthread_attr_setstacksize(&attr, stacksize); 111 | ret = pthread_create(threadp, &attr, func, param); 112 | if(ret < 0) 113 | { 114 | return 0; 115 | } 116 | return 1; 117 | } 118 | 119 | int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param) 120 | { 121 | int ret; 122 | pthread_attr_t attr; 123 | struct sched_param schparam; 124 | pthread_t *threadp; 125 | 126 | threadp = thandle; 127 | pthread_attr_init(&attr); 128 | pthread_attr_setstacksize(&attr, stacksize); 129 | ret = pthread_create(threadp, &attr, func, param); 130 | pthread_attr_destroy(&attr); 131 | if(ret < 0) 132 | { 133 | return 0; 134 | } 135 | memset(&schparam, 0, sizeof(schparam)); 136 | schparam.sched_priority = 40; 137 | ret = pthread_setschedparam(*threadp, SCHED_FIFO, &schparam); 138 | if(ret < 0) 139 | { 140 | return 0; 141 | } 142 | 143 | return 1; 144 | } 145 | -------------------------------------------------------------------------------- /osal/linux/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #define PACKED_BEGIN 25 | #define PACKED __attribute__((__packed__)) 26 | #define PACKED_END 27 | #endif 28 | 29 | #include 30 | #define OSAL_THREAD_HANDLE pthread_t * 31 | #define OSAL_THREAD_FUNC void 32 | #define OSAL_THREAD_FUNC_RT void 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /osal/macosx/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define USECS_PER_SEC 1000000 14 | 15 | int osal_usleep (uint32 usec) 16 | { 17 | struct timespec ts; 18 | ts.tv_sec = usec / USECS_PER_SEC; 19 | ts.tv_nsec = (usec % USECS_PER_SEC) * 1000; 20 | /* usleep is deprecated, use nanosleep instead */ 21 | return nanosleep(&ts, NULL); 22 | } 23 | 24 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz) 25 | { 26 | struct timespec ts; 27 | int return_value; 28 | (void)tz; /* Not used */ 29 | 30 | /* Use clock_gettime to prevent possible live-lock. 31 | * Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust. 32 | * If this function preempts timeadjust and it uses vpage it live-locks. 33 | * Also when using XENOMAI, only clock_gettime is RT safe */ 34 | return_value = clock_gettime(CLOCK_MONOTONIC, &ts); 35 | tv->tv_sec = ts.tv_sec; 36 | tv->tv_usec = ts.tv_nsec / 1000; 37 | return return_value; 38 | } 39 | 40 | ec_timet osal_current_time(void) 41 | { 42 | struct timeval current_time; 43 | ec_timet return_value; 44 | 45 | osal_gettimeofday(¤t_time, 0); 46 | return_value.sec = current_time.tv_sec; 47 | return_value.usec = current_time.tv_usec; 48 | return return_value; 49 | } 50 | 51 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff) 52 | { 53 | if (end->usec < start->usec) { 54 | diff->sec = end->sec - start->sec - 1; 55 | diff->usec = end->usec + 1000000 - start->usec; 56 | } 57 | else { 58 | diff->sec = end->sec - start->sec; 59 | diff->usec = end->usec - start->usec; 60 | } 61 | } 62 | 63 | void osal_timer_start(osal_timert * self, uint32 timeout_usec) 64 | { 65 | struct timeval start_time; 66 | struct timeval timeout; 67 | struct timeval stop_time; 68 | 69 | osal_gettimeofday(&start_time, 0); 70 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 71 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 72 | timeradd(&start_time, &timeout, &stop_time); 73 | 74 | self->stop_time.sec = stop_time.tv_sec; 75 | self->stop_time.usec = stop_time.tv_usec; 76 | } 77 | 78 | boolean osal_timer_is_expired (osal_timert * self) 79 | { 80 | struct timeval current_time; 81 | struct timeval stop_time; 82 | int is_not_yet_expired; 83 | 84 | osal_gettimeofday(¤t_time, 0); 85 | stop_time.tv_sec = self->stop_time.sec; 86 | stop_time.tv_usec = self->stop_time.usec; 87 | is_not_yet_expired = timercmp(¤t_time, &stop_time, <); 88 | 89 | return is_not_yet_expired == FALSE; 90 | } 91 | 92 | void *osal_malloc(size_t size) 93 | { 94 | return malloc(size); 95 | } 96 | 97 | void osal_free(void *ptr) 98 | { 99 | free(ptr); 100 | } 101 | 102 | int osal_thread_create(void *thandle, int stacksize, void *func, void *param) 103 | { 104 | int ret; 105 | pthread_attr_t attr; 106 | pthread_t *threadp; 107 | 108 | threadp = thandle; 109 | pthread_attr_init(&attr); 110 | pthread_attr_setstacksize(&attr, stacksize); 111 | ret = pthread_create(threadp, &attr, func, param); 112 | if(ret < 0) 113 | { 114 | return 0; 115 | } 116 | return 1; 117 | } 118 | 119 | int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param) 120 | { 121 | int ret; 122 | pthread_attr_t attr; 123 | struct sched_param schparam; 124 | pthread_t *threadp; 125 | 126 | threadp = thandle; 127 | pthread_attr_init(&attr); 128 | pthread_attr_setstacksize(&attr, stacksize); 129 | ret = pthread_create(threadp, &attr, func, param); 130 | pthread_attr_destroy(&attr); 131 | if(ret < 0) 132 | { 133 | return 0; 134 | } 135 | memset(&schparam, 0, sizeof(schparam)); 136 | schparam.sched_priority = 40; 137 | ret = pthread_setschedparam(*threadp, SCHED_FIFO, &schparam); 138 | if(ret < 0) 139 | { 140 | return 0; 141 | } 142 | 143 | return 1; 144 | } 145 | -------------------------------------------------------------------------------- /osal/macosx/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #define PACKED_BEGIN 25 | #define PACKED __attribute__((__packed__)) 26 | #define PACKED_END 27 | #endif 28 | 29 | #include 30 | #define OSAL_THREAD_HANDLE pthread_t * 31 | #define OSAL_THREAD_FUNC void 32 | #define OSAL_THREAD_FUNC_RT void 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /osal/osal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_ 7 | #define _osal_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include "osal_defs.h" 15 | #include 16 | 17 | /* General types */ 18 | #ifndef TRUE 19 | #define TRUE 1 20 | #endif 21 | #ifndef FALSE 22 | #define FALSE 0 23 | #endif 24 | typedef uint8_t boolean; 25 | typedef int8_t int8; 26 | typedef int16_t int16; 27 | typedef int32_t int32; 28 | typedef uint8_t uint8; 29 | typedef uint16_t uint16; 30 | typedef uint32_t uint32; 31 | typedef int64_t int64; 32 | typedef uint64_t uint64; 33 | typedef float float32; 34 | typedef double float64; 35 | 36 | typedef struct 37 | { 38 | uint32 sec; /*< Seconds elapsed since the Epoch (Jan 1, 1970) */ 39 | uint32 usec; /*< Microseconds elapsed since last second boundary */ 40 | } ec_timet; 41 | 42 | typedef struct osal_timer 43 | { 44 | ec_timet stop_time; 45 | } osal_timert; 46 | 47 | void osal_timer_start(osal_timert * self, uint32 timeout_us); 48 | boolean osal_timer_is_expired(osal_timert * self); 49 | int osal_usleep(uint32 usec); 50 | ec_timet osal_current_time(void); 51 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff); 52 | int osal_thread_create(void *thandle, int stacksize, void *func, void *param); 53 | int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /osal/rtems/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define USECS_PER_SEC 1000000 14 | 15 | int osal_usleep (uint32 usec) 16 | { 17 | struct timespec ts; 18 | ts.tv_sec = usec / USECS_PER_SEC; 19 | ts.tv_nsec = (usec % USECS_PER_SEC) * 1000; 20 | /* usleep is deprecated, use nanosleep instead */ 21 | return nanosleep(&ts, NULL); 22 | } 23 | 24 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz) 25 | { 26 | struct timespec ts; 27 | int return_value; 28 | (void)tz; /* Not used */ 29 | 30 | /* Use clock_gettime to prevent possible live-lock. 31 | * Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust. 32 | * If this function preempts timeadjust and it uses vpage it live-locks. 33 | * Also when using XENOMAI, only clock_gettime is RT safe */ 34 | return_value = clock_gettime(CLOCK_MONOTONIC, &ts); 35 | tv->tv_sec = ts.tv_sec; 36 | tv->tv_usec = ts.tv_nsec / 1000; 37 | return return_value; 38 | } 39 | 40 | ec_timet osal_current_time(void) 41 | { 42 | struct timeval current_time; 43 | ec_timet return_value; 44 | 45 | osal_gettimeofday(¤t_time, 0); 46 | return_value.sec = current_time.tv_sec; 47 | return_value.usec = current_time.tv_usec; 48 | return return_value; 49 | } 50 | 51 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff) 52 | { 53 | if (end->usec < start->usec) { 54 | diff->sec = end->sec - start->sec - 1; 55 | diff->usec = end->usec + 1000000 - start->usec; 56 | } 57 | else { 58 | diff->sec = end->sec - start->sec; 59 | diff->usec = end->usec - start->usec; 60 | } 61 | } 62 | 63 | void osal_timer_start(osal_timert * self, uint32 timeout_usec) 64 | { 65 | struct timeval start_time; 66 | struct timeval timeout; 67 | struct timeval stop_time; 68 | 69 | osal_gettimeofday(&start_time, 0); 70 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 71 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 72 | timeradd(&start_time, &timeout, &stop_time); 73 | 74 | self->stop_time.sec = stop_time.tv_sec; 75 | self->stop_time.usec = stop_time.tv_usec; 76 | } 77 | 78 | boolean osal_timer_is_expired (osal_timert * self) 79 | { 80 | struct timeval current_time; 81 | struct timeval stop_time; 82 | int is_not_yet_expired; 83 | 84 | osal_gettimeofday(¤t_time, 0); 85 | stop_time.tv_sec = self->stop_time.sec; 86 | stop_time.tv_usec = self->stop_time.usec; 87 | is_not_yet_expired = timercmp(¤t_time, &stop_time, <); 88 | 89 | return is_not_yet_expired == FALSE; 90 | } 91 | 92 | void *osal_malloc(size_t size) 93 | { 94 | return malloc(size); 95 | } 96 | 97 | void osal_free(void *ptr) 98 | { 99 | free(ptr); 100 | } 101 | 102 | int osal_thread_create(void *thandle, int stacksize, void *func, void *param) 103 | { 104 | int ret; 105 | pthread_attr_t attr; 106 | pthread_t *threadp; 107 | 108 | threadp = thandle; 109 | pthread_attr_init(&attr); 110 | pthread_attr_setstacksize(&attr, stacksize); 111 | ret = pthread_create(threadp, &attr, func, param); 112 | if(ret < 0) 113 | { 114 | return 0; 115 | } 116 | return 1; 117 | } 118 | 119 | int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param) 120 | { 121 | int ret; 122 | pthread_attr_t attr; 123 | struct sched_param schparam; 124 | pthread_t *threadp; 125 | 126 | threadp = thandle; 127 | pthread_attr_init(&attr); 128 | pthread_attr_setstacksize(&attr, stacksize); 129 | ret = pthread_create(threadp, &attr, func, param); 130 | pthread_attr_destroy(&attr); 131 | if(ret < 0) 132 | { 133 | return 0; 134 | } 135 | memset(&schparam, 0, sizeof(schparam)); 136 | schparam.sched_priority = 40; 137 | ret = pthread_setschedparam(*threadp, SCHED_FIFO, &schparam); 138 | if(ret < 0) 139 | { 140 | return 0; 141 | } 142 | 143 | return 1; 144 | } 145 | -------------------------------------------------------------------------------- /osal/rtems/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #define PACKED_BEGIN 25 | #define PACKED __attribute__((__packed__)) 26 | #define PACKED_END 27 | #endif 28 | 29 | #include 30 | #define OSAL_THREAD_HANDLE pthread_t * 31 | #define OSAL_THREAD_FUNC void 32 | #define OSAL_THREAD_FUNC_RT void 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /osal/rtk/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define timercmp(a, b, CMP) \ 13 | (((a)->tv_sec == (b)->tv_sec) ? \ 14 | ((a)->tv_usec CMP (b)->tv_usec) : \ 15 | ((a)->tv_sec CMP (b)->tv_sec)) 16 | #define timeradd(a, b, result) \ 17 | do { \ 18 | (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 19 | (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 20 | if ((result)->tv_usec >= 1000000) \ 21 | { \ 22 | ++(result)->tv_sec; \ 23 | (result)->tv_usec -= 1000000; \ 24 | } \ 25 | } while (0) 26 | #define timersub(a, b, result) \ 27 | do { \ 28 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 29 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 30 | if ((result)->tv_usec < 0) { \ 31 | --(result)->tv_sec; \ 32 | (result)->tv_usec += 1000000; \ 33 | } \ 34 | } while (0) 35 | 36 | #define USECS_PER_SEC 1000000 37 | #define USECS_PER_TICK (USECS_PER_SEC / CFG_TICKS_PER_SECOND) 38 | 39 | 40 | /* Workaround for rt-labs defect 776. 41 | * Default implementation of udelay() didn't work correctly when tick was 42 | * shorter than one millisecond. 43 | */ 44 | void udelay (uint32_t us) 45 | { 46 | tick_t ticks = (us / USECS_PER_TICK) + 1; 47 | task_delay (ticks); 48 | } 49 | 50 | int gettimeofday(struct timeval *tp, void *tzp) 51 | { 52 | tick_t tick = tick_get(); 53 | tick_t ticks_left; 54 | 55 | ASSERT (tp != NULL); 56 | 57 | tp->tv_sec = tick / CFG_TICKS_PER_SECOND; 58 | 59 | ticks_left = tick % CFG_TICKS_PER_SECOND; 60 | tp->tv_usec = ticks_left * USECS_PER_TICK; 61 | ASSERT (tp->tv_usec < USECS_PER_SEC); 62 | 63 | return 0; 64 | } 65 | 66 | int osal_usleep (uint32 usec) 67 | { 68 | udelay(usec); 69 | return 0; 70 | } 71 | 72 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz) 73 | { 74 | return gettimeofday(tv, tz); 75 | } 76 | 77 | ec_timet osal_current_time (void) 78 | { 79 | struct timeval current_time; 80 | ec_timet return_value; 81 | 82 | gettimeofday (¤t_time, 0); 83 | return_value.sec = current_time.tv_sec; 84 | return_value.usec = current_time.tv_usec; 85 | return return_value; 86 | } 87 | 88 | void osal_timer_start (osal_timert * self, uint32 timeout_usec) 89 | { 90 | struct timeval start_time; 91 | struct timeval timeout; 92 | struct timeval stop_time; 93 | 94 | gettimeofday (&start_time, 0); 95 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 96 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 97 | timeradd (&start_time, &timeout, &stop_time); 98 | 99 | self->stop_time.sec = stop_time.tv_sec; 100 | self->stop_time.usec = stop_time.tv_usec; 101 | } 102 | 103 | boolean osal_timer_is_expired (osal_timert * self) 104 | { 105 | struct timeval current_time; 106 | struct timeval stop_time; 107 | int is_not_yet_expired; 108 | 109 | gettimeofday (¤t_time, 0); 110 | stop_time.tv_sec = self->stop_time.sec; 111 | stop_time.tv_usec = self->stop_time.usec; 112 | is_not_yet_expired = timercmp (¤t_time, &stop_time, <); 113 | 114 | return is_not_yet_expired == false; 115 | } 116 | 117 | void *osal_malloc(size_t size) 118 | { 119 | return malloc(size); 120 | } 121 | 122 | void osal_free(void *ptr) 123 | { 124 | free(ptr); 125 | } 126 | 127 | int osal_thread_create(void *thandle, int stacksize, void *func, void *param) 128 | { 129 | thandle = task_spawn ("worker", func, 6,stacksize, param); 130 | if(!thandle) 131 | { 132 | return 0; 133 | } 134 | return 1; 135 | } 136 | 137 | int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param) 138 | { 139 | thandle = task_spawn ("worker_rt", func, 15 ,stacksize, param); 140 | if(!thandle) 141 | { 142 | return 0; 143 | } 144 | return 1; 145 | } 146 | -------------------------------------------------------------------------------- /osal/rtk/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #define PACKED_BEGIN 25 | #define PACKED __attribute__((__packed__)) 26 | #define PACKED_END 27 | #endif 28 | 29 | #define OSAL_THREAD_HANDLE task_t * 30 | #define OSAL_THREAD_FUNC void 31 | #define OSAL_THREAD_FUNC_RT void 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /osal/vxworks/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | // define if debug printf is needed 10 | //#define EC_DEBUG 11 | 12 | #ifdef EC_DEBUG 13 | #define EC_PRINT printf 14 | #else 15 | #define EC_PRINT(...) do {} while (0) 16 | #endif 17 | 18 | #ifndef PACKED 19 | #define PACKED_BEGIN 20 | #define PACKED __attribute__((__packed__)) 21 | #define PACKED_END 22 | #endif 23 | 24 | #define OSAL_THREAD_HANDLE TASK_ID 25 | #define OSAL_THREAD_FUNC void 26 | #define OSAL_THREAD_FUNC_RT void 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /osal/win32/osal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include "osal_win32.h" 9 | 10 | static int64_t sysfrequency; 11 | static double qpc2usec; 12 | 13 | #define USECS_PER_SEC 1000000 14 | 15 | int osal_getrelativetime(struct timeval *tv, struct timezone *tz) 16 | { 17 | int64_t wintime, usecs; 18 | if(!sysfrequency) 19 | { 20 | timeBeginPeriod(1); 21 | QueryPerformanceFrequency((LARGE_INTEGER *)&sysfrequency); 22 | qpc2usec = 1000000.0 / sysfrequency; 23 | } 24 | QueryPerformanceCounter((LARGE_INTEGER *)&wintime); 25 | usecs = (int64_t)((double)wintime * qpc2usec); 26 | tv->tv_sec = (long)(usecs / 1000000); 27 | tv->tv_usec = (long)(usecs - (tv->tv_sec * 1000000)); 28 | 29 | return 1; 30 | } 31 | 32 | int osal_gettimeofday(struct timeval *tv, struct timezone *tz) 33 | { 34 | FILETIME system_time; 35 | int64 system_time64, usecs; 36 | 37 | /* The offset variable is required to switch from Windows epoch (January 1, 1601) to 38 | * Unix epoch (January 1, 1970). Number of days between both epochs: 134.774 39 | * 40 | * The time returned by GetSystemTimeAsFileTime() changes in 100 ns steps, so the 41 | * following factors are required for the conversion from days to 100 ns steps: 42 | * 43 | * 86.400 seconds per day; 1.000.000 microseconds per second; 10 * 100 ns per microsecond 44 | */ 45 | int64 offset = -134774LL * 86400LL * 1000000LL * 10LL; 46 | 47 | GetSystemTimeAsFileTime(&system_time); 48 | 49 | system_time64 = ((int64)(system_time.dwHighDateTime) << 32) + (int64)system_time.dwLowDateTime; 50 | system_time64 += offset; 51 | usecs = system_time64 / 10; 52 | 53 | tv->tv_sec = (long)(usecs / 1000000); 54 | tv->tv_usec = (long)(usecs - (tv->tv_sec * 1000000)); 55 | 56 | return 1; 57 | } 58 | 59 | ec_timet osal_current_time (void) 60 | { 61 | struct timeval current_time; 62 | ec_timet return_value; 63 | 64 | osal_gettimeofday (¤t_time, 0); 65 | return_value.sec = current_time.tv_sec; 66 | return_value.usec = current_time.tv_usec; 67 | return return_value; 68 | } 69 | 70 | void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff) 71 | { 72 | if (end->usec < start->usec) { 73 | diff->sec = end->sec - start->sec - 1; 74 | diff->usec = end->usec + 1000000 - start->usec; 75 | } 76 | else { 77 | diff->sec = end->sec - start->sec; 78 | diff->usec = end->usec - start->usec; 79 | } 80 | } 81 | 82 | void osal_timer_start (osal_timert *self, uint32 timeout_usec) 83 | { 84 | struct timeval start_time; 85 | struct timeval timeout; 86 | struct timeval stop_time; 87 | 88 | osal_getrelativetime (&start_time, 0); 89 | timeout.tv_sec = timeout_usec / USECS_PER_SEC; 90 | timeout.tv_usec = timeout_usec % USECS_PER_SEC; 91 | timeradd (&start_time, &timeout, &stop_time); 92 | 93 | self->stop_time.sec = stop_time.tv_sec; 94 | self->stop_time.usec = stop_time.tv_usec; 95 | } 96 | 97 | boolean osal_timer_is_expired (osal_timert *self) 98 | { 99 | struct timeval current_time; 100 | struct timeval stop_time; 101 | int is_not_yet_expired; 102 | 103 | osal_getrelativetime (¤t_time, 0); 104 | stop_time.tv_sec = self->stop_time.sec; 105 | stop_time.tv_usec = self->stop_time.usec; 106 | is_not_yet_expired = timercmp (¤t_time, &stop_time, <); 107 | 108 | return is_not_yet_expired == FALSE; 109 | } 110 | 111 | int osal_usleep(uint32 usec) 112 | { 113 | osal_timert qtime; 114 | osal_timer_start(&qtime, usec); 115 | if(usec >= 1000) 116 | { 117 | SleepEx(usec / 1000, FALSE); 118 | } 119 | while(!osal_timer_is_expired(&qtime)); 120 | return 1; 121 | } 122 | 123 | void *osal_malloc(size_t size) 124 | { 125 | return malloc(size); 126 | } 127 | 128 | void osal_free(void *ptr) 129 | { 130 | free(ptr); 131 | } 132 | 133 | int osal_thread_create(void **thandle, int stacksize, void *func, void *param) 134 | { 135 | *thandle = CreateThread(NULL, stacksize, func, param, 0, NULL); 136 | if(!thandle) 137 | { 138 | return 0; 139 | } 140 | return 1; 141 | } 142 | 143 | int osal_thread_create_rt(void **thandle, int stacksize, void *func, void *param) 144 | { 145 | int ret; 146 | ret = osal_thread_create(thandle, stacksize, func, param); 147 | if (ret) 148 | { 149 | ret = SetThreadPriority(*thandle, THREAD_PRIORITY_TIME_CRITICAL); 150 | } 151 | return ret; 152 | } 153 | -------------------------------------------------------------------------------- /osal/win32/osal_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_defs_ 7 | #define _osal_defs_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | // define if debug printf is needed 15 | //#define EC_DEBUG 16 | 17 | #ifdef EC_DEBUG 18 | #define EC_PRINT printf 19 | #else 20 | #define EC_PRINT(...) do {} while (0) 21 | #endif 22 | 23 | #ifndef PACKED 24 | #define PACKED_BEGIN __pragma(pack(push, 1)) 25 | #define PACKED 26 | #define PACKED_END __pragma(pack(pop)) 27 | #endif 28 | 29 | #define OSAL_THREAD_HANDLE HANDLE 30 | #define OSAL_THREAD_FUNC void 31 | #define OSAL_THREAD_FUNC_RT void 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /osal/win32/osal_win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #ifndef _osal_win32_ 7 | #define _osal_win32_ 8 | 9 | /* Convenience macros for operations on timevals. 10 | NOTE: `timercmp' does not work for >= or <=. */ 11 | # define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 12 | # define timeradd(a, b, result) \ 13 | do { \ 14 | (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 15 | (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 16 | if ((result)->tv_usec >= 1000000) \ 17 | { \ 18 | ++(result)->tv_sec; \ 19 | (result)->tv_usec -= 1000000; \ 20 | } \ 21 | } while (0) 22 | # define timersub(a, b, result) \ 23 | do { \ 24 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 25 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 26 | if ((result)->tv_usec < 0) { \ 27 | --(result)->tv_sec; \ 28 | (result)->tv_usec += 1000000; \ 29 | } \ 30 | } while (0) 31 | 32 | int osal_gettimeofday (struct timeval *tv, struct timezone *tz); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /oshw/erika/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | typedef struct 20 | { 21 | /** socket connection used */ 22 | int *sock; 23 | /** tx buffer */ 24 | ec_bufT (*txbuf)[EC_MAXBUF]; 25 | /** tx buffer lengths */ 26 | int (*txbuflength)[EC_MAXBUF]; 27 | /** temporary receive buffer */ 28 | ec_bufT *tempbuf; 29 | /** rx buffers */ 30 | ec_bufT (*rxbuf)[EC_MAXBUF]; 31 | /** rx buffer status fields */ 32 | int (*rxbufstat)[EC_MAXBUF]; 33 | /** received MAC source address (middle word) */ 34 | int (*rxsa)[EC_MAXBUF]; 35 | } ec_stackT; 36 | 37 | /** pointer structure to buffers for redundant port */ 38 | typedef struct 39 | { 40 | ec_stackT stack; 41 | int sockhandle; 42 | /** rx buffers */ 43 | ec_bufT rxbuf[EC_MAXBUF]; 44 | /** rx buffer status */ 45 | int rxbufstat[EC_MAXBUF]; 46 | /** rx MAC source address */ 47 | int rxsa[EC_MAXBUF]; 48 | /** temporary rx buffer */ 49 | ec_bufT tempinbuf; 50 | } ecx_redportt; 51 | 52 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 53 | typedef struct 54 | { 55 | ec_stackT stack; 56 | int sockhandle; 57 | /** rx buffers */ 58 | ec_bufT rxbuf[EC_MAXBUF]; 59 | /** rx buffer status */ 60 | int rxbufstat[EC_MAXBUF]; 61 | /** rx MAC source address */ 62 | int rxsa[EC_MAXBUF]; 63 | /** temporary rx buffer */ 64 | ec_bufT tempinbuf; 65 | /** temporary rx buffer status */ 66 | int tempinbufs; 67 | /** transmit buffers */ 68 | ec_bufT txbuf[EC_MAXBUF]; 69 | /** transmit buffer lengths */ 70 | int txbuflength[EC_MAXBUF]; 71 | /** temporary tx buffer */ 72 | ec_bufT txbuf2; 73 | /** temporary tx buffer length */ 74 | int txbuflength2; 75 | /** last used frame index */ 76 | uint8 lastidx; 77 | /** current redundancy state */ 78 | int redstate; 79 | /** pointer to redundancy port and buffers */ 80 | ecx_redportt *redport; 81 | 82 | /** Device id in the device pool */ 83 | int dev_id; 84 | 85 | // TODO: add mutex support 86 | } ecx_portt; 87 | 88 | extern const uint16 priMAC[3]; 89 | extern const uint16 secMAC[3]; 90 | 91 | #ifdef EC_VER1 92 | extern ecx_portt ecx_port; 93 | extern ecx_redportt ecx_redport; 94 | 95 | int ec_setupnic(const char * ifname, int secondary); 96 | int ec_closenic(void); 97 | void ec_setbufstat(uint8 idx, int bufstat); 98 | uint8 ec_getindex(void); 99 | int ec_outframe(uint8 idx, int sock); 100 | int ec_outframe_red(uint8 idx); 101 | int ec_waitinframe(uint8 idx, int timeout); 102 | int ec_srconfirm(uint8 idx,int timeout); 103 | int ec_inframe(uint8 idx, int stacknumber); 104 | #endif 105 | 106 | void ec_setupheader(void *p); 107 | int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary); 108 | int ecx_closenic(ecx_portt *port); 109 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 110 | uint8 ecx_getindex(ecx_portt *port); 111 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 112 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 113 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 114 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 115 | 116 | int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /oshw/erika/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "oshw.h" 12 | #include "intel_i210.h" 13 | #include "ethercat.h" 14 | 15 | #if !defined(__gnu_linux__) 16 | #include 17 | #else 18 | #include 19 | #define __htons(x) htobe16(x) 20 | #define __ntohs(x) be16toh(x) 21 | #endif 22 | 23 | ec_adaptert adapters [DEVS_MAX_NB]; 24 | 25 | /** 26 | * Host to Network byte order (i.e. to big endian). 27 | * 28 | * Note that Ethercat uses little endian byte order, except for the Ethernet 29 | * header which is big endian as usual. 30 | */ 31 | inline uint16 oshw_htons(uint16 host) 32 | { 33 | // __htons() is provided by the bare-metal x86 compiler 34 | return __htons(host); 35 | } 36 | 37 | /** 38 | * Network (i.e. big endian) to Host byte order. 39 | * 40 | * Note that Ethercat uses little endian byte order, except for the Ethernet 41 | * header which is big endian as usual. 42 | */ 43 | inline uint16 oshw_ntohs(uint16 network) 44 | { 45 | // __ntohs() is provided by the bare-metal x86 compiler 46 | return __ntohs(network); 47 | } 48 | 49 | /** Create list over available network adapters. 50 | * @return First element in linked list of adapters 51 | */ 52 | ec_adaptert* oshw_find_adapters(void) 53 | { 54 | ec_adaptert *ret = NULL; 55 | if (eth_discover_devices() >= 0) { 56 | for (int i = 0;; ++i) { 57 | struct eth_device *dev = eth_get_device(i); 58 | if (dev == NULL) { 59 | adapters[i-1].next = NULL; 60 | break; 61 | } 62 | strncpy(adapters[i].name, dev->name, MAX_DEVICE_NAME); 63 | adapters[i].next = &adapters[i+1]; 64 | } 65 | ret = &(adapters[0]); 66 | } 67 | return ret; 68 | } 69 | 70 | /** Free memory allocated memory used by adapter collection. 71 | * @param[in] adapter = First element in linked list of adapters 72 | * EC_NOFRAME. 73 | */ 74 | void oshw_free_adapters(ec_adaptert *adapter) 75 | { 76 | } 77 | 78 | extern int ec_slavecount; 79 | 80 | -------------------------------------------------------------------------------- /oshw/erika/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ethercattype.h" 19 | #include "nicdrv.h" 20 | #include "ethercatmain.h" 21 | 22 | uint16 oshw_htons(uint16 hostshort); 23 | uint16 oshw_ntohs(uint16 networkshort); 24 | ec_adaptert* oshw_find_adapters(void); 25 | void oshw_free_adapters(ec_adaptert * adapter); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /oshw/intime/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #define HAVE_REMOTE 15 | 16 | #include 17 | #include "hpeif2.h" 18 | 19 | /** pointer structure to Tx and Rx stacks */ 20 | typedef struct 21 | { 22 | /** socket connection used */ 23 | int *sock; 24 | /** tx buffer */ 25 | ec_bufT (*txbuf)[EC_MAXBUF]; 26 | /** tx buffer lengths */ 27 | int (*txbuflength)[EC_MAXBUF]; 28 | /** temporary receive buffer */ 29 | ec_bufT *tempbuf; 30 | /** rx buffers */ 31 | ec_bufT (*rxbuf)[EC_MAXBUF]; 32 | /** rx buffer status fields */ 33 | int (*rxbufstat)[EC_MAXBUF]; 34 | /** received MAC source address (middle word) */ 35 | int (*rxsa)[EC_MAXBUF]; 36 | } ec_stackT; 37 | 38 | typedef struct 39 | { 40 | ec_stackT stack; 41 | /** rx buffers */ 42 | ec_bufT rxbuf[EC_MAXBUF]; 43 | /** rx buffer status */ 44 | int rxbufstat[EC_MAXBUF]; 45 | /** rx MAC source address */ 46 | int rxsa[EC_MAXBUF]; 47 | /** temporary rx buffer */ 48 | ec_bufT tempinbuf; 49 | /* Intime */ 50 | HPEHANDLE handle; 51 | HPERXBUFFERSET *rx_buffers; 52 | HPETXBUFFERSET *tx_buffers[EC_MAXBUF]; 53 | } ecx_redportt; 54 | 55 | typedef struct 56 | { 57 | ec_stackT stack; 58 | /** rx buffers */ 59 | ec_bufT rxbuf[EC_MAXBUF]; 60 | /** rx buffer status */ 61 | int rxbufstat[EC_MAXBUF]; 62 | /** rx MAC source address */ 63 | int rxsa[EC_MAXBUF]; 64 | /** temporary rx buffer */ 65 | ec_bufT tempinbuf; 66 | /** temporary rx buffer status */ 67 | int tempinbufs; 68 | /** transmit buffers */ 69 | ec_bufT txbuf[EC_MAXBUF]; 70 | /** transmit buffer lengths */ 71 | int txbuflength[EC_MAXBUF]; 72 | /** temporary tx buffer */ 73 | ec_bufT txbuf2; 74 | /** temporary tx buffer length */ 75 | int txbuflength2; 76 | /** last used frame index */ 77 | uint8 lastidx; 78 | /** current redundancy state */ 79 | int redstate; 80 | /** pointer to redundancy port and buffers */ 81 | ecx_redportt *redport; 82 | RTHANDLE getindex_region; 83 | RTHANDLE tx_region; 84 | RTHANDLE rx_region; 85 | /* Intime */ 86 | HPEHANDLE handle; 87 | HPERXBUFFERSET *rx_buffers; 88 | HPETXBUFFERSET *tx_buffers[EC_MAXBUF]; 89 | } ecx_portt; 90 | 91 | extern const uint16 priMAC[3]; 92 | extern const uint16 secMAC[3]; 93 | 94 | //extern ecx_portt ecx_port; 95 | //extern ecx_redportt ecx_redport; 96 | 97 | int ec_setupnic(const char * ifname, int secondary); 98 | int ec_closenic(void); 99 | void ec_setupheader(void *p); 100 | void ec_setbufstat(uint8 idx, int bufstat); 101 | uint8 ec_getindex(void); 102 | int ec_outframe(uint8 idx, int sock); 103 | int ec_outframe_red(uint8 idx); 104 | int ec_waitinframe(uint8 idx, int timeout); 105 | int ec_srconfirm(uint8 idx,int timeout); 106 | 107 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 108 | int ecx_closenic(ecx_portt *port); 109 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 110 | uint8 ecx_getindex(ecx_portt *port); 111 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 112 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 113 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 114 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /oshw/intime/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include "oshw.h" 8 | 9 | /** 10 | * Host to Network byte order (i.e. to big endian). 11 | * 12 | * Note that Ethercat uses little endian byte order, except for the Ethernet 13 | * header which is big endian as usual. 14 | */ 15 | uint16 oshw_htons (uint16 host) 16 | { 17 | uint16 network = htons (host); 18 | return network; 19 | } 20 | 21 | /** 22 | * Network (i.e. big endian) to Host byte order. 23 | * 24 | * Note that Ethercat uses little endian byte order, except for the Ethernet 25 | * header which is big endian as usual. 26 | */ 27 | uint16 oshw_ntohs (uint16 network) 28 | { 29 | uint16 host = ntohs (network); 30 | return host; 31 | } 32 | 33 | /* Create list over available network adapters. 34 | * @return First element in linked list of adapters 35 | */ 36 | ec_adaptert * oshw_find_adapters (void) 37 | { 38 | return NULL; 39 | } 40 | 41 | /** Free memory allocated memory used by adapter collection. 42 | * @param[in] adapter = First element in linked list of adapters 43 | * EC_NOFRAME. 44 | */ 45 | void oshw_free_adapters (ec_adaptert * adapter) 46 | { 47 | 48 | } 49 | -------------------------------------------------------------------------------- /oshw/intime/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for oshw.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #include "ethercattype.h" 15 | #include "ethercatmain.h" 16 | #include "nicdrv.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | uint16 oshw_htons (uint16 hostshort); 23 | uint16 oshw_ntohs (uint16 networkshort); 24 | ec_adaptert * oshw_find_adapters (void); 25 | void oshw_free_adapters (ec_adaptert * adapter); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /oshw/linux/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include 20 | 21 | /** pointer structure to Tx and Rx stacks */ 22 | typedef struct 23 | { 24 | /** socket connection used */ 25 | int *sock; 26 | /** tx buffer */ 27 | ec_bufT (*txbuf)[EC_MAXBUF]; 28 | /** tx buffer lengths */ 29 | int (*txbuflength)[EC_MAXBUF]; 30 | /** temporary receive buffer */ 31 | ec_bufT *tempbuf; 32 | /** rx buffers */ 33 | ec_bufT (*rxbuf)[EC_MAXBUF]; 34 | /** rx buffer status fields */ 35 | int (*rxbufstat)[EC_MAXBUF]; 36 | /** received MAC source address (middle word) */ 37 | int (*rxsa)[EC_MAXBUF]; 38 | } ec_stackT; 39 | 40 | /** pointer structure to buffers for redundant port */ 41 | typedef struct 42 | { 43 | ec_stackT stack; 44 | int sockhandle; 45 | /** rx buffers */ 46 | ec_bufT rxbuf[EC_MAXBUF]; 47 | /** rx buffer status */ 48 | int rxbufstat[EC_MAXBUF]; 49 | /** rx MAC source address */ 50 | int rxsa[EC_MAXBUF]; 51 | /** temporary rx buffer */ 52 | ec_bufT tempinbuf; 53 | } ecx_redportt; 54 | 55 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 56 | typedef struct 57 | { 58 | ec_stackT stack; 59 | int sockhandle; 60 | /** rx buffers */ 61 | ec_bufT rxbuf[EC_MAXBUF]; 62 | /** rx buffer status */ 63 | int rxbufstat[EC_MAXBUF]; 64 | /** rx MAC source address */ 65 | int rxsa[EC_MAXBUF]; 66 | /** temporary rx buffer */ 67 | ec_bufT tempinbuf; 68 | /** temporary rx buffer status */ 69 | int tempinbufs; 70 | /** transmit buffers */ 71 | ec_bufT txbuf[EC_MAXBUF]; 72 | /** transmit buffer lengths */ 73 | int txbuflength[EC_MAXBUF]; 74 | /** temporary tx buffer */ 75 | ec_bufT txbuf2; 76 | /** temporary tx buffer length */ 77 | int txbuflength2; 78 | /** last used frame index */ 79 | uint8 lastidx; 80 | /** current redundancy state */ 81 | int redstate; 82 | /** pointer to redundancy port and buffers */ 83 | ecx_redportt *redport; 84 | pthread_mutex_t getindex_mutex; 85 | pthread_mutex_t tx_mutex; 86 | pthread_mutex_t rx_mutex; 87 | } ecx_portt; 88 | 89 | extern const uint16 priMAC[3]; 90 | extern const uint16 secMAC[3]; 91 | 92 | #ifdef EC_VER1 93 | extern ecx_portt ecx_port; 94 | extern ecx_redportt ecx_redport; 95 | 96 | int ec_setupnic(const char * ifname, int secondary); 97 | int ec_closenic(void); 98 | void ec_setbufstat(uint8 idx, int bufstat); 99 | uint8 ec_getindex(void); 100 | int ec_outframe(uint8 idx, int sock); 101 | int ec_outframe_red(uint8 idx); 102 | int ec_waitinframe(uint8 idx, int timeout); 103 | int ec_srconfirm(uint8 idx,int timeout); 104 | #endif 105 | 106 | void ec_setupheader(void *p); 107 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 108 | int ecx_closenic(ecx_portt *port); 109 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 110 | uint8 ecx_getindex(ecx_portt *port); 111 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 112 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 113 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 114 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /oshw/linux/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "oshw.h" 14 | 15 | /** 16 | * Host to Network byte order (i.e. to big endian). 17 | * 18 | * Note that Ethercat uses little endian byte order, except for the Ethernet 19 | * header which is big endian as usual. 20 | */ 21 | uint16 oshw_htons(uint16 host) 22 | { 23 | uint16 network = htons (host); 24 | return network; 25 | } 26 | 27 | /** 28 | * Network (i.e. big endian) to Host byte order. 29 | * 30 | * Note that Ethercat uses little endian byte order, except for the Ethernet 31 | * header which is big endian as usual. 32 | */ 33 | uint16 oshw_ntohs(uint16 network) 34 | { 35 | uint16 host = ntohs (network); 36 | return host; 37 | } 38 | 39 | /** Create list over available network adapters. 40 | * @return First element in linked list of adapters 41 | */ 42 | ec_adaptert * oshw_find_adapters(void) 43 | { 44 | int i; 45 | struct if_nameindex *ids; 46 | ec_adaptert * adapter; 47 | ec_adaptert * prev_adapter = NULL; 48 | ec_adaptert * ret_adapter = NULL; 49 | 50 | 51 | /* Iterate all devices and create a local copy holding the name and 52 | * description. 53 | */ 54 | 55 | ids = if_nameindex (); 56 | for(i = 0; ids[i].if_index != 0; i++) 57 | { 58 | adapter = (ec_adaptert *)malloc(sizeof(ec_adaptert)); 59 | /* If we got more than one adapter save link list pointer to previous 60 | * adapter. 61 | * Else save as pointer to return. 62 | */ 63 | if (prev_adapter) 64 | { 65 | prev_adapter->next = adapter; 66 | } 67 | else 68 | { 69 | ret_adapter = adapter; 70 | } 71 | 72 | /* fetch description and name, in Linux we use the same on both */ 73 | adapter->next = NULL; 74 | 75 | if (ids[i].if_name) 76 | { 77 | strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 78 | adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 79 | strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 80 | adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 81 | } 82 | else 83 | { 84 | adapter->name[0] = '\0'; 85 | adapter->desc[0] = '\0'; 86 | } 87 | 88 | prev_adapter = adapter; 89 | } 90 | 91 | if_freenameindex (ids); 92 | 93 | return ret_adapter; 94 | } 95 | 96 | /** Free memory allocated memory used by adapter collection. 97 | * @param[in] adapter = First element in linked list of adapters 98 | * EC_NOFRAME. 99 | */ 100 | void oshw_free_adapters(ec_adaptert * adapter) 101 | { 102 | ec_adaptert * next_adapter; 103 | /* Iterate the linked list and free all elements holding 104 | * adapter information 105 | */ 106 | if(adapter) 107 | { 108 | next_adapter = adapter->next; 109 | free (adapter); 110 | while (next_adapter) 111 | { 112 | adapter = next_adapter; 113 | next_adapter = adapter->next; 114 | free (adapter); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /oshw/linux/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ethercattype.h" 19 | #include "nicdrv.h" 20 | #include "ethercatmain.h" 21 | 22 | uint16 oshw_htons(uint16 hostshort); 23 | uint16 oshw_ntohs(uint16 networkshort); 24 | ec_adaptert * oshw_find_adapters(void); 25 | void oshw_free_adapters(ec_adaptert * adapter); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /oshw/macosx/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include 20 | 21 | /** pointer structure to Tx and Rx stacks */ 22 | typedef struct 23 | { 24 | /** socket connection used */ 25 | pcap_t **sock; 26 | /** tx buffer */ 27 | ec_bufT (*txbuf)[EC_MAXBUF]; 28 | /** tx buffer lengths */ 29 | int (*txbuflength)[EC_MAXBUF]; 30 | /** temporary receive buffer */ 31 | ec_bufT *tempbuf; 32 | /** rx buffers */ 33 | ec_bufT (*rxbuf)[EC_MAXBUF]; 34 | /** rx buffer status fields */ 35 | int (*rxbufstat)[EC_MAXBUF]; 36 | /** received MAC source address (middle word) */ 37 | int (*rxsa)[EC_MAXBUF]; 38 | } ec_stackT; 39 | 40 | /** pointer structure to buffers for redundant port */ 41 | typedef struct 42 | { 43 | ec_stackT stack; 44 | pcap_t *sockhandle; 45 | /** rx buffers */ 46 | ec_bufT rxbuf[EC_MAXBUF]; 47 | /** rx buffer status */ 48 | int rxbufstat[EC_MAXBUF]; 49 | /** rx MAC source address */ 50 | int rxsa[EC_MAXBUF]; 51 | /** temporary rx buffer */ 52 | ec_bufT tempinbuf; 53 | } ecx_redportt; 54 | 55 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 56 | typedef struct 57 | { 58 | ec_stackT stack; 59 | pcap_t *sockhandle; 60 | /** rx buffers */ 61 | ec_bufT rxbuf[EC_MAXBUF]; 62 | /** rx buffer status */ 63 | int rxbufstat[EC_MAXBUF]; 64 | /** rx MAC source address */ 65 | int rxsa[EC_MAXBUF]; 66 | /** temporary rx buffer */ 67 | ec_bufT tempinbuf; 68 | /** temporary rx buffer status */ 69 | int tempinbufs; 70 | /** transmit buffers */ 71 | ec_bufT txbuf[EC_MAXBUF]; 72 | /** transmit buffer lenghts */ 73 | int txbuflength[EC_MAXBUF]; 74 | /** temporary tx buffer */ 75 | ec_bufT txbuf2; 76 | /** temporary tx buffer length */ 77 | int txbuflength2; 78 | /** last used frame index */ 79 | uint8 lastidx; 80 | /** current redundancy state */ 81 | int redstate; 82 | /** pointer to redundancy port and buffers */ 83 | ecx_redportt *redport; 84 | pthread_mutex_t getindex_mutex; 85 | pthread_mutex_t tx_mutex; 86 | pthread_mutex_t rx_mutex; 87 | } ecx_portt; 88 | 89 | extern const uint16 priMAC[3]; 90 | extern const uint16 secMAC[3]; 91 | 92 | #ifdef EC_VER1 93 | extern ecx_portt ecx_port; 94 | extern ecx_redportt ecx_redport; 95 | 96 | int ec_setupnic(const char * ifname, int secondary); 97 | int ec_closenic(void); 98 | void ec_setbufstat(uint8 idx, int bufstat); 99 | uint8 ec_getindex(void); 100 | int ec_outframe(uint8 idx, int sock); 101 | int ec_outframe_red(uint8 idx); 102 | int ec_waitinframe(uint8 idx, int timeout); 103 | int ec_srconfirm(uint8 idx,int timeout); 104 | #endif 105 | 106 | void ec_setupheader(void *p); 107 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 108 | int ecx_closenic(ecx_portt *port); 109 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 110 | uint8 ecx_getindex(ecx_portt *port); 111 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 112 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 113 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 114 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /oshw/macosx/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "oshw.h" 14 | 15 | /** 16 | * Host to Network byte order (i.e. to big endian). 17 | * 18 | * Note that Ethercat uses little endian byte order, except for the Ethernet 19 | * header which is big endian as usual. 20 | */ 21 | uint16 oshw_htons(uint16 host) 22 | { 23 | uint16 network = htons (host); 24 | return network; 25 | } 26 | 27 | /** 28 | * Network (i.e. big endian) to Host byte order. 29 | * 30 | * Note that Ethercat uses little endian byte order, except for the Ethernet 31 | * header which is big endian as usual. 32 | */ 33 | uint16 oshw_ntohs(uint16 network) 34 | { 35 | uint16 host = ntohs (network); 36 | return host; 37 | } 38 | 39 | /** Create list over available network adapters. 40 | * @return First element in linked list of adapters 41 | */ 42 | ec_adaptert * oshw_find_adapters(void) 43 | { 44 | int i; 45 | struct if_nameindex *ids; 46 | ec_adaptert * adapter; 47 | ec_adaptert * prev_adapter; 48 | ec_adaptert * ret_adapter = NULL; 49 | 50 | 51 | /* Iterate all devices and create a local copy holding the name and 52 | * description. 53 | */ 54 | 55 | ids = if_nameindex (); 56 | for(i = 0; ids[i].if_index != 0; i++) 57 | { 58 | adapter = (ec_adaptert *)malloc(sizeof(ec_adaptert)); 59 | /* If we got more than one adapter save link list pointer to previous 60 | * adapter. 61 | * Else save as pointer to return. 62 | */ 63 | if (i) 64 | { 65 | prev_adapter->next = adapter; 66 | } 67 | else 68 | { 69 | ret_adapter = adapter; 70 | } 71 | 72 | /* fetch description and name, in macosx we use the same on both */ 73 | adapter->next = NULL; 74 | 75 | if (ids[i].if_name) 76 | { 77 | strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 78 | adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 79 | strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 80 | adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 81 | } 82 | else 83 | { 84 | adapter->name[0] = '\0'; 85 | adapter->desc[0] = '\0'; 86 | } 87 | 88 | prev_adapter = adapter; 89 | } 90 | 91 | if_freenameindex (ids); 92 | 93 | return ret_adapter; 94 | } 95 | 96 | /** Free memory allocated memory used by adapter collection. 97 | * @param[in] adapter = First element in linked list of adapters 98 | * EC_NOFRAME. 99 | */ 100 | void oshw_free_adapters(ec_adaptert * adapter) 101 | { 102 | ec_adaptert * next_adapter; 103 | /* Iterate the linked list and free all elements holding 104 | * adapter information 105 | */ 106 | if(adapter) 107 | { 108 | next_adapter = adapter->next; 109 | free (adapter); 110 | while (next_adapter) 111 | { 112 | adapter = next_adapter; 113 | next_adapter = adapter->next; 114 | free (adapter); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /oshw/macosx/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ethercattype.h" 19 | #include "nicdrv.h" 20 | #include "ethercatmain.h" 21 | 22 | uint16 oshw_htons(uint16 hostshort); 23 | uint16 oshw_ntohs(uint16 networkshort); 24 | ec_adaptert * oshw_find_adapters(void); 25 | void oshw_free_adapters(ec_adaptert * adapter); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /oshw/rtems/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include 20 | 21 | /** pointer structure to Tx and Rx stacks */ 22 | typedef struct 23 | { 24 | /** socket connection used */ 25 | int *sock; 26 | /** tx buffer */ 27 | ec_bufT (*txbuf)[EC_MAXBUF]; 28 | /** tx buffer lengths */ 29 | int (*txbuflength)[EC_MAXBUF]; 30 | /** temporary receive buffer */ 31 | ec_bufT *tempbuf; 32 | /** rx buffers */ 33 | ec_bufT (*rxbuf)[EC_MAXBUF]; 34 | /** rx buffer status fields */ 35 | int (*rxbufstat)[EC_MAXBUF]; 36 | /** received MAC source address (middle word) */ 37 | int (*rxsa)[EC_MAXBUF]; 38 | } ec_stackT; 39 | 40 | /** pointer structure to buffers for redundant port */ 41 | typedef struct 42 | { 43 | ec_stackT stack; 44 | int sockhandle; 45 | /** rx buffers */ 46 | ec_bufT rxbuf[EC_MAXBUF]; 47 | /** rx buffer status */ 48 | int rxbufstat[EC_MAXBUF]; 49 | /** rx MAC source address */ 50 | int rxsa[EC_MAXBUF]; 51 | /** temporary rx buffer */ 52 | ec_bufT tempinbuf; 53 | } ecx_redportt; 54 | 55 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 56 | typedef struct 57 | { 58 | ec_stackT stack; 59 | int sockhandle; 60 | /** rx buffers */ 61 | ec_bufT rxbuf[EC_MAXBUF]; 62 | /** rx buffer status */ 63 | int rxbufstat[EC_MAXBUF]; 64 | /** rx MAC source address */ 65 | int rxsa[EC_MAXBUF]; 66 | /** temporary rx buffer */ 67 | ec_bufT tempinbuf; 68 | /** temporary rx buffer status */ 69 | int tempinbufs; 70 | /** transmit buffers */ 71 | ec_bufT txbuf[EC_MAXBUF]; 72 | /** transmit buffer lengths */ 73 | int txbuflength[EC_MAXBUF]; 74 | /** temporary tx buffer */ 75 | ec_bufT txbuf2; 76 | /** temporary tx buffer length */ 77 | int txbuflength2; 78 | /** last used frame index */ 79 | uint8 lastidx; 80 | /** current redundancy state */ 81 | int redstate; 82 | /** pointer to redundancy port and buffers */ 83 | ecx_redportt *redport; 84 | pthread_mutex_t getindex_mutex; 85 | pthread_mutex_t tx_mutex; 86 | pthread_mutex_t rx_mutex; 87 | } ecx_portt; 88 | 89 | extern const uint16 priMAC[3]; 90 | extern const uint16 secMAC[3]; 91 | 92 | #ifdef EC_VER1 93 | extern ecx_portt ecx_port; 94 | extern ecx_redportt ecx_redport; 95 | 96 | int ec_setupnic(const char * ifname, int secondary); 97 | int ec_closenic(void); 98 | void ec_setbufstat(uint8 idx, int bufstat); 99 | uint8 ec_getindex(void); 100 | int ec_outframe(uint8 idx, int sock); 101 | int ec_outframe_red(uint8 idx); 102 | int ec_waitinframe(uint8 idx, int timeout); 103 | int ec_srconfirm(uint8 idx,int timeout); 104 | #endif 105 | 106 | void ec_setupheader(void *p); 107 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 108 | int ecx_closenic(ecx_portt *port); 109 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 110 | uint8 ecx_getindex(ecx_portt *port); 111 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 112 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 113 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 114 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /oshw/rtems/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "oshw.h" 14 | 15 | /** 16 | * Host to Network byte order (i.e. to big endian). 17 | * 18 | * Note that Ethercat uses little endian byte order, except for the Ethernet 19 | * header which is big endian as usual. 20 | */ 21 | uint16 oshw_htons(uint16 host) 22 | { 23 | uint16 network = htons (host); 24 | return network; 25 | } 26 | 27 | /** 28 | * Network (i.e. big endian) to Host byte order. 29 | * 30 | * Note that Ethercat uses little endian byte order, except for the Ethernet 31 | * header which is big endian as usual. 32 | */ 33 | uint16 oshw_ntohs(uint16 network) 34 | { 35 | uint16 host = ntohs (network); 36 | return host; 37 | } 38 | 39 | /** Create list over available network adapters. 40 | * @return First element in linked list of adapters 41 | */ 42 | ec_adaptert * oshw_find_adapters(void) 43 | { 44 | int i; 45 | struct if_nameindex *ids; 46 | ec_adaptert * adapter; 47 | ec_adaptert * prev_adapter; 48 | ec_adaptert * ret_adapter = NULL; 49 | 50 | 51 | /* Iterate all devices and create a local copy holding the name and 52 | * description. 53 | */ 54 | 55 | ids = if_nameindex (); 56 | for(i = 0; ids[i].if_index != 0; i++) 57 | { 58 | adapter = (ec_adaptert *)malloc(sizeof(ec_adaptert)); 59 | /* If we got more than one adapter save link list pointer to previous 60 | * adapter. 61 | * Else save as pointer to return. 62 | */ 63 | if (i) 64 | { 65 | prev_adapter->next = adapter; 66 | } 67 | else 68 | { 69 | ret_adapter = adapter; 70 | } 71 | 72 | /* fetch description and name, in rtems we use the same on both */ 73 | adapter->next = NULL; 74 | 75 | if (ids[i].if_name) 76 | { 77 | strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 78 | adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 79 | strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME); 80 | adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 81 | } 82 | else 83 | { 84 | adapter->name[0] = '\0'; 85 | adapter->desc[0] = '\0'; 86 | } 87 | 88 | prev_adapter = adapter; 89 | } 90 | 91 | if_freenameindex (ids); 92 | 93 | return ret_adapter; 94 | } 95 | 96 | /** Free memory allocated memory used by adapter collection. 97 | * @param[in] adapter = First element in linked list of adapters 98 | * EC_NOFRAME. 99 | */ 100 | void oshw_free_adapters(ec_adaptert * adapter) 101 | { 102 | ec_adaptert * next_adapter; 103 | /* Iterate the linked list and free all elements holding 104 | * adapter information 105 | */ 106 | if(adapter) 107 | { 108 | next_adapter = adapter->next; 109 | free (adapter); 110 | while (next_adapter) 111 | { 112 | adapter = next_adapter; 113 | next_adapter = adapter->next; 114 | free (adapter); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /oshw/rtems/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ethercattype.h" 19 | #include "nicdrv.h" 20 | #include "ethercatmain.h" 21 | 22 | uint16 oshw_htons(uint16 hostshort); 23 | uint16 oshw_ntohs(uint16 networkshort); 24 | ec_adaptert * oshw_find_adapters(void); 25 | void oshw_free_adapters(ec_adaptert * adapter); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /oshw/rtk/fec/fec_ecat.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * * *** *** 3 | * *** *** *** 4 | * *** **** ********** *** ***** *** **** ***** 5 | * ********* ********** *** ********* ************ ********* 6 | * **** *** *** *** *** **** *** 7 | * *** *** ****** *** *********** *** **** ***** 8 | * *** *** ****** *** ************* *** **** ***** 9 | * *** **** **** *** *** *** **** *** 10 | * *** ******* ***** ************** ************* ********* 11 | * *** ***** *** ******* ** ** ****** ***** 12 | * t h e r e a l t i m e t a r g e t e x p e r t s 13 | * 14 | * http://www.rt-labs.com 15 | * Copyright (C) 2007. rt-labs AB, Sweden. All rights reserved. 16 | *------------------------------------------------------------------------------ 17 | * $Id: fec_ecat.h 91 2014-04-02 13:32:29Z rtlfrm $ 18 | *------------------------------------------------------------------------------ 19 | */ 20 | 21 | /** 22 | * \defgroup fec EtherCat Ethernet MAC driver for Frescale K60 SoCs. 23 | * 24 | * \{ 25 | */ 26 | 27 | #ifndef FEC_H 28 | #define FEC_H 29 | 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | typedef struct fec_mac_address 38 | { 39 | uint8_t octet[6]; 40 | } fec_mac_address_t; 41 | 42 | int fec_ecat_init (const fec_mac_address_t * mac_address, bool phy_loopback_mode); 43 | 44 | int fec_ecat_send (const void *payload, size_t tot_len); 45 | 46 | int fec_ecat_recv (void * buffer, size_t buffer_length); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* FEC_H */ 53 | 54 | /** 55 | * \} 56 | */ 57 | -------------------------------------------------------------------------------- /oshw/rtk/lw_mac/lw_emac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * author: Tomas Vestelind 3 | */ 4 | 5 | #ifndef LWIP_MAC_H 6 | #define LWIP_MAC_H 7 | 8 | int bfin_EMAC_init(uint8_t *enetaddr); 9 | int bfin_EMAC_send(void *packet, int length); 10 | int bfin_EMAC_recv(uint8_t * packet, size_t size); 11 | 12 | #endif /* LWIP_MAC_H */ 13 | -------------------------------------------------------------------------------- /oshw/rtk/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | /** pointer structure to Tx and Rx stacks */ 15 | typedef struct 16 | { 17 | /** socket connection used */ 18 | int *sock; 19 | /** tx buffer */ 20 | ec_bufT (*txbuf)[EC_MAXBUF]; 21 | /** tx buffer lengths */ 22 | int (*txbuflength)[EC_MAXBUF]; 23 | /** temporary receive buffer */ 24 | ec_bufT *tempbuf; 25 | /** rx buffers */ 26 | ec_bufT (*rxbuf)[EC_MAXBUF]; 27 | /** rx buffer status fields */ 28 | int (*rxbufstat)[EC_MAXBUF]; 29 | /** received MAC source address (middle word) */ 30 | int (*rxsa)[EC_MAXBUF]; 31 | } ec_stackT; 32 | 33 | /** pointer structure to buffers for redundant port */ 34 | typedef struct 35 | { 36 | ec_stackT stack; 37 | int sockhandle; 38 | /** rx buffers */ 39 | ec_bufT rxbuf[EC_MAXBUF]; 40 | /** rx buffer status */ 41 | int rxbufstat[EC_MAXBUF]; 42 | /** rx MAC source address */ 43 | int rxsa[EC_MAXBUF]; 44 | /** temporary rx buffer */ 45 | ec_bufT tempinbuf; 46 | } ecx_redportt; 47 | 48 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 49 | typedef struct 50 | { 51 | ec_stackT stack; 52 | int sockhandle; 53 | /** rx buffers */ 54 | ec_bufT rxbuf[EC_MAXBUF]; 55 | /** rx buffer status */ 56 | int rxbufstat[EC_MAXBUF]; 57 | /** rx MAC source address */ 58 | int rxsa[EC_MAXBUF]; 59 | /** temporary rx buffer */ 60 | ec_bufT tempinbuf; 61 | /** temporary rx buffer status */ 62 | int tempinbufs; 63 | /** transmit buffers */ 64 | ec_bufT txbuf[EC_MAXBUF]; 65 | /** transmit buffer lengths */ 66 | int txbuflength[EC_MAXBUF]; 67 | /** temporary tx buffer */ 68 | ec_bufT txbuf2; 69 | /** temporary tx buffer length */ 70 | int txbuflength2; 71 | /** last used frame index */ 72 | uint8 lastidx; 73 | /** current redundancy state */ 74 | int redstate; 75 | /** pointer to redundancy port and buffers */ 76 | ecx_redportt *redport; 77 | mtx_t * getindex_mutex; 78 | mtx_t * tx_mutex; 79 | mtx_t * rx_mutex; 80 | } ecx_portt; 81 | 82 | extern const uint16 priMAC[3]; 83 | extern const uint16 secMAC[3]; 84 | 85 | #ifdef EC_VER1 86 | extern ecx_portt ecx_port; 87 | extern ecx_redportt ecx_redport; 88 | 89 | int ec_setupnic(const char * ifname, int secondary); 90 | int ec_closenic(void); 91 | void ec_setbufstat(uint8 idx, int bufstat); 92 | uint8 ec_getindex(void); 93 | int ec_outframe(uint8 idx, int stacknumber); 94 | int ec_outframe_red(uint8 idx); 95 | int ec_waitinframe(uint8 idx, int timeout); 96 | int ec_srconfirm(uint8 idx,int timeout); 97 | #endif 98 | 99 | void ec_setupheader(void *p); 100 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 101 | int ecx_closenic(ecx_portt *port); 102 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 103 | uint8 ecx_getindex(ecx_portt *port); 104 | int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber); 105 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 106 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 107 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /oshw/rtk/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include "oshw.h" 7 | #include 8 | #include 9 | 10 | /** 11 | * Host to Network byte order (i.e. to big endian). 12 | * 13 | * Note that Ethercat uses little endian byte order, except for the Ethernet 14 | * header which is big endian as usual. 15 | */ 16 | uint16 oshw_htons(const uint16 host) 17 | { 18 | uint16 network = htons (host); 19 | return network; 20 | } 21 | 22 | /** 23 | * Network (i.e. big endian) to Host byte order. 24 | * 25 | * Note that Ethercat uses little endian byte order, except for the Ethernet 26 | * header which is big endian as usual. 27 | */ 28 | uint16 oshw_ntohs(const uint16 network) 29 | { 30 | uint16 host = ntohs (network); 31 | return host; 32 | } 33 | 34 | /* Create list over available network adapters. 35 | * @return First element in linked list of adapters 36 | */ 37 | ec_adaptert * oshw_find_adapters(void) 38 | { 39 | ec_adaptert * ret_adapter = NULL; 40 | 41 | /* TODO if needed */ 42 | 43 | return ret_adapter; 44 | } 45 | 46 | /** Free memory allocated memory used by adapter collection. 47 | * @param[in] adapter = First element in linked list of adapters 48 | * EC_NOFRAME. 49 | */ 50 | void oshw_free_adapters(ec_adaptert * adapter) 51 | { 52 | /* TODO if needed */ 53 | } 54 | -------------------------------------------------------------------------------- /oshw/rtk/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for oshw.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include 20 | #include "ethercattype.h" 21 | #include "nicdrv.h" 22 | #include "ethercatmain.h" 23 | 24 | 25 | uint16 oshw_htons(uint16 host); 26 | uint16 oshw_ntohs(uint16 network); 27 | 28 | ec_adaptert * oshw_find_adapters(void); 29 | void oshw_free_adapters(ec_adaptert * adapter); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /oshw/vxworks/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include 20 | 21 | /** structure to connect EtherCAT stack and VxWorks device */ 22 | typedef struct ETHERCAT_PKT_DEV 23 | { 24 | struct ecx_port *port; 25 | void *pCookie; 26 | void *endObj; 27 | UINT32 redundant; 28 | UINT32 tx_count; 29 | UINT32 rx_count; 30 | UINT32 overrun_count; 31 | UINT32 abandoned_count; 32 | }ETHERCAT_PKT_DEV; 33 | 34 | /** pointer structure to Tx and Rx stacks */ 35 | typedef struct 36 | { 37 | /** tx buffer */ 38 | ec_bufT (*txbuf)[EC_MAXBUF]; 39 | /** tx buffer lengths */ 40 | int (*txbuflength)[EC_MAXBUF]; 41 | /** rx buffers */ 42 | ec_bufT (*rxbuf)[EC_MAXBUF]; 43 | /** rx buffer status fields */ 44 | int (*rxbufstat)[EC_MAXBUF]; 45 | /** received MAC source address (middle word) */ 46 | int (*rxsa)[EC_MAXBUF]; 47 | } ec_stackT; 48 | 49 | /** pointer structure to buffers for redundant port */ 50 | typedef struct ecx_redport 51 | { 52 | /** Stack reference */ 53 | ec_stackT stack; 54 | /** Packet device instance */ 55 | ETHERCAT_PKT_DEV pktDev; 56 | /** rx buffers */ 57 | ec_bufT rxbuf[EC_MAXBUF]; 58 | /** rx buffer status */ 59 | int rxbufstat[EC_MAXBUF]; 60 | /** rx MAC source address */ 61 | int rxsa[EC_MAXBUF]; 62 | /** MSG Q for receive callbacks to post into */ 63 | MSG_Q_ID msgQId[EC_MAXBUF]; 64 | } ecx_redportt; 65 | 66 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 67 | typedef struct ecx_port 68 | { 69 | /** Stack reference */ 70 | ec_stackT stack; 71 | /** Packet device instance */ 72 | ETHERCAT_PKT_DEV pktDev; 73 | /** rx buffers */ 74 | ec_bufT rxbuf[EC_MAXBUF]; 75 | /** rx buffer status */ 76 | int rxbufstat[EC_MAXBUF]; 77 | /** rx MAC source address */ 78 | int rxsa[EC_MAXBUF]; 79 | /** transmit buffers */ 80 | ec_bufT txbuf[EC_MAXBUF]; 81 | /** transmit buffer lengths */ 82 | int txbuflength[EC_MAXBUF]; 83 | /** temporary tx buffer */ 84 | ec_bufT txbuf2; 85 | /** temporary tx buffer length */ 86 | int txbuflength2; 87 | /** last used frame index */ 88 | uint8 lastidx; 89 | /** current redundancy state */ 90 | int redstate; 91 | /** pointer to redundancy port and buffers */ 92 | ecx_redportt *redport; 93 | /** Semaphore to protect single resources */ 94 | SEM_ID sem_get_index; 95 | /** MSG Q for receive callbacks to post into */ 96 | MSG_Q_ID msgQId[EC_MAXBUF]; 97 | } ecx_portt; 98 | 99 | extern const uint16 priMAC[3]; 100 | extern const uint16 secMAC[3]; 101 | 102 | #ifdef EC_VER1 103 | extern ecx_portt ecx_port; 104 | extern ecx_redportt ecx_redport; 105 | 106 | int ec_setupnic(const char * ifname, int secondary); 107 | int ec_closenic(void); 108 | void ec_setbufstat(uint8 idx, int bufstat); 109 | uint8 ec_getindex(void); 110 | int ec_outframe(uint8 idx, int sock); 111 | int ec_outframe_red(uint8 idx); 112 | int ec_waitinframe(uint8 idx, int timeout); 113 | int ec_srconfirm(uint8 idx,int timeout); 114 | #endif 115 | 116 | void ec_setupheader(void *p); 117 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 118 | int ecx_closenic(ecx_portt *port); 119 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 120 | uint8 ecx_getindex(ecx_portt *port); 121 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 122 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 123 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 124 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /oshw/vxworks/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "oshw.h" 15 | 16 | /** 17 | * Host to Network byte order (i.e. to big endian). 18 | * 19 | * Note that Ethercat uses little endian byte order, except for the Ethernet 20 | * header which is big endian as usual. 21 | */ 22 | uint16 oshw_htons(uint16 host) 23 | { 24 | uint16 network = htons (host); 25 | return network; 26 | } 27 | 28 | /** 29 | * Network (i.e. big endian) to Host byte order. 30 | * 31 | * Note that Ethercat uses little endian byte order, except for the Ethernet 32 | * header which is big endian as usual. 33 | */ 34 | uint16 oshw_ntohs(uint16 network) 35 | { 36 | uint16 host = ntohs (network); 37 | return host; 38 | } 39 | 40 | /** Create list over available network adapters. 41 | * @return First element in linked list of adapters 42 | */ 43 | ec_adaptert * oshw_find_adapters(void) 44 | { 45 | ec_adaptert * ret_adapter = NULL; 46 | /* Not implemented */ 47 | assert(0); 48 | 49 | return ret_adapter; 50 | } 51 | 52 | /** Free memory allocated memory used by adapter collection. 53 | * @param[in] adapter = First element in linked list of adapters 54 | * EC_NOFRAME. 55 | */ 56 | void oshw_free_adapters(ec_adaptert * adapter) 57 | { 58 | /* Not implemented */ 59 | assert(0); 60 | } 61 | -------------------------------------------------------------------------------- /oshw/vxworks/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for oshw.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #include "ethercattype.h" 15 | #include "nicdrv.h" 16 | #include "ethercatmain.h" 17 | 18 | uint16 oshw_htons(uint16 hostshort); 19 | uint16 oshw_ntohs(uint16 networkshort); 20 | ec_adaptert * oshw_find_adapters(void); 21 | void oshw_free_adapters(ec_adaptert * adapter); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /oshw/win32/nicdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for nicdrv.c 9 | */ 10 | 11 | #ifndef _nicdrvh_ 12 | #define _nicdrvh_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #define HAVE_REMOTE 20 | 21 | #include 22 | #include 23 | 24 | /** pointer structure to Tx and Rx stacks */ 25 | typedef struct 26 | { 27 | /** socket connection used */ 28 | pcap_t **sock; 29 | /** tx buffer */ 30 | ec_bufT (*txbuf)[EC_MAXBUF]; 31 | /** tx buffer lengths */ 32 | int (*txbuflength)[EC_MAXBUF]; 33 | /** temporary receive buffer */ 34 | ec_bufT *tempbuf; 35 | /** rx buffers */ 36 | ec_bufT (*rxbuf)[EC_MAXBUF]; 37 | /** rx buffer status fields */ 38 | int (*rxbufstat)[EC_MAXBUF]; 39 | /** received MAC source address (middle word) */ 40 | int (*rxsa)[EC_MAXBUF]; 41 | } ec_stackT; 42 | 43 | /** pointer structure to buffers for redundant port */ 44 | typedef struct 45 | { 46 | ec_stackT stack; 47 | pcap_t *sockhandle; 48 | /** rx buffers */ 49 | ec_bufT rxbuf[EC_MAXBUF]; 50 | /** rx buffer status */ 51 | int rxbufstat[EC_MAXBUF]; 52 | /** rx MAC source address */ 53 | int rxsa[EC_MAXBUF]; 54 | /** temporary rx buffer */ 55 | ec_bufT tempinbuf; 56 | } ecx_redportt; 57 | 58 | /** pointer structure to buffers, vars and mutexes for port instantiation */ 59 | typedef struct 60 | { 61 | ec_stackT stack; 62 | pcap_t *sockhandle; 63 | /** rx buffers */ 64 | ec_bufT rxbuf[EC_MAXBUF]; 65 | /** rx buffer status */ 66 | int rxbufstat[EC_MAXBUF]; 67 | /** rx MAC source address */ 68 | int rxsa[EC_MAXBUF]; 69 | /** temporary rx buffer */ 70 | ec_bufT tempinbuf; 71 | /** temporary rx buffer status */ 72 | int tempinbufs; 73 | /** transmit buffers */ 74 | ec_bufT txbuf[EC_MAXBUF]; 75 | /** transmit buffer lengths */ 76 | int txbuflength[EC_MAXBUF]; 77 | /** temporary tx buffer */ 78 | ec_bufT txbuf2; 79 | /** temporary tx buffer length */ 80 | int txbuflength2; 81 | /** last used frame index */ 82 | uint8 lastidx; 83 | /** current redundancy state */ 84 | int redstate; 85 | /** pointer to redundancy port and buffers */ 86 | ecx_redportt *redport; 87 | CRITICAL_SECTION getindex_mutex; 88 | CRITICAL_SECTION tx_mutex; 89 | CRITICAL_SECTION rx_mutex; 90 | } ecx_portt; 91 | 92 | extern const uint16 priMAC[3]; 93 | extern const uint16 secMAC[3]; 94 | 95 | #ifdef EC_VER1 96 | extern ecx_portt ecx_port; 97 | extern ecx_redportt ecx_redport; 98 | 99 | int ec_setupnic(const char * ifname, int secondary); 100 | int ec_closenic(void); 101 | void ec_setbufstat(uint8 idx, int bufstat); 102 | uint8 ec_getindex(void); 103 | int ec_outframe(uint8 idx, int sock); 104 | int ec_outframe_red(uint8 idx); 105 | int ec_waitinframe(uint8 idx, int timeout); 106 | int ec_srconfirm(uint8 idx,int timeout); 107 | #endif 108 | 109 | void ec_setupheader(void *p); 110 | int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary); 111 | int ecx_closenic(ecx_portt *port); 112 | void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat); 113 | uint8 ecx_getindex(ecx_portt *port); 114 | int ecx_outframe(ecx_portt *port, uint8 idx, int sock); 115 | int ecx_outframe_red(ecx_portt *port, uint8 idx); 116 | int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout); 117 | int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout); 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /oshw/win32/oshw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | #include "oshw.h" 7 | 8 | /** 9 | * Host to Network byte order (i.e. to big endian). 10 | * 11 | * Note that Ethercat uses little endian byte order, except for the Ethernet 12 | * header which is big endian as usual. 13 | */ 14 | uint16 oshw_htons (uint16 host) 15 | { 16 | uint16 network = htons (host); 17 | return network; 18 | } 19 | 20 | /** 21 | * Network (i.e. big endian) to Host byte order. 22 | * 23 | * Note that Ethercat uses little endian byte order, except for the Ethernet 24 | * header which is big endian as usual. 25 | */ 26 | uint16 oshw_ntohs (uint16 network) 27 | { 28 | uint16 host = ntohs (network); 29 | return host; 30 | } 31 | 32 | /* Create list over available network adapters. 33 | * @return First element in linked list of adapters 34 | */ 35 | ec_adaptert * oshw_find_adapters (void) 36 | { 37 | int i = 0; 38 | int ret = 0; 39 | pcap_if_t *alldevs; 40 | pcap_if_t *d; 41 | ec_adaptert * adapter; 42 | ec_adaptert * prev_adapter; 43 | ec_adaptert * ret_adapter = NULL; 44 | char errbuf[PCAP_ERRBUF_SIZE]; 45 | 46 | /* find all devices */ 47 | if (pcap_findalldevs(&alldevs, errbuf) == -1) 48 | { 49 | fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf); 50 | return (NULL); 51 | } 52 | /* Iterate all devices and create a local copy holding the name and 53 | * description. 54 | */ 55 | for(d= alldevs; d != NULL; d= d->next) 56 | { 57 | adapter = (ec_adaptert *)malloc(sizeof(ec_adaptert)); 58 | /* If we got more than one adapter save link list pointer to previous 59 | * adapter. 60 | * Else save as pointer to return. 61 | */ 62 | if (i) 63 | { 64 | prev_adapter->next = adapter; 65 | } 66 | else 67 | { 68 | ret_adapter = adapter; 69 | } 70 | 71 | /* fetch description and name of the device from libpcap */ 72 | adapter->next = NULL; 73 | if (d->name) 74 | { 75 | strncpy(adapter->name, d->name, EC_MAXLEN_ADAPTERNAME); 76 | adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 77 | } 78 | else 79 | { 80 | adapter->name[0] = '\0'; 81 | } 82 | if (d->description) 83 | { 84 | strncpy(adapter->desc, d->description, EC_MAXLEN_ADAPTERNAME); 85 | adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0'; 86 | } 87 | else 88 | { 89 | adapter->desc[0] = '\0'; 90 | } 91 | prev_adapter = adapter; 92 | i++; 93 | } 94 | /* free all devices allocated */ 95 | pcap_freealldevs(alldevs); 96 | 97 | return ret_adapter; 98 | } 99 | 100 | /** Free memory allocated memory used by adapter collection. 101 | * @param[in] adapter = First element in linked list of adapters 102 | * EC_NOFRAME. 103 | */ 104 | void oshw_free_adapters (ec_adaptert * adapter) 105 | { 106 | ec_adaptert * next_adapter; 107 | /* Iterate the linked list and free all elements holding 108 | * adapter information 109 | */ 110 | if(adapter) 111 | { 112 | next_adapter = adapter->next; 113 | free (adapter); 114 | while (next_adapter) 115 | { 116 | adapter = next_adapter; 117 | next_adapter = adapter->next; 118 | free (adapter); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /oshw/win32/oshw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _oshw_ 12 | #define _oshw_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include "ethercattype.h" 20 | #include "nicdrv.h" 21 | #include "ethercatmain.h" 22 | 23 | uint16 oshw_htons (uint16 hostshort); 24 | uint16 oshw_ntohs (uint16 networkshort); 25 | ec_adaptert * oshw_find_adapters (void); 26 | void oshw_free_adapters (ec_adaptert * adapter); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/Win32-Extensions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #ifndef __WIN32_EXTENSIONS_H__ 35 | #define __WIN32_EXTENSIONS_H__ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Definitions */ 42 | 43 | /*! 44 | \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). 45 | */ 46 | struct pcap_send_queue 47 | { 48 | u_int maxlen; ///< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field. 49 | u_int len; ///< Current size of the queue, in bytes. 50 | char *buffer; ///< Buffer containing the packets to be sent. 51 | }; 52 | 53 | typedef struct pcap_send_queue pcap_send_queue; 54 | 55 | /*! 56 | \brief This typedef is a support for the pcap_get_airpcap_handle() function 57 | */ 58 | #if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) 59 | #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ 60 | typedef struct _AirpcapHandle *PAirpcapHandle; 61 | #endif 62 | 63 | #define BPF_MEM_EX_IMM 0xc0 64 | #define BPF_MEM_EX_IND 0xe0 65 | 66 | /*used for ST*/ 67 | #define BPF_MEM_EX 0xc0 68 | #define BPF_TME 0x08 69 | 70 | #define BPF_LOOKUP 0x90 71 | #define BPF_EXECUTE 0xa0 72 | #define BPF_INIT 0xb0 73 | #define BPF_VALIDATE 0xc0 74 | #define BPF_SET_ACTIVE 0xd0 75 | #define BPF_RESET 0xe0 76 | #define BPF_SET_MEMORY 0x80 77 | #define BPF_GET_REGISTER_VALUE 0x70 78 | #define BPF_SET_REGISTER_VALUE 0x60 79 | #define BPF_SET_WORKING 0x50 80 | #define BPF_SET_ACTIVE_READ 0x40 81 | #define BPF_SET_AUTODELETION 0x30 82 | #define BPF_SEPARATION 0xff 83 | 84 | /* Prototypes */ 85 | pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); 86 | 87 | void pcap_sendqueue_destroy(pcap_send_queue* queue); 88 | 89 | int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); 90 | 91 | u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); 92 | 93 | HANDLE pcap_getevent(pcap_t *p); 94 | 95 | struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); 96 | 97 | int pcap_setuserbuffer(pcap_t *p, int size); 98 | 99 | int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); 100 | 101 | int pcap_live_dump_ended(pcap_t *p, int sync); 102 | 103 | int pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data); 104 | 105 | int pcap_start_oem(char* err_str, int flags); 106 | 107 | PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif //__WIN32_EXTENSIONS_H__ 114 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/bittypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 WIDE Project. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | #ifndef _BITTYPES_H 30 | #define _BITTYPES_H 31 | 32 | #ifndef HAVE_U_INT8_T 33 | 34 | #if SIZEOF_CHAR == 1 35 | typedef unsigned char u_int8_t; 36 | typedef signed char int8_t; 37 | #elif SIZEOF_INT == 1 38 | typedef unsigned int u_int8_t; 39 | typedef signed int int8_t; 40 | #else /* XXX */ 41 | #error "there's no appropriate type for u_int8_t" 42 | #endif 43 | #define HAVE_U_INT8_T 1 44 | #define HAVE_INT8_T 1 45 | 46 | #endif /* HAVE_U_INT8_T */ 47 | 48 | #ifndef HAVE_U_INT16_T 49 | 50 | #if SIZEOF_SHORT == 2 51 | typedef unsigned short u_int16_t; 52 | typedef signed short int16_t; 53 | #elif SIZEOF_INT == 2 54 | typedef unsigned int u_int16_t; 55 | typedef signed int int16_t; 56 | #elif SIZEOF_CHAR == 2 57 | typedef unsigned char u_int16_t; 58 | typedef signed char int16_t; 59 | #else /* XXX */ 60 | #error "there's no appropriate type for u_int16_t" 61 | #endif 62 | #define HAVE_U_INT16_T 1 63 | #define HAVE_INT16_T 1 64 | 65 | #endif /* HAVE_U_INT16_T */ 66 | 67 | #ifndef HAVE_U_INT32_T 68 | 69 | #if SIZEOF_INT == 4 70 | typedef unsigned int u_int32_t; 71 | typedef signed int int32_t; 72 | #elif SIZEOF_LONG == 4 73 | typedef unsigned long u_int32_t; 74 | typedef signed long int32_t; 75 | #elif SIZEOF_SHORT == 4 76 | typedef unsigned short u_int32_t; 77 | typedef signed short int32_t; 78 | #else /* XXX */ 79 | #error "there's no appropriate type for u_int32_t" 80 | #endif 81 | #define HAVE_U_INT32_T 1 82 | #define HAVE_INT32_T 1 83 | 84 | #endif /* HAVE_U_INT32_T */ 85 | 86 | #ifndef HAVE_U_INT64_T 87 | #if SIZEOF_LONG_LONG == 8 88 | typedef unsigned long long u_int64_t; 89 | typedef long long int64_t; 90 | #elif defined(_MSC_EXTENSIONS) 91 | typedef unsigned _int64 u_int64_t; 92 | typedef _int64 int64_t; 93 | #elif SIZEOF_INT == 8 94 | typedef unsigned int u_int64_t; 95 | #elif SIZEOF_LONG == 8 96 | typedef unsigned long u_int64_t; 97 | #elif SIZEOF_SHORT == 8 98 | typedef unsigned short u_int64_t; 99 | #else /* XXX */ 100 | #error "there's no appropriate type for u_int64_t" 101 | #endif 102 | 103 | #endif /* HAVE_U_INT64_T */ 104 | 105 | #ifndef PRId64 106 | #ifdef _MSC_EXTENSIONS 107 | #define PRId64 "I64d" 108 | #else /* _MSC_EXTENSIONS */ 109 | #define PRId64 "lld" 110 | #endif /* _MSC_EXTENSIONS */ 111 | #endif /* PRId64 */ 112 | 113 | #ifndef PRIo64 114 | #ifdef _MSC_EXTENSIONS 115 | #define PRIo64 "I64o" 116 | #else /* _MSC_EXTENSIONS */ 117 | #define PRIo64 "llo" 118 | #endif /* _MSC_EXTENSIONS */ 119 | #endif /* PRIo64 */ 120 | 121 | #ifndef PRIx64 122 | #ifdef _MSC_EXTENSIONS 123 | #define PRIx64 "I64x" 124 | #else /* _MSC_EXTENSIONS */ 125 | #define PRIx64 "llx" 126 | #endif /* _MSC_EXTENSIONS */ 127 | #endif /* PRIx64 */ 128 | 129 | #ifndef PRIu64 130 | #ifdef _MSC_EXTENSIONS 131 | #define PRIu64 "I64u" 132 | #else /* _MSC_EXTENSIONS */ 133 | #define PRIu64 "llu" 134 | #endif /* _MSC_EXTENSIONS */ 135 | #endif /* PRIu64 */ 136 | 137 | #endif /* _BITTYPES_H */ 138 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap-bpf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from the Stanford/CMU enet packet filter, 6 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8 | * Berkeley Laboratory. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed by the University of 21 | * California, Berkeley and its contributors. 22 | * 4. Neither the name of the University nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | * SUCH DAMAGE. 37 | * 38 | * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.50 2007/04/01 21:43:55 guy Exp $ (LBL) 39 | */ 40 | 41 | /* 42 | * For backwards compatibility. 43 | * 44 | * Note to OS vendors: do NOT get rid of this file! Some applications 45 | * might expect to be able to include . 46 | */ 47 | #include 48 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap-namedb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.13 2006/10/04 18:13:32 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * For backwards compatibility. 38 | * 39 | * Note to OS vendors: do NOT get rid of this file! Some applications 40 | * might expect to be able to include . 41 | */ 42 | #include 43 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap-stdinc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * @(#) $Header: /tcpdump/master/libpcap/pcap-stdinc.h,v 1.10.2.1 2008-10-06 15:38:39 gianluca Exp $ (LBL) 32 | */ 33 | 34 | #define SIZEOF_CHAR 1 35 | #define SIZEOF_SHORT 2 36 | #define SIZEOF_INT 4 37 | #ifndef _MSC_EXTENSIONS 38 | #define SIZEOF_LONG_LONG 8 39 | #endif 40 | 41 | /* 42 | * Avoids a compiler warning in case this was already defined 43 | * (someone defined _WINSOCKAPI_ when including 'windows.h', in order 44 | * to prevent it from including 'winsock.h') 45 | */ 46 | #ifdef _WINSOCKAPI_ 47 | #undef _WINSOCKAPI_ 48 | #endif 49 | #include 50 | 51 | #include 52 | 53 | #include "bittypes.h" 54 | #include 55 | #include 56 | 57 | #ifndef __MINGW32__ 58 | #include "IP6_misc.h" 59 | #endif 60 | 61 | #define caddr_t char* 62 | 63 | #if _MSC_VER < 1500 64 | #define snprintf _snprintf 65 | #define vsnprintf _vsnprintf 66 | #define strdup _strdup 67 | #endif 68 | 69 | #define inline __inline 70 | 71 | #ifdef __MINGW32__ 72 | #include 73 | #else /*__MINGW32__*/ 74 | /* MSVC compiler */ 75 | #ifndef _UINTPTR_T_DEFINED 76 | #ifdef _WIN64 77 | typedef unsigned __int64 uintptr_t; 78 | #else 79 | typedef _W64 unsigned int uintptr_t; 80 | #endif 81 | #define _UINTPTR_T_DEFINED 82 | #endif 83 | 84 | #ifndef _INTPTR_T_DEFINED 85 | #ifdef _WIN64 86 | typedef __int64 intptr_t; 87 | #else 88 | typedef _W64 int intptr_t; 89 | #endif 90 | #define _INTPTR_T_DEFINED 91 | #endif 92 | 93 | #endif /*__MINGW32__*/ 94 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.59 2006/10/04 18:09:22 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * For backwards compatibility. 38 | * 39 | * Note to OS vendors: do NOT get rid of this file! Many applications 40 | * expect to be able to include , and at least some of them 41 | * go through contortions in their configure scripts to try to detect 42 | * OSes that have "helpfully" moved pcap.h to without 43 | * leaving behind a file. 44 | */ 45 | #include 46 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap/bluetooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * bluetooth data struct 31 | * By Paolo Abeni 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap/bluetooth.h,v 1.1 2007/09/22 02:10:17 guy Exp $ 34 | */ 35 | 36 | #ifndef _PCAP_BLUETOOTH_STRUCTS_H__ 37 | #define _PCAP_BLUETOOTH_STRUCTS_H__ 38 | 39 | /* 40 | * Header prepended libpcap to each bluetooth h:4 frame. 41 | * fields are in network byte order 42 | */ 43 | typedef struct _pcap_bluetooth_h4_header { 44 | u_int32_t direction; /* if first bit is set direction is incoming */ 45 | } pcap_bluetooth_h4_header; 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap/namedb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap/namedb.h,v 1.1 2006/10/04 18:09:22 guy Exp $ (LBL) 34 | */ 35 | 36 | #ifndef lib_pcap_namedb_h 37 | #define lib_pcap_namedb_h 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* 44 | * As returned by the pcap_next_etherent() 45 | * XXX this stuff doesn't belong in this interface, but this 46 | * library already must do name to address translation, so 47 | * on systems that don't have support for /etc/ethers, we 48 | * export these hooks since they'll 49 | */ 50 | struct pcap_etherent { 51 | u_char addr[6]; 52 | char name[122]; 53 | }; 54 | #ifndef PCAP_ETHERS_FILE 55 | #define PCAP_ETHERS_FILE "/etc/ethers" 56 | #endif 57 | struct pcap_etherent *pcap_next_etherent(FILE *); 58 | u_char *pcap_ether_hostton(const char*); 59 | u_char *pcap_ether_aton(const char *); 60 | 61 | bpf_u_int32 **pcap_nametoaddr(const char *); 62 | #ifdef INET6 63 | struct addrinfo *pcap_nametoaddrinfo(const char *); 64 | #endif 65 | bpf_u_int32 pcap_nametonetaddr(const char *); 66 | 67 | int pcap_nametoport(const char *, int *, int *); 68 | int pcap_nametoportrange(const char *, int *, int *, int *); 69 | int pcap_nametoproto(const char *); 70 | int pcap_nametoeproto(const char *); 71 | int pcap_nametollc(const char *); 72 | /* 73 | * If a protocol is unknown, PROTO_UNDEF is returned. 74 | * Also, pcap_nametoport() returns the protocol along with the port number. 75 | * If there are ambiguous entried in /etc/services (i.e. domain 76 | * can be either tcp or udp) PROTO_UNDEF is returned. 77 | */ 78 | #define PROTO_UNDEF -1 79 | 80 | /* XXX move these to pcap-int.h? */ 81 | int __pcap_atodn(const char *, bpf_u_int32 *); 82 | int __pcap_atoin(const char *, bpf_u_int32 *); 83 | u_short __pcap_nametodnaddr(const char *); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * Basic USB data struct 31 | * By Paolo Abeni 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.6 2007/09/22 02:06:08 guy Exp $ 34 | */ 35 | 36 | #ifndef _PCAP_USB_STRUCTS_H__ 37 | #define _PCAP_USB_STRUCTS_H__ 38 | 39 | /* 40 | * possible transfer mode 41 | */ 42 | #define URB_TRANSFER_IN 0x80 43 | #define URB_ISOCHRONOUS 0x0 44 | #define URB_INTERRUPT 0x1 45 | #define URB_CONTROL 0x2 46 | #define URB_BULK 0x3 47 | 48 | /* 49 | * possible event type 50 | */ 51 | #define URB_SUBMIT 'S' 52 | #define URB_COMPLETE 'C' 53 | #define URB_ERROR 'E' 54 | 55 | /* 56 | * USB setup header as defined in USB specification. 57 | * Appears at the front of each packet in DLT_USB captures. 58 | */ 59 | typedef struct _usb_setup { 60 | u_int8_t bmRequestType; 61 | u_int8_t bRequest; 62 | u_int16_t wValue; 63 | u_int16_t wIndex; 64 | u_int16_t wLength; 65 | } pcap_usb_setup; 66 | 67 | 68 | /* 69 | * Header prepended by linux kernel to each event. 70 | * Appears at the front of each packet in DLT_USB_LINUX captures. 71 | */ 72 | typedef struct _usb_header { 73 | u_int64_t id; 74 | u_int8_t event_type; 75 | u_int8_t transfer_type; 76 | u_int8_t endpoint_number; 77 | u_int8_t device_address; 78 | u_int16_t bus_id; 79 | char setup_flag;/*if !=0 the urb setup header is not present*/ 80 | char data_flag; /*if !=0 no urb data is present*/ 81 | int64_t ts_sec; 82 | int32_t ts_usec; 83 | int32_t status; 84 | u_int32_t urb_len; 85 | u_int32_t data_len; /* amount of urb data really present in this event*/ 86 | pcap_usb_setup setup; 87 | } pcap_usb_header; 88 | 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Include/pcap/vlan.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap/vlan.h,v 1.1.2.2 2008-08-06 07:45:59 guy Exp $ 34 | */ 35 | 36 | #ifndef lib_pcap_vlan_h 37 | #define lib_pcap_vlan_h 38 | 39 | struct vlan_tag { 40 | u_int16_t vlan_tpid; /* ETH_P_8021Q */ 41 | u_int16_t vlan_tci; /* VLAN TCI */ 42 | }; 43 | 44 | #define VLAN_TAG_LEN 4 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/Packet.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/Packet.lib -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/libpacket.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/libpacket.a -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/libwpcap.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/libwpcap.a -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/wpcap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/wpcap.lib -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/x64/Packet.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/x64/Packet.lib -------------------------------------------------------------------------------- /oshw/win32/wpcap/Lib/x64/wpcap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/oshw/win32/wpcap/Lib/x64/wpcap.lib -------------------------------------------------------------------------------- /soem/ethercat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for all ethercat headers 9 | */ 10 | 11 | #ifndef _EC_ETHERCAT_H 12 | #define _EC_ETHERCAT_H 13 | 14 | #include "ethercattype.h" 15 | #include "nicdrv.h" 16 | #include "ethercatbase.h" 17 | #include "ethercatmain.h" 18 | #include "ethercatdc.h" 19 | #include "ethercatcoe.h" 20 | #include "ethercatfoe.h" 21 | #include "ethercatsoe.h" 22 | #include "ethercateoe.h" 23 | #include "ethercatconfig.h" 24 | #include "ethercatprint.h" 25 | 26 | #endif /* _EC_ETHERCAT_H */ 27 | -------------------------------------------------------------------------------- /soem/ethercatbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatbase.c 9 | */ 10 | 11 | #ifndef _ethercatbase_ 12 | #define _ethercatbase_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data); 20 | uint16 ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data); 21 | int ecx_BWR(ecx_portt *port, uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout); 22 | int ecx_BRD(ecx_portt *port, uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout); 23 | int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 24 | int ecx_ARMW(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 25 | int ecx_FRMW(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 26 | uint16 ecx_APRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout); 27 | int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 28 | uint16 ecx_FPRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout); 29 | int ecx_APWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout); 30 | int ecx_APWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 31 | int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout); 32 | int ecx_FPWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 33 | int ecx_LRW(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout); 34 | int ecx_LRD(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout); 35 | int ecx_LWR(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout); 36 | int ecx_LRWDC(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, uint16 DCrs, int64 *DCtime, int timeout); 37 | 38 | #ifdef EC_VER1 39 | int ec_setupdatagram(void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data); 40 | uint16 ec_adddatagram(void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data); 41 | int ec_BWR(uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout); 42 | int ec_BRD(uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout); 43 | int ec_APRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 44 | int ec_ARMW(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 45 | int ec_FRMW(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 46 | uint16 ec_APRDw(uint16 ADP, uint16 ADO, int timeout); 47 | int ec_FPRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 48 | uint16 ec_FPRDw(uint16 ADP, uint16 ADO, int timeout); 49 | int ec_APWRw(uint16 ADP, uint16 ADO, uint16 data, int timeout); 50 | int ec_APWR(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 51 | int ec_FPWRw(uint16 ADP, uint16 ADO, uint16 data, int timeout); 52 | int ec_FPWR(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout); 53 | int ec_LRW(uint32 LogAdr, uint16 length, void *data, int timeout); 54 | int ec_LRD(uint32 LogAdr, uint16 length, void *data, int timeout); 55 | int ec_LWR(uint32 LogAdr, uint16 length, void *data, int timeout); 56 | int ec_LRWDC(uint32 LogAdr, uint16 length, void *data, uint16 DCrs, int64 *DCtime, int timeout); 57 | #endif 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /soem/ethercatcoe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatcoe.c 9 | */ 10 | 11 | #ifndef _ethercatcoe_ 12 | #define _ethercatcoe_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | /** max entries in Object Description list */ 20 | #define EC_MAXODLIST 1024 21 | 22 | /** max entries in Object Entry list */ 23 | #define EC_MAXOELIST 256 24 | 25 | /* Storage for object description list */ 26 | typedef struct 27 | { 28 | /** slave number */ 29 | uint16 Slave; 30 | /** number of entries in list */ 31 | uint16 Entries; 32 | /** array of indexes */ 33 | uint16 Index[EC_MAXODLIST]; 34 | /** array of datatypes, see EtherCAT specification */ 35 | uint16 DataType[EC_MAXODLIST]; 36 | /** array of object codes, see EtherCAT specification */ 37 | uint8 ObjectCode[EC_MAXODLIST]; 38 | /** number of subindexes for each index */ 39 | uint8 MaxSub[EC_MAXODLIST]; 40 | /** textual description of each index */ 41 | char Name[EC_MAXODLIST][EC_MAXNAME+1]; 42 | } ec_ODlistt; 43 | 44 | /* storage for object list entry information */ 45 | typedef struct 46 | { 47 | /** number of entries in list */ 48 | uint16 Entries; 49 | /** array of value infos, see EtherCAT specification */ 50 | uint8 ValueInfo[EC_MAXOELIST]; 51 | /** array of value infos, see EtherCAT specification */ 52 | uint16 DataType[EC_MAXOELIST]; 53 | /** array of bit lengths, see EtherCAT specification */ 54 | uint16 BitLength[EC_MAXOELIST]; 55 | /** array of object access bits, see EtherCAT specification */ 56 | uint16 ObjAccess[EC_MAXOELIST]; 57 | /** textual description of each index */ 58 | char Name[EC_MAXOELIST][EC_MAXNAME+1]; 59 | } ec_OElistt; 60 | 61 | #ifdef EC_VER1 62 | void ec_SDOerror(uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode); 63 | int ec_SDOread(uint16 slave, uint16 index, uint8 subindex, 64 | boolean CA, int *psize, void *p, int timeout); 65 | int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex, 66 | boolean CA, int psize, const void *p, int Timeout); 67 | int ec_RxPDO(uint16 Slave, uint16 RxPDOnumber , int psize, const void *p); 68 | int ec_TxPDO(uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout); 69 | int ec_readPDOmap(uint16 Slave, uint32 *Osize, uint32 *Isize); 70 | int ec_readPDOmapCA(uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize); 71 | int ec_readODlist(uint16 Slave, ec_ODlistt *pODlist); 72 | int ec_readODdescription(uint16 Item, ec_ODlistt *pODlist); 73 | int ec_readOEsingle(uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist); 74 | int ec_readOE(uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist); 75 | #endif 76 | 77 | void ecx_SDOerror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode); 78 | int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subindex, 79 | boolean CA, int *psize, void *p, int timeout); 80 | int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIndex, 81 | boolean CA, int psize, const void *p, int Timeout); 82 | int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber , int psize, const void *p); 83 | int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout); 84 | int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, uint32 *Osize, uint32 *Isize); 85 | int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize); 86 | int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist); 87 | int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist); 88 | int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist); 89 | int ecx_readOE(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /soem/ethercatconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatconfig.c 9 | */ 10 | 11 | #ifndef _ethercatconfig_ 12 | #define _ethercatconfig_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #define EC_NODEOFFSET 0x1000 20 | #define EC_TEMPNODE 0xffff 21 | 22 | #ifdef EC_VER1 23 | int ec_config_init(uint8 usetable); 24 | int ec_config_map(void *pIOmap); 25 | int ec_config_overlap_map(void *pIOmap); 26 | int ec_config_map_aligned(void *pIOmap); 27 | int ec_config_map_group(void *pIOmap, uint8 group); 28 | int ec_config_overlap_map_group(void *pIOmap, uint8 group); 29 | int ec_config_map_group_aligned(void *pIOmap, uint8 group); 30 | int ec_config(uint8 usetable, void *pIOmap); 31 | int ec_config_overlap(uint8 usetable, void *pIOmap); 32 | int ec_recover_slave(uint16 slave, int timeout); 33 | int ec_reconfig_slave(uint16 slave, int timeout); 34 | #endif 35 | 36 | int ecx_config_init(ecx_contextt *context, uint8 usetable); 37 | int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group); 38 | int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 group); 39 | int ecx_config_map_group_aligned(ecx_contextt *context, void *pIOmap, uint8 group); 40 | int ecx_recover_slave(ecx_contextt *context, uint16 slave, int timeout); 41 | int ecx_reconfig_slave(ecx_contextt *context, uint16 slave, int timeout); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /soem/ethercatconfiglist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * DEPRECATED Configuration list of known EtherCAT slave devices. 9 | * 10 | * If a slave is found in this list it is configured according to the parameters 11 | * in the list. Otherwise the configuration info is read directly from the slave 12 | * EEPROM (SII or Slave Information Interface). 13 | */ 14 | 15 | #ifndef _ethercatconfiglist_ 16 | #define _ethercatconfiglist_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | /* 24 | explanation of dev: 25 | 1: static device with no IO mapping ie EK1100 26 | 2: input device no mailbox ie simple IO device 27 | 3: output device no mailbox 28 | 4: input device with mailbox configuration 29 | 5: output device with mailbox configuration 30 | 6: input/output device no mailbox 31 | 7: input.output device with mailbox configuration 32 | */ 33 | #define EC_CONFIGEND 0xffffffff 34 | 35 | ec_configlist_t ec_configlist[] = { 36 | {/*Man=*/0x00000000,/*ID=*/0x00000000,/*Name=*/"" ,/*dtype=*/0,/*Ibits=*/ 0,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 37 | {/*Man=*/0x00000002,/*ID=*/0x044c2c52,/*Name=*/"EK1100" ,/*dtype=*/1,/*Ibits=*/ 0,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 38 | {/*Man=*/0x00000002,/*ID=*/0x03ea3052,/*Name=*/"EL1002" ,/*dtype=*/2,/*Ibits=*/ 2,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 39 | {/*Man=*/0x00000002,/*ID=*/0x03ec3052,/*Name=*/"EL1004" ,/*dtype=*/2,/*Ibits=*/ 4,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 40 | {/*Man=*/0x00000002,/*ID=*/0x03f43052,/*Name=*/"EL1012" ,/*dtype=*/2,/*Ibits=*/ 2,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 41 | {/*Man=*/0x00000002,/*ID=*/0x03f63052,/*Name=*/"EL1014" ,/*dtype=*/2,/*Ibits=*/ 4,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 42 | {/*Man=*/0x00000002,/*ID=*/0x03fa3052,/*Name=*/"EL1018" ,/*dtype=*/2,/*Ibits=*/ 8,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 43 | {/*Man=*/0x00000002,/*ID=*/0x07d23052,/*Name=*/"EL2002" ,/*dtype=*/3,/*Ibits=*/ 0,/*Obits=*/ 2,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 44 | {/*Man=*/0x00000002,/*ID=*/0x07d43052,/*Name=*/"EL2004" ,/*dtype=*/3,/*Ibits=*/ 0,/*Obits=*/ 4,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 45 | {/*Man=*/0x00000002,/*ID=*/0x07d83052,/*Name=*/"EL2008" ,/*dtype=*/3,/*Ibits=*/ 0,/*Obits=*/ 8,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 46 | {/*Man=*/0x00000002,/*ID=*/0x07f03052,/*Name=*/"EL2032" ,/*dtype=*/6,/*Ibits=*/ 2,/*Obits=*/ 2,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0}, 47 | {/*Man=*/0x00000002,/*ID=*/0x0c1e3052,/*Name=*/"EL3102" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 48 | {/*Man=*/0x00000002,/*ID=*/0x0c283052,/*Name=*/"EL3112" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 49 | {/*Man=*/0x00000002,/*ID=*/0x0c323052,/*Name=*/"EL3122" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 50 | {/*Man=*/0x00000002,/*ID=*/0x0c463052,/*Name=*/"EL3142" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 51 | {/*Man=*/0x00000002,/*ID=*/0x0c503052,/*Name=*/"EL3152" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 52 | {/*Man=*/0x00000002,/*ID=*/0x0c5a3052,/*Name=*/"EL3162" ,/*dtype=*/4,/*Ibits=*/48,/*Obits=*/ 0,/*SM2a*/0x1000,/*SM2f*/0x00000024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/0,/*FM1ac*/1}, 53 | {/*Man=*/0x00000002,/*ID=*/0x0fc03052,/*Name=*/"EL4032" ,/*dtype=*/5,/*Ibits=*/ 0,/*Obits=*/32,/*SM2a*/0x1100,/*SM2f*/0x00010024,/*SM3a*/0x1180,/*SM3f*/0x00000022,/*FM0ac*/1,/*FM1ac*/0}, 54 | {/*Man=*/0x00000002,/*ID=*/0x10063052,/*Name=*/"EL4102" ,/*dtype=*/5,/*Ibits=*/ 0,/*Obits=*/32,/*SM2a*/0x1000,/*SM2f*/0x00010024,/*SM3a*/0x1100,/*SM3f*/0x00000022,/*FM0ac*/1,/*FM1ac*/0}, 55 | {/*Man=*/0x00000002,/*ID=*/0x10103052,/*Name=*/"EL4112" ,/*dtype=*/5,/*Ibits=*/ 0,/*Obits=*/32,/*SM2a*/0x1000,/*SM2f*/0x00010024,/*SM3a*/0x1100,/*SM3f*/0x00000022,/*FM0ac*/1,/*FM1ac*/0}, 56 | {/*Man=*/0x00000002,/*ID=*/0x101a3052,/*Name=*/"EL4122" ,/*dtype=*/5,/*Ibits=*/ 0,/*Obits=*/32,/*SM2a*/0x1000,/*SM2f*/0x00010024,/*SM3a*/0x1100,/*SM3f*/0x00000022,/*FM0ac*/1,/*FM1ac*/0}, 57 | {/*Man=*/0x00000002,/*ID=*/0x10243052,/*Name=*/"EL4132" ,/*dtype=*/5,/*Ibits=*/ 0,/*Obits=*/32,/*SM2a*/0x1000,/*SM2f*/0x00010024,/*SM3a*/0x1100,/*SM3f*/0x00000022,/*FM0ac*/1,/*FM1ac*/0}, 58 | {/*Man=*/0x00000002,/*ID=*/0x13ed3052,/*Name=*/"EL5101" ,/*dtype=*/7,/*Ibits=*/40,/*Obits=*/24,/*SM2a*/0x1000,/*SM2f*/0x00010024,/*SM3a*/0x1100,/*SM3f*/0x00010020,/*FM0ac*/1,/*FM1ac*/1}, 59 | {/*Man=*/EC_CONFIGEND,/*ID=*/0x00000000,/*Name=*/"" ,/*dtype=*/0,/*Ibits=*/ 0,/*Obits=*/ 0,/*SM2a*/ 0,/*SM2f*/ 0,/*SM3a*/ 0,/*SM3f*/ 0,/*FM0ac*/0,/*FM1ac*/0} 60 | }; 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /soem/ethercatdc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatdc.c 9 | */ 10 | 11 | #ifndef _EC_ECATDC_H 12 | #define _EC_ECATDC_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #ifdef EC_VER1 20 | boolean ec_configdc(); 21 | void ec_dcsync0(uint16 slave, boolean act, uint32 CyclTime, int32 CyclShift); 22 | void ec_dcsync01(uint16 slave, boolean act, uint32 CyclTime0, uint32 CyclTime1, int32 CyclShift); 23 | #endif 24 | 25 | boolean ecx_configdc(ecx_contextt *context); 26 | void ecx_dcsync0(ecx_contextt *context, uint16 slave, boolean act, uint32 CyclTime, int32 CyclShift); 27 | void ecx_dcsync01(ecx_contextt *context, uint16 slave, boolean act, uint32 CyclTime0, uint32 CyclTime1, int32 CyclShift); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* _EC_ECATDC_H */ 34 | -------------------------------------------------------------------------------- /soem/ethercatfoe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatfoe.c 9 | */ 10 | 11 | #ifndef _ethercatfoe_ 12 | #define _ethercatfoe_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #ifdef EC_VER1 20 | int ec_FOEdefinehook(void *hook); 21 | int ec_FOEread(uint16 slave, char *filename, uint32 password, int *psize, void *p, int timeout); 22 | int ec_FOEwrite(uint16 slave, char *filename, uint32 password, int psize, void *p, int timeout); 23 | #endif 24 | 25 | int ecx_FOEdefinehook(ecx_contextt *context, void *hook); 26 | int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 password, int *psize, void *p, int timeout); 27 | int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 password, int psize, void *p, int timeout); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /soem/ethercatprint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatprint.c 9 | */ 10 | 11 | #ifndef _ethercatprint_ 12 | #define _ethercatprint_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | char* ec_sdoerror2string( uint32 sdoerrorcode); 20 | char* ec_ALstatuscode2string( uint16 ALstatuscode); 21 | char* ec_soeerror2string( uint16 errorcode); 22 | char* ec_mbxerror2string( uint16 errorcode); 23 | char* ecx_err2string(const ec_errort Ec); 24 | char* ecx_elist2string(ecx_contextt *context); 25 | 26 | #ifdef EC_VER1 27 | char* ec_elist2string(void); 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /soem/ethercatsoe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the GNU General Public License version 2 with exceptions. See 3 | * LICENSE file in the project root for full license information 4 | */ 5 | 6 | /** \file 7 | * \brief 8 | * Headerfile for ethercatsoe.c 9 | */ 10 | 11 | #ifndef _ethercatsoe_ 12 | #define _ethercatsoe_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #define EC_SOE_DATASTATE_B 0x01 20 | #define EC_SOE_NAME_B 0x02 21 | #define EC_SOE_ATTRIBUTE_B 0x04 22 | #define EC_SOE_UNIT_B 0x08 23 | #define EC_SOE_MIN_B 0x10 24 | #define EC_SOE_MAX_B 0x20 25 | #define EC_SOE_VALUE_B 0x40 26 | #define EC_SOE_DEFAULT_B 0x80 27 | 28 | #define EC_SOE_MAXNAME 60 29 | #define EC_SOE_MAXMAPPING 64 30 | 31 | #define EC_IDN_MDTCONFIG 24 32 | #define EC_IDN_ATCONFIG 16 33 | 34 | /** SoE name structure */ 35 | PACKED_BEGIN 36 | typedef struct PACKED 37 | { 38 | /** current length in bytes of list */ 39 | uint16 currentlength; 40 | /** maximum length in bytes of list */ 41 | uint16 maxlength; 42 | char name[EC_SOE_MAXNAME]; 43 | } ec_SoEnamet; 44 | PACKED_END 45 | 46 | /** SoE list structure */ 47 | PACKED_BEGIN 48 | typedef struct PACKED 49 | { 50 | /** current length in bytes of list */ 51 | uint16 currentlength; 52 | /** maximum length in bytes of list */ 53 | uint16 maxlength; 54 | union 55 | { 56 | uint8 byte[8]; 57 | uint16 word[4]; 58 | uint32 dword[2]; 59 | uint64 lword[1]; 60 | }; 61 | } ec_SoElistt; 62 | PACKED_END 63 | 64 | /** SoE IDN mapping structure */ 65 | PACKED_BEGIN 66 | typedef struct PACKED 67 | { 68 | /** current length in bytes of list */ 69 | uint16 currentlength; 70 | /** maximum length in bytes of list */ 71 | uint16 maxlength; 72 | uint16 idn[EC_SOE_MAXMAPPING]; 73 | } ec_SoEmappingt; 74 | PACKED_END 75 | 76 | #define EC_SOE_LENGTH_1 0x00 77 | #define EC_SOE_LENGTH_2 0x01 78 | #define EC_SOE_LENGTH_4 0x02 79 | #define EC_SOE_LENGTH_8 0x03 80 | #define EC_SOE_TYPE_BINARY 0x00 81 | #define EC_SOE_TYPE_UINT 0x01 82 | #define EC_SOE_TYPE_INT 0x02 83 | #define EC_SOE_TYPE_HEX 0x03 84 | #define EC_SOE_TYPE_STRING 0x04 85 | #define EC_SOE_TYPE_IDN 0x05 86 | #define EC_SOE_TYPE_FLOAT 0x06 87 | #define EC_SOE_TYPE_PARAMETER 0x07 88 | 89 | /** SoE attribute structure */ 90 | PACKED_BEGIN 91 | typedef struct PACKED 92 | { 93 | /** evaluation factor for display purposes */ 94 | uint32 evafactor :16; 95 | /** length of IDN element(s) */ 96 | uint32 length :2; 97 | /** IDN is list */ 98 | uint32 list :1; 99 | /** IDN is command */ 100 | uint32 command :1; 101 | /** datatype */ 102 | uint32 datatype :3; 103 | uint32 reserved1 :1; 104 | /** decimals to display if float datatype */ 105 | uint32 decimals :4; 106 | /** write protected in pre-op */ 107 | uint32 wppreop :1; 108 | /** write protected in safe-op */ 109 | uint32 wpsafeop :1; 110 | /** write protected in op */ 111 | uint32 wpop :1; 112 | uint32 reserved2 :1; 113 | } ec_SoEattributet; 114 | PACKED_END 115 | 116 | #ifdef EC_VER1 117 | int ec_SoEread(uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int *psize, void *p, int timeout); 118 | int ec_SoEwrite(uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int psize, void *p, int timeout); 119 | int ec_readIDNmap(uint16 slave, uint32 *Osize, uint32 *Isize); 120 | #endif 121 | 122 | int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int *psize, void *p, int timeout); 123 | int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int psize, void *p, int timeout); 124 | int ecx_readIDNmap(ecx_contextt *context, uint16 slave, uint32 *Osize, uint32 *Isize); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif -------------------------------------------------------------------------------- /test/linux/eepromtool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCES eepromtool.c) 3 | add_executable(eepromtool ${SOURCES}) 4 | target_link_libraries(eepromtool soem) 5 | install(TARGETS eepromtool DESTINATION bin) 6 | -------------------------------------------------------------------------------- /test/linux/firm_update/firm_update.c: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Example code for Simple Open EtherCAT master 3 | * 4 | * Usage: firm_update ifname1 slave fname 5 | * ifname is NIC interface, f.e. eth0 6 | * slave = slave number in EtherCAT order 1..n 7 | * fname = binary file to store in slave 8 | * CAUTION! Using the wrong file can result in a bricked slave! 9 | * 10 | * This is a slave firmware update test. 11 | * 12 | * (c)Arthur Ketels 2011 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "ethercat.h" 22 | 23 | #define FWBUFSIZE (8 * 1024 * 1024) 24 | 25 | uint8 ob; 26 | uint16 ow; 27 | uint32 data; 28 | char filename[256]; 29 | char filebuffer[FWBUFSIZE]; // 8MB buffer 30 | int filesize; 31 | int j; 32 | uint16 argslave; 33 | 34 | int input_bin(char *fname, int *length) 35 | { 36 | FILE *fp; 37 | 38 | int cc = 0, c; 39 | 40 | fp = fopen(fname, "rb"); 41 | if(fp == NULL) 42 | return 0; 43 | while (((c = fgetc(fp)) != EOF) && (cc < FWBUFSIZE)) 44 | filebuffer[cc++] = (uint8)c; 45 | *length = cc; 46 | fclose(fp); 47 | return 1; 48 | } 49 | 50 | 51 | void boottest(char *ifname, uint16 slave, char *filename) 52 | { 53 | printf("Starting firmware update example\n"); 54 | 55 | /* initialise SOEM, bind socket to ifname */ 56 | if (ec_init(ifname)) 57 | { 58 | printf("ec_init on %s succeeded.\n",ifname); 59 | /* find and auto-config slaves */ 60 | 61 | 62 | if ( ec_config_init(FALSE) > 0 ) 63 | { 64 | printf("%d slaves found and configured.\n",ec_slavecount); 65 | 66 | /* wait for all slaves to reach PRE_OP state */ 67 | ec_statecheck(0, EC_STATE_PRE_OP, EC_TIMEOUTSTATE * 4); 68 | 69 | printf("Request init state for slave %d\n", slave); 70 | ec_slave[slave].state = EC_STATE_INIT; 71 | ec_writestate(slave); 72 | 73 | /* wait for slave to reach INIT state */ 74 | ec_statecheck(slave, EC_STATE_INIT, EC_TIMEOUTSTATE * 4); 75 | printf("Slave %d state to INIT.\n", slave); 76 | 77 | /* read BOOT mailbox data, master -> slave */ 78 | data = ec_readeeprom(slave, ECT_SII_BOOTRXMBX, EC_TIMEOUTEEP); 79 | ec_slave[slave].SM[0].StartAddr = (uint16)LO_WORD(data); 80 | ec_slave[slave].SM[0].SMlength = (uint16)HI_WORD(data); 81 | /* store boot write mailbox address */ 82 | ec_slave[slave].mbx_wo = (uint16)LO_WORD(data); 83 | /* store boot write mailbox size */ 84 | ec_slave[slave].mbx_l = (uint16)HI_WORD(data); 85 | 86 | /* read BOOT mailbox data, slave -> master */ 87 | data = ec_readeeprom(slave, ECT_SII_BOOTTXMBX, EC_TIMEOUTEEP); 88 | ec_slave[slave].SM[1].StartAddr = (uint16)LO_WORD(data); 89 | ec_slave[slave].SM[1].SMlength = (uint16)HI_WORD(data); 90 | /* store boot read mailbox address */ 91 | ec_slave[slave].mbx_ro = (uint16)LO_WORD(data); 92 | /* store boot read mailbox size */ 93 | ec_slave[slave].mbx_rl = (uint16)HI_WORD(data); 94 | 95 | printf(" SM0 A:%4.4x L:%4d F:%8.8x\n", ec_slave[slave].SM[0].StartAddr, ec_slave[slave].SM[0].SMlength, 96 | (int)ec_slave[slave].SM[0].SMflags); 97 | printf(" SM1 A:%4.4x L:%4d F:%8.8x\n", ec_slave[slave].SM[1].StartAddr, ec_slave[slave].SM[1].SMlength, 98 | (int)ec_slave[slave].SM[1].SMflags); 99 | /* program SM0 mailbox in for slave */ 100 | ec_FPWR (ec_slave[slave].configadr, ECT_REG_SM0, sizeof(ec_smt), &ec_slave[slave].SM[0], EC_TIMEOUTRET); 101 | /* program SM1 mailbox out for slave */ 102 | ec_FPWR (ec_slave[slave].configadr, ECT_REG_SM1, sizeof(ec_smt), &ec_slave[slave].SM[1], EC_TIMEOUTRET); 103 | 104 | printf("Request BOOT state for slave %d\n", slave); 105 | ec_slave[slave].state = EC_STATE_BOOT; 106 | ec_writestate(slave); 107 | 108 | /* wait for slave to reach BOOT state */ 109 | if (ec_statecheck(slave, EC_STATE_BOOT, EC_TIMEOUTSTATE * 10) == EC_STATE_BOOT) 110 | { 111 | printf("Slave %d state to BOOT.\n", slave); 112 | 113 | if (input_bin(filename, &filesize)) 114 | { 115 | printf("File read OK, %d bytes.\n",filesize); 116 | printf("FoE write...."); 117 | j = ec_FOEwrite(slave, filename, 0, filesize , &filebuffer, EC_TIMEOUTSTATE); 118 | printf("result %d.\n",j); 119 | printf("Request init state for slave %d\n", slave); 120 | ec_slave[slave].state = EC_STATE_INIT; 121 | ec_writestate(slave); 122 | } 123 | else 124 | printf("File not read OK.\n"); 125 | } 126 | 127 | } 128 | else 129 | { 130 | printf("No slaves found!\n"); 131 | } 132 | printf("End firmware update example, close socket\n"); 133 | /* stop SOEM, close socket */ 134 | ec_close(); 135 | } 136 | else 137 | { 138 | printf("No socket connection on %s\nExcecute as root\n",ifname); 139 | } 140 | } 141 | 142 | int main(int argc, char *argv[]) 143 | { 144 | printf("SOEM (Simple Open EtherCAT Master)\nFirmware update example\n"); 145 | 146 | if (argc > 3) 147 | { 148 | argslave = atoi(argv[2]); 149 | boottest(argv[1], argslave, argv[3]); 150 | } 151 | else 152 | { 153 | printf("Usage: firm_update ifname1 slave fname\n"); 154 | printf("ifname = eth0 for example\n"); 155 | printf("slave = slave number in EtherCAT order 1..n\n"); 156 | printf("fname = binary file to store in slave\n"); 157 | printf("CAUTION! Using the wrong file can result in a bricked slave!\n"); 158 | } 159 | 160 | printf("End program\n"); 161 | return (0); 162 | } 163 | -------------------------------------------------------------------------------- /test/linux/simple_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(soemtest) 3 | 4 | 5 | project(eRob_test LANGUAGES C CXX) 6 | find_package(Threads REQUIRED) 7 | 8 | include_directories(/home/erobman/SOEM_ethercat/install/SOEM/include/soem) 9 | link_directories(/home/erobman/SOEM_ethercat/install/SOEM/lib) 10 | 11 | set(SOURCES simple_test.c) 12 | add_executable(simple_test ${SOURCES}) 13 | target_link_libraries(simple_test soem) 14 | install(TARGETS simple_test DESTINATION bin) 15 | 16 | 17 | 18 | add_executable(eRob_test eRob_test.cpp) 19 | target_link_libraries(eRob_test soem) 20 | install(TARGETS eRob_test DESTINATION bin) 21 | 22 | 23 | add_executable(github_test github.cpp) 24 | target_link_libraries(github_test soem) 25 | install(TARGETS github_test DESTINATION bin) -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-9aa1cbdb6a802b85206c.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "hasInstallRule" : true, 10 | "jsonFile" : "directory-.-Debug-b325d41ce6d3ee02aa0e.json", 11 | "minimumCMakeVersion" : 12 | { 13 | "string" : "3.8" 14 | }, 15 | "projectIndex" : 0, 16 | "source" : ".", 17 | "targetIndexes" : 18 | [ 19 | 0, 20 | 1, 21 | 2 22 | ] 23 | } 24 | ], 25 | "name" : "Debug", 26 | "projects" : 27 | [ 28 | { 29 | "directoryIndexes" : 30 | [ 31 | 0 32 | ], 33 | "name" : "eRob_test", 34 | "targetIndexes" : 35 | [ 36 | 0, 37 | 1, 38 | 2 39 | ] 40 | } 41 | ], 42 | "targets" : 43 | [ 44 | { 45 | "directoryIndex" : 0, 46 | "id" : "eRob_test::@6890427a1f51a3e7e1df", 47 | "jsonFile" : "target-eRob_test-Debug-16138a9a78b739c30419.json", 48 | "name" : "eRob_test", 49 | "projectIndex" : 0 50 | }, 51 | { 52 | "directoryIndex" : 0, 53 | "id" : "github_test::@6890427a1f51a3e7e1df", 54 | "jsonFile" : "target-github_test-Debug-249137b88ece3a0b5028.json", 55 | "name" : "github_test", 56 | "projectIndex" : 0 57 | }, 58 | { 59 | "directoryIndex" : 0, 60 | "id" : "simple_test::@6890427a1f51a3e7e1df", 61 | "jsonFile" : "target-simple_test-Debug-7c03d7d505b4e4e23035.json", 62 | "name" : "simple_test", 63 | "projectIndex" : 0 64 | } 65 | ] 66 | } 67 | ], 68 | "kind" : "codemodel", 69 | "paths" : 70 | { 71 | "build" : "/home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug", 72 | "source" : "/home/erobman/test_project/SOEM-master/test/linux/simple_test" 73 | }, 74 | "version" : 75 | { 76 | "major" : 2, 77 | "minor" : 7 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-b325d41ce6d3ee02aa0e.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : 5 | [ 6 | "install" 7 | ], 8 | "files" : 9 | [ 10 | "CMakeLists.txt" 11 | ], 12 | "nodes" : 13 | [ 14 | { 15 | "file" : 0 16 | }, 17 | { 18 | "command" : 0, 19 | "file" : 0, 20 | "line" : 14, 21 | "parent" : 0 22 | }, 23 | { 24 | "command" : 0, 25 | "file" : 0, 26 | "line" : 20, 27 | "parent" : 0 28 | }, 29 | { 30 | "command" : 0, 31 | "file" : 0, 32 | "line" : 25, 33 | "parent" : 0 34 | } 35 | ] 36 | }, 37 | "installers" : 38 | [ 39 | { 40 | "backtrace" : 1, 41 | "component" : "Unspecified", 42 | "destination" : "bin", 43 | "paths" : 44 | [ 45 | "simple_test" 46 | ], 47 | "targetId" : "simple_test::@6890427a1f51a3e7e1df", 48 | "targetIndex" : 2, 49 | "type" : "target" 50 | }, 51 | { 52 | "backtrace" : 1, 53 | "component" : "Unspecified", 54 | "cxxModuleBmiTarget" : 55 | { 56 | "id" : "simple_test::@6890427a1f51a3e7e1df", 57 | "index" : 2 58 | }, 59 | "destination" : "bin", 60 | "type" : "cxxModuleBmi" 61 | }, 62 | { 63 | "backtrace" : 2, 64 | "component" : "Unspecified", 65 | "destination" : "bin", 66 | "paths" : 67 | [ 68 | "eRob_test" 69 | ], 70 | "targetId" : "eRob_test::@6890427a1f51a3e7e1df", 71 | "targetIndex" : 0, 72 | "type" : "target" 73 | }, 74 | { 75 | "backtrace" : 2, 76 | "component" : "Unspecified", 77 | "cxxModuleBmiTarget" : 78 | { 79 | "id" : "eRob_test::@6890427a1f51a3e7e1df", 80 | "index" : 0 81 | }, 82 | "destination" : "bin", 83 | "type" : "cxxModuleBmi" 84 | }, 85 | { 86 | "backtrace" : 3, 87 | "component" : "Unspecified", 88 | "destination" : "bin", 89 | "paths" : 90 | [ 91 | "github_test" 92 | ], 93 | "targetId" : "github_test::@6890427a1f51a3e7e1df", 94 | "targetIndex" : 1, 95 | "type" : "target" 96 | }, 97 | { 98 | "backtrace" : 3, 99 | "component" : "Unspecified", 100 | "cxxModuleBmiTarget" : 101 | { 102 | "id" : "github_test::@6890427a1f51a3e7e1df", 103 | "index" : 1 104 | }, 105 | "destination" : "bin", 106 | "type" : "cxxModuleBmi" 107 | } 108 | ], 109 | "paths" : 110 | { 111 | "build" : ".", 112 | "source" : "." 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/index-2024-10-23T12-04-06-0220.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake" : 3 | { 4 | "generator" : 5 | { 6 | "multiConfig" : false, 7 | "name" : "Ninja" 8 | }, 9 | "paths" : 10 | { 11 | "cmake" : "/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cmake", 12 | "cpack" : "/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cpack", 13 | "ctest" : "/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/ctest", 14 | "root" : "/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/share/cmake-3.29" 15 | }, 16 | "version" : 17 | { 18 | "isDirty" : false, 19 | "major" : 3, 20 | "minor" : 29, 21 | "patch" : 6, 22 | "string" : "3.29.6", 23 | "suffix" : "" 24 | } 25 | }, 26 | "objects" : 27 | [ 28 | { 29 | "jsonFile" : "codemodel-v2-9aa1cbdb6a802b85206c.json", 30 | "kind" : "codemodel", 31 | "version" : 32 | { 33 | "major" : 2, 34 | "minor" : 7 35 | } 36 | }, 37 | { 38 | "jsonFile" : "cache-v2-f87ad9eea6b44cf17ff1.json", 39 | "kind" : "cache", 40 | "version" : 41 | { 42 | "major" : 2, 43 | "minor" : 0 44 | } 45 | }, 46 | { 47 | "jsonFile" : "cmakeFiles-v1-f9c3ad20eee0b952595f.json", 48 | "kind" : "cmakeFiles", 49 | "version" : 50 | { 51 | "major" : 1, 52 | "minor" : 0 53 | } 54 | }, 55 | { 56 | "jsonFile" : "toolchains-v1-7096c62e23c342eb06a8.json", 57 | "kind" : "toolchains", 58 | "version" : 59 | { 60 | "major" : 1, 61 | "minor" : 0 62 | } 63 | } 64 | ], 65 | "reply" : 66 | { 67 | "cache-v2" : 68 | { 69 | "jsonFile" : "cache-v2-f87ad9eea6b44cf17ff1.json", 70 | "kind" : "cache", 71 | "version" : 72 | { 73 | "major" : 2, 74 | "minor" : 0 75 | } 76 | }, 77 | "cmakeFiles-v1" : 78 | { 79 | "jsonFile" : "cmakeFiles-v1-f9c3ad20eee0b952595f.json", 80 | "kind" : "cmakeFiles", 81 | "version" : 82 | { 83 | "major" : 1, 84 | "minor" : 0 85 | } 86 | }, 87 | "codemodel-v2" : 88 | { 89 | "jsonFile" : "codemodel-v2-9aa1cbdb6a802b85206c.json", 90 | "kind" : "codemodel", 91 | "version" : 92 | { 93 | "major" : 2, 94 | "minor" : 7 95 | } 96 | }, 97 | "toolchains-v1" : 98 | { 99 | "jsonFile" : "toolchains-v1-7096c62e23c342eb06a8.json", 100 | "kind" : "toolchains", 101 | "version" : 102 | { 103 | "major" : 1, 104 | "minor" : 0 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/target-eRob_test-Debug-16138a9a78b739c30419.json: -------------------------------------------------------------------------------- 1 | { 2 | "artifacts" : 3 | [ 4 | { 5 | "path" : "eRob_test" 6 | } 7 | ], 8 | "backtrace" : 1, 9 | "backtraceGraph" : 10 | { 11 | "commands" : 12 | [ 13 | "add_executable", 14 | "install", 15 | "link_directories", 16 | "target_link_libraries", 17 | "include_directories" 18 | ], 19 | "files" : 20 | [ 21 | "CMakeLists.txt" 22 | ], 23 | "nodes" : 24 | [ 25 | { 26 | "file" : 0 27 | }, 28 | { 29 | "command" : 0, 30 | "file" : 0, 31 | "line" : 18, 32 | "parent" : 0 33 | }, 34 | { 35 | "command" : 1, 36 | "file" : 0, 37 | "line" : 20, 38 | "parent" : 0 39 | }, 40 | { 41 | "command" : 2, 42 | "file" : 0, 43 | "line" : 9, 44 | "parent" : 0 45 | }, 46 | { 47 | "command" : 3, 48 | "file" : 0, 49 | "line" : 19, 50 | "parent" : 0 51 | }, 52 | { 53 | "command" : 4, 54 | "file" : 0, 55 | "line" : 8, 56 | "parent" : 0 57 | } 58 | ] 59 | }, 60 | "compileGroups" : 61 | [ 62 | { 63 | "compileCommandFragments" : 64 | [ 65 | { 66 | "fragment" : "-g -fdiagnostics-color=always" 67 | } 68 | ], 69 | "includes" : 70 | [ 71 | { 72 | "backtrace" : 5, 73 | "path" : "/home/erobman/SOEM_ethercat/install/SOEM/include/soem" 74 | } 75 | ], 76 | "language" : "CXX", 77 | "sourceIndexes" : 78 | [ 79 | 0 80 | ] 81 | } 82 | ], 83 | "id" : "eRob_test::@6890427a1f51a3e7e1df", 84 | "install" : 85 | { 86 | "destinations" : 87 | [ 88 | { 89 | "backtrace" : 2, 90 | "path" : "bin" 91 | } 92 | ], 93 | "prefix" : 94 | { 95 | "path" : "/usr/local" 96 | } 97 | }, 98 | "link" : 99 | { 100 | "commandFragments" : 101 | [ 102 | { 103 | "fragment" : "-g", 104 | "role" : "flags" 105 | }, 106 | { 107 | "fragment" : "", 108 | "role" : "flags" 109 | }, 110 | { 111 | "backtrace" : 3, 112 | "fragment" : "-L/home/erobman/SOEM_ethercat/install/SOEM/lib", 113 | "role" : "libraryPath" 114 | }, 115 | { 116 | "fragment" : "-Wl,-rpath,/home/erobman/SOEM_ethercat/install/SOEM/lib:", 117 | "role" : "libraries" 118 | }, 119 | { 120 | "backtrace" : 4, 121 | "fragment" : "-lsoem", 122 | "role" : "libraries" 123 | } 124 | ], 125 | "language" : "CXX" 126 | }, 127 | "name" : "eRob_test", 128 | "nameOnDisk" : "eRob_test", 129 | "paths" : 130 | { 131 | "build" : ".", 132 | "source" : "." 133 | }, 134 | "sourceGroups" : 135 | [ 136 | { 137 | "name" : "Source Files", 138 | "sourceIndexes" : 139 | [ 140 | 0 141 | ] 142 | } 143 | ], 144 | "sources" : 145 | [ 146 | { 147 | "backtrace" : 1, 148 | "compileGroupIndex" : 0, 149 | "path" : "eRob_test.cpp", 150 | "sourceGroupIndex" : 0 151 | } 152 | ], 153 | "type" : "EXECUTABLE" 154 | } 155 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/target-github_test-Debug-249137b88ece3a0b5028.json: -------------------------------------------------------------------------------- 1 | { 2 | "artifacts" : 3 | [ 4 | { 5 | "path" : "github_test" 6 | } 7 | ], 8 | "backtrace" : 1, 9 | "backtraceGraph" : 10 | { 11 | "commands" : 12 | [ 13 | "add_executable", 14 | "install", 15 | "link_directories", 16 | "target_link_libraries", 17 | "include_directories" 18 | ], 19 | "files" : 20 | [ 21 | "CMakeLists.txt" 22 | ], 23 | "nodes" : 24 | [ 25 | { 26 | "file" : 0 27 | }, 28 | { 29 | "command" : 0, 30 | "file" : 0, 31 | "line" : 23, 32 | "parent" : 0 33 | }, 34 | { 35 | "command" : 1, 36 | "file" : 0, 37 | "line" : 25, 38 | "parent" : 0 39 | }, 40 | { 41 | "command" : 2, 42 | "file" : 0, 43 | "line" : 9, 44 | "parent" : 0 45 | }, 46 | { 47 | "command" : 3, 48 | "file" : 0, 49 | "line" : 24, 50 | "parent" : 0 51 | }, 52 | { 53 | "command" : 4, 54 | "file" : 0, 55 | "line" : 8, 56 | "parent" : 0 57 | } 58 | ] 59 | }, 60 | "compileGroups" : 61 | [ 62 | { 63 | "compileCommandFragments" : 64 | [ 65 | { 66 | "fragment" : "-g -fdiagnostics-color=always" 67 | } 68 | ], 69 | "includes" : 70 | [ 71 | { 72 | "backtrace" : 5, 73 | "path" : "/home/erobman/SOEM_ethercat/install/SOEM/include/soem" 74 | } 75 | ], 76 | "language" : "CXX", 77 | "sourceIndexes" : 78 | [ 79 | 0 80 | ] 81 | } 82 | ], 83 | "id" : "github_test::@6890427a1f51a3e7e1df", 84 | "install" : 85 | { 86 | "destinations" : 87 | [ 88 | { 89 | "backtrace" : 2, 90 | "path" : "bin" 91 | } 92 | ], 93 | "prefix" : 94 | { 95 | "path" : "/usr/local" 96 | } 97 | }, 98 | "link" : 99 | { 100 | "commandFragments" : 101 | [ 102 | { 103 | "fragment" : "-g", 104 | "role" : "flags" 105 | }, 106 | { 107 | "fragment" : "", 108 | "role" : "flags" 109 | }, 110 | { 111 | "backtrace" : 3, 112 | "fragment" : "-L/home/erobman/SOEM_ethercat/install/SOEM/lib", 113 | "role" : "libraryPath" 114 | }, 115 | { 116 | "fragment" : "-Wl,-rpath,/home/erobman/SOEM_ethercat/install/SOEM/lib:", 117 | "role" : "libraries" 118 | }, 119 | { 120 | "backtrace" : 4, 121 | "fragment" : "-lsoem", 122 | "role" : "libraries" 123 | } 124 | ], 125 | "language" : "CXX" 126 | }, 127 | "name" : "github_test", 128 | "nameOnDisk" : "github_test", 129 | "paths" : 130 | { 131 | "build" : ".", 132 | "source" : "." 133 | }, 134 | "sourceGroups" : 135 | [ 136 | { 137 | "name" : "Source Files", 138 | "sourceIndexes" : 139 | [ 140 | 0 141 | ] 142 | } 143 | ], 144 | "sources" : 145 | [ 146 | { 147 | "backtrace" : 1, 148 | "compileGroupIndex" : 0, 149 | "path" : "github.cpp", 150 | "sourceGroupIndex" : 0 151 | } 152 | ], 153 | "type" : "EXECUTABLE" 154 | } 155 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/target-simple_test-Debug-7c03d7d505b4e4e23035.json: -------------------------------------------------------------------------------- 1 | { 2 | "artifacts" : 3 | [ 4 | { 5 | "path" : "simple_test" 6 | } 7 | ], 8 | "backtrace" : 1, 9 | "backtraceGraph" : 10 | { 11 | "commands" : 12 | [ 13 | "add_executable", 14 | "install", 15 | "link_directories", 16 | "target_link_libraries", 17 | "include_directories" 18 | ], 19 | "files" : 20 | [ 21 | "CMakeLists.txt" 22 | ], 23 | "nodes" : 24 | [ 25 | { 26 | "file" : 0 27 | }, 28 | { 29 | "command" : 0, 30 | "file" : 0, 31 | "line" : 12, 32 | "parent" : 0 33 | }, 34 | { 35 | "command" : 1, 36 | "file" : 0, 37 | "line" : 14, 38 | "parent" : 0 39 | }, 40 | { 41 | "command" : 2, 42 | "file" : 0, 43 | "line" : 9, 44 | "parent" : 0 45 | }, 46 | { 47 | "command" : 3, 48 | "file" : 0, 49 | "line" : 13, 50 | "parent" : 0 51 | }, 52 | { 53 | "command" : 4, 54 | "file" : 0, 55 | "line" : 8, 56 | "parent" : 0 57 | } 58 | ] 59 | }, 60 | "compileGroups" : 61 | [ 62 | { 63 | "compileCommandFragments" : 64 | [ 65 | { 66 | "fragment" : "-g -fdiagnostics-color=always" 67 | } 68 | ], 69 | "includes" : 70 | [ 71 | { 72 | "backtrace" : 5, 73 | "path" : "/home/erobman/SOEM_ethercat/install/SOEM/include/soem" 74 | } 75 | ], 76 | "language" : "C", 77 | "sourceIndexes" : 78 | [ 79 | 0 80 | ] 81 | } 82 | ], 83 | "id" : "simple_test::@6890427a1f51a3e7e1df", 84 | "install" : 85 | { 86 | "destinations" : 87 | [ 88 | { 89 | "backtrace" : 2, 90 | "path" : "bin" 91 | } 92 | ], 93 | "prefix" : 94 | { 95 | "path" : "/usr/local" 96 | } 97 | }, 98 | "link" : 99 | { 100 | "commandFragments" : 101 | [ 102 | { 103 | "fragment" : "-g", 104 | "role" : "flags" 105 | }, 106 | { 107 | "fragment" : "", 108 | "role" : "flags" 109 | }, 110 | { 111 | "backtrace" : 3, 112 | "fragment" : "-L/home/erobman/SOEM_ethercat/install/SOEM/lib", 113 | "role" : "libraryPath" 114 | }, 115 | { 116 | "fragment" : "-Wl,-rpath,/home/erobman/SOEM_ethercat/install/SOEM/lib:", 117 | "role" : "libraries" 118 | }, 119 | { 120 | "backtrace" : 4, 121 | "fragment" : "-lsoem", 122 | "role" : "libraries" 123 | } 124 | ], 125 | "language" : "C" 126 | }, 127 | "name" : "simple_test", 128 | "nameOnDisk" : "simple_test", 129 | "paths" : 130 | { 131 | "build" : ".", 132 | "source" : "." 133 | }, 134 | "sourceGroups" : 135 | [ 136 | { 137 | "name" : "Source Files", 138 | "sourceIndexes" : 139 | [ 140 | 0 141 | ] 142 | } 143 | ], 144 | "sources" : 145 | [ 146 | { 147 | "backtrace" : 1, 148 | "compileGroupIndex" : 0, 149 | "path" : "simple_test.c", 150 | "sourceGroupIndex" : 0 151 | } 152 | ], 153 | "type" : "EXECUTABLE" 154 | } 155 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-7096c62e23c342eb06a8.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind" : "toolchains", 3 | "toolchains" : 4 | [ 5 | { 6 | "compiler" : 7 | { 8 | "id" : "GNU", 9 | "implicit" : 10 | { 11 | "includeDirectories" : 12 | [ 13 | "/usr/lib/gcc/x86_64-linux-gnu/11/include", 14 | "/usr/local/include", 15 | "/usr/include/x86_64-linux-gnu", 16 | "/usr/include" 17 | ], 18 | "linkDirectories" : 19 | [ 20 | "/usr/lib/gcc/x86_64-linux-gnu/11", 21 | "/usr/lib/x86_64-linux-gnu", 22 | "/usr/lib", 23 | "/lib/x86_64-linux-gnu", 24 | "/lib" 25 | ], 26 | "linkFrameworkDirectories" : [], 27 | "linkLibraries" : 28 | [ 29 | "gcc", 30 | "gcc_s", 31 | "c", 32 | "gcc", 33 | "gcc_s" 34 | ] 35 | }, 36 | "path" : "/usr/bin/cc", 37 | "version" : "11.4.0" 38 | }, 39 | "language" : "C", 40 | "sourceFileExtensions" : 41 | [ 42 | "c", 43 | "m" 44 | ] 45 | }, 46 | { 47 | "compiler" : 48 | { 49 | "id" : "GNU", 50 | "implicit" : 51 | { 52 | "includeDirectories" : 53 | [ 54 | "/usr/include/c++/11", 55 | "/usr/include/x86_64-linux-gnu/c++/11", 56 | "/usr/include/c++/11/backward", 57 | "/usr/lib/gcc/x86_64-linux-gnu/11/include", 58 | "/usr/local/include", 59 | "/usr/include/x86_64-linux-gnu", 60 | "/usr/include" 61 | ], 62 | "linkDirectories" : 63 | [ 64 | "/usr/lib/gcc/x86_64-linux-gnu/11", 65 | "/usr/lib/x86_64-linux-gnu", 66 | "/usr/lib", 67 | "/lib/x86_64-linux-gnu", 68 | "/lib" 69 | ], 70 | "linkFrameworkDirectories" : [], 71 | "linkLibraries" : 72 | [ 73 | "stdc++", 74 | "m", 75 | "gcc_s", 76 | "gcc", 77 | "c", 78 | "gcc_s", 79 | "gcc" 80 | ] 81 | }, 82 | "path" : "/usr/bin/c++", 83 | "version" : "11.4.0" 84 | }, 85 | "language" : "CXX", 86 | "sourceFileExtensions" : 87 | [ 88 | "C", 89 | "M", 90 | "c++", 91 | "cc", 92 | "cpp", 93 | "cxx", 94 | "mm", 95 | "mpp", 96 | "CPP", 97 | "ixx", 98 | "cppm", 99 | "ccm", 100 | "cxxm", 101 | "c++m" 102 | ] 103 | } 104 | ], 105 | "version" : 106 | { 107 | "major" : 1, 108 | "minor" : 0 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/.ninja_log: -------------------------------------------------------------------------------- 1 | # ninja log v6 2 | 18 30 1729689635153199808 simple_test 622be762462e75f0 3 | 0 18 1729689635135198701 CMakeFiles/simple_test.dir/simple_test.c.o fcdd16991d431441 4 | 160 187 1729751250707919414 eRob_test 9f26259162829e8a 5 | 0 160 1729751250547923802 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 6 | 361 400 1728906888741241190 github_test f18ef4f308b07ec5 7 | 1 361 1728906888381240970 CMakeFiles/github_test.dir/github.cpp.o ace1fd701425395c 8 | 1 164 1729751325019988150 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 9 | 164 194 1729751325182984138 eRob_test 9f26259162829e8a 10 | 0 170 1729752654251476801 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 11 | 170 197 1729752654421475414 eRob_test 9f26259162829e8a 12 | 1 171 1729752751897691688 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 13 | 171 199 1729752752067690340 eRob_test 9f26259162829e8a 14 | 0 174 1729752846469477348 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 15 | 174 202 1729752846643477574 eRob_test 9f26259162829e8a 16 | 0 170 1729753034036515782 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 17 | 170 199 1729753034206515652 eRob_test 9f26259162829e8a 18 | 1 171 1729753116377423440 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 19 | 172 201 1729753116548423191 eRob_test 9f26259162829e8a 20 | 0 172 1729753208855257231 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 21 | 172 201 1729753209027256867 eRob_test 9f26259162829e8a 22 | 0 173 1729753231952206659 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 23 | 173 201 1729753232125206267 eRob_test 9f26259162829e8a 24 | 0 172 1729753264327130242 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 25 | 172 199 1729753264499129819 eRob_test 9f26259162829e8a 26 | 1 194 1729753275226103126 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 27 | 194 225 1729753275419102640 eRob_test 9f26259162829e8a 28 | 1 191 1729753316474994497 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 29 | 191 218 1729753316664993976 eRob_test 9f26259162829e8a 30 | 0 172 1729753329206959129 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 31 | 172 199 1729753329378958645 eRob_test 9f26259162829e8a 32 | 1 173 1729753372071834070 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 33 | 174 200 1729753372244833547 eRob_test 9f26259162829e8a 34 | 0 192 1729753394976763650 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 35 | 192 220 1729753395168763049 eRob_test 9f26259162829e8a 36 | 1 173 1729753409457717901 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 37 | 173 201 1729753409629717352 eRob_test 9f26259162829e8a 38 | 1 179 1729753430574649551 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 39 | 179 207 1729753430752648967 eRob_test 9f26259162829e8a 40 | 1 175 1729753444126604695 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 41 | 175 203 1729753444300604114 eRob_test 9f26259162829e8a 42 | 0 175 1729753457606559332 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 43 | 175 203 1729753457780558742 eRob_test 9f26259162829e8a 44 | 1 186 1729753463011540939 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 45 | 186 214 1729753463196540307 eRob_test 9f26259162829e8a 46 | 0 175 1729753514028361816 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 47 | 175 201 1729753514203361185 eRob_test 9f26259162829e8a 48 | 1 174 1729753598761044208 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 49 | 174 210 1729753598934043537 eRob_test 9f26259162829e8a 50 | 1 171 1729829063189001597 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 51 | 171 199 1729829063358990685 eRob_test 9f26259162829e8a 52 | 0 182 1729829325934117441 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 53 | 182 211 1729829326116155166 eRob_test 9f26259162829e8a 54 | 1 180 1729830899879729419 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 55 | 180 209 1729830900058736044 eRob_test 9f26259162829e8a 56 | 0 189 1730075478034250156 CMakeFiles/eRob_test.dir/eRob_test.cpp.o ac1f66a417590d62 57 | 189 221 1730075478222250593 eRob_test 9f26259162829e8a 58 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "11.4.0") 5 | set(CMAKE_C_COMPILER_VERSION_INTERNAL "") 6 | set(CMAKE_C_COMPILER_WRAPPER "") 7 | set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "17") 8 | set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "ON") 9 | set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert;c_std_17;c_std_23") 10 | set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") 11 | set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") 12 | set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") 13 | set(CMAKE_C17_COMPILE_FEATURES "c_std_17") 14 | set(CMAKE_C23_COMPILE_FEATURES "c_std_23") 15 | 16 | set(CMAKE_C_PLATFORM_ID "Linux") 17 | set(CMAKE_C_SIMULATE_ID "") 18 | set(CMAKE_C_COMPILER_FRONTEND_VARIANT "GNU") 19 | set(CMAKE_C_SIMULATE_VERSION "") 20 | 21 | 22 | 23 | 24 | set(CMAKE_AR "/usr/bin/ar") 25 | set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-11") 26 | set(CMAKE_RANLIB "/usr/bin/ranlib") 27 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-11") 28 | set(CMAKE_LINKER "/usr/bin/ld") 29 | set(CMAKE_LINKER_LINK "") 30 | set(CMAKE_LINKER_LLD "") 31 | set(CMAKE_C_COMPILER_LINKER "/usr/bin/ld") 32 | set(CMAKE_C_COMPILER_LINKER_ID "GNU") 33 | set(CMAKE_C_COMPILER_LINKER_VERSION 2.38) 34 | set(CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT GNU) 35 | set(CMAKE_MT "") 36 | set(CMAKE_TAPI "CMAKE_TAPI-NOTFOUND") 37 | set(CMAKE_COMPILER_IS_GNUCC 1) 38 | set(CMAKE_C_COMPILER_LOADED 1) 39 | set(CMAKE_C_COMPILER_WORKS TRUE) 40 | set(CMAKE_C_ABI_COMPILED TRUE) 41 | 42 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 43 | 44 | set(CMAKE_C_COMPILER_ID_RUN 1) 45 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 46 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 47 | set(CMAKE_C_LINKER_PREFERENCE 10) 48 | set(CMAKE_C_LINKER_DEPFILE_SUPPORTED FALSE) 49 | 50 | # Save compiler ABI information. 51 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 52 | set(CMAKE_C_COMPILER_ABI "ELF") 53 | set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN") 54 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 55 | 56 | if(CMAKE_C_SIZEOF_DATA_PTR) 57 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 58 | endif() 59 | 60 | if(CMAKE_C_COMPILER_ABI) 61 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 62 | endif() 63 | 64 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 65 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 66 | endif() 67 | 68 | set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") 69 | if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) 70 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") 71 | endif() 72 | 73 | 74 | 75 | 76 | 77 | set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/11/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include") 78 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "gcc;gcc_s;c;gcc;gcc_s") 79 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/11;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 80 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 81 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-6.8.0-47-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "6.8.0-47-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-6.8.0-47-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "6.8.0-47-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CompilerIdC/a.out -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/3.29.6/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/simple_test.dir 2 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/eRob_test.dir 3 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/github_test.dir 4 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/edit_cache.dir 5 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/rebuild_cache.dir 6 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/list_install_components.dir 7 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/install.dir 8 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/install/local.dir 9 | /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug/CMakeFiles/install/strip.dir 10 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/clion-Debug-log.txt: -------------------------------------------------------------------------------- 1 | /home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja -G Ninja -S /home/erobman/test_project/SOEM-master/test/linux/simple_test -B /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug 2 | -- Configuring done (0.0s) 3 | -- Generating done (0.0s) 4 | -- Build files have been written to: /home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug 5 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Ninja: 1.12.0@/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja 2 | Options: 3 | 4 | Options:-DCMAKE_MAKE_PROGRAM=/home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/eRob_test.dir/eRob_test.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/eRob_test.dir/eRob_test.cpp.o -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/rules.ninja: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Ninja" Generator, CMake Version 3.29 3 | 4 | # This file contains all the rules used to get the outputs files 5 | # built from the input files. 6 | # It is included in the main 'build.ninja'. 7 | 8 | # ============================================================================= 9 | # Project: eRob_test 10 | # Configurations: Debug 11 | # ============================================================================= 12 | # ============================================================================= 13 | 14 | ############################################# 15 | # Rule for compiling C files. 16 | 17 | rule C_COMPILER__simple_test_unscanned_Debug 18 | depfile = $DEP_FILE 19 | deps = gcc 20 | command = ${LAUNCHER}${CODE_CHECK}/usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in 21 | description = Building C object $out 22 | 23 | 24 | ############################################# 25 | # Rule for linking C executable. 26 | 27 | rule C_EXECUTABLE_LINKER__simple_test_Debug 28 | command = $PRE_LINK && /usr/bin/cc $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD 29 | description = Linking C executable $TARGET_FILE 30 | restat = $RESTAT 31 | 32 | 33 | ############################################# 34 | # Rule for compiling CXX files. 35 | 36 | rule CXX_COMPILER__eRob_test_unscanned_Debug 37 | depfile = $DEP_FILE 38 | deps = gcc 39 | command = ${LAUNCHER}${CODE_CHECK}/usr/bin/c++ $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in 40 | description = Building CXX object $out 41 | 42 | 43 | ############################################# 44 | # Rule for linking CXX executable. 45 | 46 | rule CXX_EXECUTABLE_LINKER__eRob_test_Debug 47 | command = $PRE_LINK && /usr/bin/c++ $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD 48 | description = Linking CXX executable $TARGET_FILE 49 | restat = $RESTAT 50 | 51 | 52 | ############################################# 53 | # Rule for compiling CXX files. 54 | 55 | rule CXX_COMPILER__github_test_unscanned_Debug 56 | depfile = $DEP_FILE 57 | deps = gcc 58 | command = ${LAUNCHER}${CODE_CHECK}/usr/bin/c++ $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in 59 | description = Building CXX object $out 60 | 61 | 62 | ############################################# 63 | # Rule for linking CXX executable. 64 | 65 | rule CXX_EXECUTABLE_LINKER__github_test_Debug 66 | command = $PRE_LINK && /usr/bin/c++ $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD 67 | description = Linking CXX executable $TARGET_FILE 68 | restat = $RESTAT 69 | 70 | 71 | ############################################# 72 | # Rule for running custom commands. 73 | 74 | rule CUSTOM_COMMAND 75 | command = $COMMAND 76 | description = $DESC 77 | 78 | 79 | ############################################# 80 | # Rule for re-running cmake. 81 | 82 | rule RERUN_CMAKE 83 | command = /home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cmake --regenerate-during-build -S/home/erobman/test_project/SOEM-master/test/linux/simple_test -B/home/erobman/test_project/SOEM-master/test/linux/simple_test/cmake-build-debug 84 | description = Re-running CMake... 85 | generator = 1 86 | 87 | 88 | ############################################# 89 | # Rule for cleaning all built files. 90 | 91 | rule CLEAN 92 | command = /home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja $FILE_ARG -t clean $TARGETS 93 | description = Cleaning all built files... 94 | 95 | 96 | ############################################# 97 | # Rule for printing all primary targets available. 98 | 99 | rule HELP 100 | command = /home/erobman/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja -t targets 101 | description = All primary targets available: 102 | 103 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/CMakeFiles/simple_test.dir/simple_test.c.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/CMakeFiles/simple_test.dir/simple_test.c.o -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Oct 28 11:10 CST 2 | ---------------------------------------------------------- 3 | End testing: Oct 28 11:10 CST 4 | -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/eRob_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/eRob_test -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/github_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/github_test -------------------------------------------------------------------------------- /test/linux/simple_test/cmake-build-debug/simple_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroErrControl/eRob_SOEM_linux/a7a2b42015f8af7786be321a896a26ce4f6f2d6c/test/linux/simple_test/cmake-build-debug/simple_test -------------------------------------------------------------------------------- /test/linux/slaveinfo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCES slaveinfo.c) 3 | add_executable(slaveinfo ${SOURCES}) 4 | target_link_libraries(slaveinfo soem) 5 | install(TARGETS slaveinfo DESTINATION bin) 6 | -------------------------------------------------------------------------------- /test/rtk/schedule.tt: -------------------------------------------------------------------------------- 1 | stack_size: 2048 2 | 3 | tasks: 4 | - name : tReadIO 5 | entry : read_io 6 | arg : 'NULL' 7 | 8 | schedules: 9 | - name : sched1 10 | period : 1 11 | events : 12 | - task : tReadIO 13 | start : 0 14 | stop : 1 -------------------------------------------------------------------------------- /test/simple_ng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES simple_ng.c) 2 | add_executable(simple_ng ${SOURCES}) 3 | target_link_libraries(simple_ng soem) 4 | install(TARGETS simple_ng DESTINATION bin) 5 | -------------------------------------------------------------------------------- /test/win32/firm_update/firm_update.c: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Example code for Simple Open EtherCAT master 3 | * 4 | * Usage: firm_update ifname1 slave fname 5 | * ifname is NIC interface, f.e. eth0 6 | * slave = slave number in EtherCAT order 1..n 7 | * fname = binary file to store in slave 8 | * CAUTION! Using the wrong file can result in a bricked slave! 9 | * 10 | * This is a slave firmware update test. 11 | * 12 | * (c)Arthur Ketels 2011 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "ethercat.h" 22 | 23 | #define FWBUFSIZE (8 * 1024 * 1024) 24 | 25 | uint8 ob; 26 | uint16 ow; 27 | uint32 data; 28 | char filename[256]; 29 | char filebuffer[FWBUFSIZE]; // 8MB buffer 30 | int filesize; 31 | int j; 32 | uint16 argslave; 33 | 34 | int input_bin(char *fname, int *length) 35 | { 36 | FILE *fp; 37 | 38 | int cc = 0, c; 39 | 40 | fp = fopen(fname, "rb"); 41 | if(fp == NULL) 42 | return 0; 43 | while (((c = fgetc(fp)) != EOF) && (cc < FWBUFSIZE)) 44 | filebuffer[cc++] = (uint8)c; 45 | *length = cc; 46 | fclose(fp); 47 | return 1; 48 | } 49 | 50 | 51 | void boottest(char *ifname, uint16 slave, char *filename) 52 | { 53 | printf("Starting firmware update example\n"); 54 | 55 | /* initialise SOEM, bind socket to ifname */ 56 | if (ec_init(ifname)) 57 | { 58 | printf("ec_init on %s succeeded.\n",ifname); 59 | /* find and auto-config slaves */ 60 | 61 | 62 | if ( ec_config_init(FALSE) > 0 ) 63 | { 64 | printf("%d slaves found and configured.\n",ec_slavecount); 65 | 66 | printf("Request init state for slave %d\n", slave); 67 | ec_slave[slave].state = EC_STATE_INIT; 68 | ec_writestate(slave); 69 | 70 | /* wait for slave to reach INIT state */ 71 | ec_statecheck(slave, EC_STATE_INIT, EC_TIMEOUTSTATE * 4); 72 | printf("Slave %d state to INIT.\n", slave); 73 | 74 | /* read BOOT mailbox data, master -> slave */ 75 | data = ec_readeeprom(slave, ECT_SII_BOOTRXMBX, EC_TIMEOUTEEP); 76 | ec_slave[slave].SM[0].StartAddr = (uint16)LO_WORD(data); 77 | ec_slave[slave].SM[0].SMlength = (uint16)HI_WORD(data); 78 | /* store boot write mailbox address */ 79 | ec_slave[slave].mbx_wo = (uint16)LO_WORD(data); 80 | /* store boot write mailbox size */ 81 | ec_slave[slave].mbx_l = (uint16)HI_WORD(data); 82 | 83 | /* read BOOT mailbox data, slave -> master */ 84 | data = ec_readeeprom(slave, ECT_SII_BOOTTXMBX, EC_TIMEOUTEEP); 85 | ec_slave[slave].SM[1].StartAddr = (uint16)LO_WORD(data); 86 | ec_slave[slave].SM[1].SMlength = (uint16)HI_WORD(data); 87 | /* store boot read mailbox address */ 88 | ec_slave[slave].mbx_ro = (uint16)LO_WORD(data); 89 | /* store boot read mailbox size */ 90 | ec_slave[slave].mbx_rl = (uint16)HI_WORD(data); 91 | 92 | printf(" SM0 A:%4.4x L:%4d F:%8.8x\n", ec_slave[slave].SM[0].StartAddr, ec_slave[slave].SM[0].SMlength, 93 | (int)ec_slave[slave].SM[0].SMflags); 94 | printf(" SM1 A:%4.4x L:%4d F:%8.8x\n", ec_slave[slave].SM[1].StartAddr, ec_slave[slave].SM[1].SMlength, 95 | (int)ec_slave[slave].SM[1].SMflags); 96 | /* program SM0 mailbox in for slave */ 97 | ec_FPWR (ec_slave[slave].configadr, ECT_REG_SM0, sizeof(ec_smt), &ec_slave[slave].SM[0], EC_TIMEOUTRET); 98 | /* program SM1 mailbox out for slave */ 99 | ec_FPWR (ec_slave[slave].configadr, ECT_REG_SM1, sizeof(ec_smt), &ec_slave[slave].SM[1], EC_TIMEOUTRET); 100 | 101 | printf("Request BOOT state for slave %d\n", slave); 102 | ec_slave[slave].state = EC_STATE_BOOT; 103 | ec_writestate(slave); 104 | 105 | /* wait for slave to reach BOOT state */ 106 | if (ec_statecheck(slave, EC_STATE_BOOT, EC_TIMEOUTSTATE * 10) == EC_STATE_BOOT) 107 | { 108 | printf("Slave %d state to BOOT.\n", slave); 109 | 110 | if (input_bin(filename, &filesize)) 111 | { 112 | printf("File read OK, %d bytes.\n",filesize); 113 | printf("FoE write...."); 114 | j = ec_FOEwrite(slave, filename, 0, filesize , &filebuffer, EC_TIMEOUTSTATE); 115 | printf("result %d.\n",j); 116 | printf("Request init state for slave %d\n", slave); 117 | ec_slave[slave].state = EC_STATE_INIT; 118 | ec_writestate(slave); 119 | } 120 | else 121 | printf("File not read OK.\n"); 122 | } 123 | 124 | } 125 | else 126 | { 127 | printf("No slaves found!\n"); 128 | } 129 | printf("End firmware update example, close socket\n"); 130 | /* stop SOEM, close socket */ 131 | ec_close(); 132 | } 133 | else 134 | { 135 | printf("No socket connection on %s\nExcecute as root\n",ifname); 136 | } 137 | } 138 | 139 | int main(int argc, char *argv[]) 140 | { 141 | printf("SOEM (Simple Open EtherCAT Master)\nFirmware update example\n"); 142 | 143 | if (argc > 3) 144 | { 145 | argslave = atoi(argv[2]); 146 | boottest(argv[1], argslave, argv[3]); 147 | } 148 | else 149 | { 150 | printf("Usage: firm_update ifname1 slave fname\n"); 151 | printf("ifname = eth0 for example\n"); 152 | printf("slave = slave number in EtherCAT order 1..n\n"); 153 | printf("fname = binary file to store in slave\n"); 154 | printf("CAUTION! Using the wrong file can result in a bricked slave!\n"); 155 | } 156 | 157 | printf("End program\n"); 158 | return (0); 159 | } 160 | --------------------------------------------------------------------------------