Skip to content

Commit

Permalink
chore: catchup to 8ada1a7
Browse files Browse the repository at this point in the history
8ada1a7 Indicate hearbeat protocol state in node map
1f744c6 Fix manufacturer-specific error bit
0f249e1 Fix USE_SCHED_FIFO option
ef9b9f8 Add test for automatic bus-off recovery
14dac66 Add configurable delay before attempting bus-off recovery
1a18e19 Crude recovery from bus-off
0249ea7 Move bus-off error behavior from recovery to actual bus-off
fcf98e4 Split NMT Initialisation state into its three sub-states
5b48daf Add API to retrieve the active node ID
88f0abf Pass the network handle to callback functions instead of cb_arg
a4b63d7 Call EMCY callback when entering bus off condition
ac8cf72 Allow EMCY callback to enable the error behavior
f07091e Fix error behaviour tests
bcee891 Only trigger the Error behaviour on the mandatory events
6735cc1 Synchronize PDO triggering with the c-open main thread
62d787b Fix SDO time-out on large segmented transfers
742ca8d Bump cmake tools
1095327 Only send PDOs in NMT Operational
49038f8 Deliver SYNC locally
291d545 socketcan: check for existing interface
f3b97db Do not validate invalid COBID
07676c8 Fix NMT command
2fb21ae Run apt-get update in build job
07b89db Enable CodeQL semantic code analysis
9e1443d Update README
a384e88 Set defaults only if main project
41beae0 Fix gtest warning on embedded targets
cdac693 Update cmake-tools
061a5b1 Add CO_EXPORT to communication objects
36dda36 Redefinition of typedef not allowed in C99
88a74ab Migrate to Github Actions
e2494e3 Fix corrupt OD load following a non-existent object
ca4688e Pass the read/write intent to the OD store open call
dc38946 Tests for co_pdo_trigger_with_obj
370956d Don't trigger disabled PDOs
e9627cf Fix multiple data corruption in OD load
5ab1a5e Add OD load test-case

Based-On-Commit: 8ada1a7
Change-Id: Ic6447abb98f7bb1ade39e427661ca49143f9d297
  • Loading branch information
rt-labs bot committed Jul 2, 2024
1 parent c3a0778 commit 5588bb5
Show file tree
Hide file tree
Showing 31 changed files with 727 additions and 301 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build
on: [push, pull_request]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Apt update
run: sudo apt-get update

- name: Install dependencies
run: sudo apt-get install doxygen

- name: Configure
shell: bash
run: |
cmake -E make_directory ${{github.workspace}}/build
cmake -B ${{github.workspace}}/build -S ${{github.workspace}} \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
shell: bash
run: |
cmake --build ${{github.workspace}}/build --target all docs install -j4
- name: Test
shell: bash
run: |
cmake --build ${{github.workspace}}/build --target check
46 changes: 46 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CodeQL

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '23 13 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Build
run: |
cmake -E make_directory ${{github.workspace}}/build.lgtm
cmake -B ${{github.workspace}}/build.lgtm -S ${{github.workspace}} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/build.lgtm -j4
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

60 changes: 33 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,40 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools")
project (CANOPEN VERSION 0.1.0)

include(AddOsal)
include(GenerateExportHeader)
include(CMakeDependentOption)

# Default settings if this is the main project
if (CMAKE_PROJECT_NAME STREQUAL CANOPEN)
include(CTest)

# Make option visible in ccmake, cmake-gui
option (BUILD_SHARED_LIBS "Build shared library" OFF)

# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)

# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CANOPEN_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()

message(STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
endif()

# Set required standard level
set (CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 11)
include(AddOsal)
include(GenerateExportHeader)
include(CMakeDependentOption)
include(GetGitRevision)

# Always use standard .o suffix
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

# Options
option (BUILD_SHARED_LIBS "Build shared library" OFF)

set(LOG_STATE_VALUES "ON;OFF")
set(LOG_LEVEL_VALUES "DEBUG;INFO;WARNING;ERROR")

Expand Down Expand Up @@ -100,21 +115,6 @@ set(CO_THREAD_PRIO "10"
set(CO_THREAD_STACK_SIZE "4096"
CACHE STRING "stack size of main thread")

# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
message (STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")

# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CANOPEN_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")

# Generate version numbers
configure_file (
version.h.in
Expand Down Expand Up @@ -142,14 +142,20 @@ if (CMAKE_PROJECT_NAME STREQUAL CANOPEN AND BUILD_TESTING)
endif()

# Platform configuration
include(${CMAKE_SYSTEM_NAME})
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake)

generate_export_header(canopen
BASE_NAME co
EXPORT_FILE_NAME ${CANOPEN_BINARY_DIR}/include/co_export.h
)

set_target_properties (canopen slave slaveinfo
PROPERTIES
C_STANDARD 99
)

target_compile_features(canopen PUBLIC c_std_99)

target_include_directories(canopen
PUBLIC
$<BUILD_INTERFACE:${CANOPEN_SOURCE_DIR}/include>
Expand Down
120 changes: 61 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
c-open: CANopen stack
=====================
[![Build Status](https://travis-ci.org/rtlabs-com/c-open.svg?branch=master)](https://travis-ci.org/rtlabs-com/c-open)

[![Build Status](https://github.com/rtlabs-com/c-open/workflows/Build/badge.svg?branch=master)](https://github.com/rtlabs-com/c-open/actions?workflow=Build)
[![CodeQL](https://github.com/rtlabs-com/c-open/workflows/CodeQL/badge.svg?branch=master)](https://github.com/rtlabs-com/c-open/actions?workflow=CodeQL)

This repository contains a CANopen stack for both master and
slaves. The stack implements most of CiA 301 and 305 (LSS). The stack
is written to an OS abstraction layer and can also be used in a bare
Expand All @@ -15,106 +16,107 @@ Tool.
Also included is a simple master example that lists all slaves on the
bus and a comprehensive set of unit-tests.

Cloning
=======

Clone the source:

```
$ git clone --recurse-submodules https://github.com/rtlabs-com/c-open.git
```

This will clone the repository with submodules. If you already cloned
the repository without the `--recurse-submodules` flag then run this
in the c-open folder:

```
$ git submodule update --init --recursive
```

Prerequisites for all platforms
===============================

* CMake 3.14 or later

Out-of-tree builds are recommended. Create a build directory and run
the following commands from that directory. In the following
instructions, the root folder for the repo is assumed to be an
absolute or relative path in an environment variable named *repo*.

The cmake executable is assumed to be in your path. After running
cmake you can run ccmake or cmake-gui to change settings.

Windows
=======

* Visual Studio 2013 or later
* Visual Studio 2017 or later
* Kvaser CANlib SDK

The windows build supports Kvaser devices and requires the Kvaser
CANlib SDK. The CMake variable CANLIB_ROOT_DIR should be set to the
folder where the CANlib SDK was installed.
You can use a windows or unix shell as preferred. The following
instructions are for a unix shell. CMake is assumed to be in your
path.

Start a Visual Studio developer command prompt, then:
The windows build supports Kvaser devices and requires the Kvaser
CANlib SDK. CMake should find the SDK but if not a hint can be given
by setting `-DCANLIB_ROOT_DIR="C:\Program Files (x86)\Kvaser\Canlib"`
or similar during configuration.

```
C:\build> cmake %repo% -DCANLIB_ROOT_DIR="C:\Program Files (x86)\Kvaser\Canlib"
C:\build> msbuild ALL_BUILD.vcxproj
C:\build> msbuild RUN_TESTS.vcxproj
$ cmake -B build.win32 -A Win32
$ cmake --build build.win32 --config Release
$ cmake --build build.win32 --config Release --target check
```

This builds the stack and runs the unit tests.
This builds the project and runs the unit tests.

Linux
=====

* GCC 4.6 or later

```console
user@host:~/build$ cmake $repo
user@host:~/build$ make all check
```

This builds the stack and runs the unit tests.

The clang static analyzer can also be used if installed. From a clean
build directory, run:

```console
user@host:~/build$ scan-build cmake $repo -DCMAKE_BUILD_TYPE=Debug
user@host:~/build$ scan-build make
$ cmake -B build
$ cmake --build build --target all check
```

This builds the project and runs the unit tests.

rt-kernel
=========

* Workbench 2020.1 or later

Set the following environment variables. You should use a bash shell,
such as for instance the Command Line in your Toolbox
installation. Set the BSP variable to the name of the BSP you wish to
build for. Set the RTK variable to the path of your rt-kernel tree.


```console
user@host:~/build$ export RTK=/path/to/rt-kernel
user@host:~/build$ export BSP=<bsp>
```
You should use a bash shell, such as for instance the Command Line in
your Toolbox installation. Set the BSP variable to the name of the BSP
you wish to build for. Set the RTK variable to the path of your
rt-kernel tree.

Standalone project
------------------

This creates standalone makefiles.

```console
user@host:~/build$ cmake $repo \
-DCMAKE_TOOLCHAIN_FILE=$repo/cmake/tools/toolchain/rt-kernel.cmake \
-G "Unix Makefiles"
user@host:~/build$ make all
```
$ RTK=/path/to/rt-kernel BSP=xmc48relax cmake \
-B build.xmc48relax \
-DCMAKE_TOOLCHAIN_FILE=cmake/tools/toolchain/rt-kernel.cmake \
-G "Unix Makefiles"
$ cmake --build build.xmc48relax
```

Workbench project
-----------------

This creates a Makefile project that can be imported to Workbench. The
project will be created in the build directory.

```console
user@host:~/build$ cmake $repo \
-DCMAKE_TOOLCHAIN_FILE=$repo/cmake/tools/toolchain/rt-kernel.cmake \
-DCMAKE_ECLIPSE_EXECUTABLE=/opt/rt-tools/workbench/Workbench \
-DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE \
-G "Eclipse CDT4 - Unix Makefiles"
project will be created in the build directory. The build directory
should be located outside of the source tree.

```
$ RTK=/path/to/rt-kernel BSP=xmc48relax cmake \
-B build.xmc48relax -S /path/to/c-open \
-DCMAKE_TOOLCHAIN_FILE=cmake/tools/toolchain/rt-kernel.cmake \
-DCMAKE_ECLIPSE_EXECUTABLE=/opt/rt-tools/workbench/Workbench \
-DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE \
-G "Eclipse CDT4 - Unix Makefiles"
```

A source project will also be created in the $repo folder. This
project can also be imported to Workbench. After importing,
right-click on the project and choose *New* -> *Convert to a C/C++
project*. This will setup the project so that the indexer works
correctly and the Workbench revision control tools can be used.
A source project will also be created in the c-open tree. This project
can also be imported to Workbench. After importing, right-click on the
project and choose *New* -> *Convert to a C/C++ project*. This will
setup the project so that the indexer works correctly and the
Workbench revision control tools can be used.

The library and the unit tests will be built. Note that the tests
require a stack of at least 6 kB. You may have to increase
Expand Down
Loading

0 comments on commit 5588bb5

Please sign in to comment.