Skip to content

Commit e6bf59d

Browse files
author
rt-labs bot
committed
chore: catchup to a66aaed
a66aaed Add Windows port 4844780 Fix USE_SCHED_FIFO option a2006f5 OSAL needs Threads c819351 Run apt-get update in build job c339b1f Enable CodeQL semantic code analysis 885e56e Update README.md c4047f7 Set defaults only if main project 4562e03 Fix gtest warning on embedded targets cdd0cf0 Update cmake-tools 22c5765 Migrate to Github Actions 462d352 Import modbus stack Based-On-Commit: a66aaed Change-Id: I91a3c3c777bfc7401ba0756d2239ec7c64617231
0 parents  commit e6bf59d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+8034
-0
lines changed

.clang-format

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
AlignAfterOpenBracket: AlwaysBreak
2+
AlignConsecutiveAssignments: false
3+
AlignConsecutiveMacros: true
4+
AllowAllArgumentsOnNextLine: false
5+
AllowAllParametersOfDeclarationOnNextLine: false
6+
AllowShortCaseLabelsOnASingleLine: false
7+
AllowShortFunctionsOnASingleLine: None
8+
AllowShortIfStatementsOnASingleLine: Never
9+
BinPackArguments: false
10+
BinPackParameters: false
11+
BreakBeforeBraces: Custom
12+
BraceWrapping:
13+
AfterCaseLabel: true
14+
AfterClass: true
15+
AfterControlStatement: true
16+
AfterEnum: true
17+
AfterFunction: true
18+
AfterNamespace: true
19+
AfterStruct: true
20+
AfterUnion: true
21+
BeforeCatch: true
22+
BeforeElse: true
23+
IndentBraces: false
24+
SplitEmptyFunction: true
25+
SplitEmptyRecord: true
26+
SplitEmptyNamespace: false
27+
AfterExternBlock: false
28+
ColumnLimit: 80
29+
ContinuationIndentWidth: 3
30+
IndentCaseLabels: false
31+
IndentWidth: 3
32+
PenaltyBreakAssignment: 10
33+
PenaltyBreakBeforeFirstCallParameter: 30
34+
PenaltyBreakComment: 10
35+
PenaltyBreakString: 10
36+
PenaltyExcessCharacter: 100
37+
PenaltyReturnTypeOnItsOwnLine: 100000
38+
PointerAlignment: Middle
39+
SortIncludes: false
40+
SpaceBeforeParens: NonEmptyParentheses
41+
UseTab: Never

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
build*/
2+
*~
3+
*#
4+
CMakeFiles/
5+
CMakeCache.txt
6+
install
7+
8+
.cproject
9+
.project
10+
.dir-locals.el
11+
12+
# Object files
13+
*.o
14+
*.ko
15+
*.obj
16+
*.elf
17+
18+
# Precompiled Headers
19+
*.gch
20+
*.pch
21+
22+
# Libraries
23+
*.lib
24+
*.a
25+
*.la
26+
*.lo
27+
28+
# Shared objects (inc. Windows DLLs)
29+
*.dll
30+
*.so
31+
*.so.*
32+
*.dylib
33+
34+
# Executables
35+
*.exe
36+
*.out
37+
*.app
38+
*.i*86
39+
*.x86_64
40+
*.hex

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# License
2+
3+
This software is dual-licensed.
4+
5+
## GPL version 3
6+
7+
This software is distributed under GPLv3. You are allowed to use this
8+
software for an open-source project with a compatible license.
9+
10+
[GNU GPL license v3](https://www.gnu.org/licenses/gpl-3.0.html)
11+
12+
## Commercial license
13+
14+
This software is also available under a commercial license with
15+
options for support and maintenance. Please contact sales@rt-labs.com
16+
for further details.

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
Modbus stack
2+
=============
3+
[![Build Status](https://github.com/rtlabs-com/m-bus/workflows/Build/badge.svg?branch=master)](https://github.com/rtlabs-com/m-bus/actions?workflow=Build)
4+
[![CodeQL](https://github.com/rtlabs-com/m-bus/workflows/CodeQL/badge.svg?branch=master)](https://github.com/rtlabs-com/m-bus/actions?workflow=CodeQL)
5+
6+
This repository contains a Modbus stack. The stack is written to an OS
7+
abstraction layer and can also be used in a bare metal
8+
application. Using the abstraction layer, the stack can run on Linux,
9+
Windows or on an RTOS.
10+
11+
Cloning
12+
=======
13+
14+
Clone the source:
15+
16+
```
17+
$ git clone --recurse-submodules https://github.com/rtlabs-com/m-bus.git
18+
```
19+
20+
This will clone the repository with submodules. If you already cloned
21+
the repository without the `--recurse-submodules` flag then run this
22+
in the m-bus folder:
23+
24+
```
25+
$ git submodule update --init --recursive
26+
```
27+
28+
Prerequisites for all platforms
29+
===============================
30+
31+
* CMake 3.14 or later
32+
33+
Windows
34+
=======
35+
36+
* Visual Studio 2019 or later
37+
38+
You can use a windows or unix shell as preferred. The following
39+
instructions are for a unix shell. CMake is assumed to be in your
40+
path.
41+
42+
```
43+
$ cmake -B build.win64 -A x64
44+
$ cmake --build build.win64 --config Release
45+
$ cmake --build build.win64 --config Release --target check
46+
```
47+
48+
This builds the project and runs the unit tests.
49+
50+
Linux
51+
=====
52+
53+
* GCC 4.6 or later
54+
55+
```
56+
$ cmake -B build
57+
$ cmake --build build --target all check
58+
```
59+
60+
This builds the project and runs the unit tests.
61+
62+
rt-kernel
63+
=========
64+
65+
* Workbench 2020.1 or later
66+
67+
You should use a bash shell, such as for instance the Command Line in
68+
your Toolbox installation. Set the BSP variable to the name of the BSP
69+
you wish to build for. Set the RTK variable to the path of your
70+
rt-kernel tree.
71+
72+
Standalone project
73+
------------------
74+
75+
This creates standalone makefiles.
76+
77+
```
78+
$ RTK=/path/to/rt-kernel BSP=xmc48relax cmake \
79+
-B build.xmc48relax \
80+
-DCMAKE_TOOLCHAIN_FILE=cmake/tools/toolchain/rt-kernel.cmake \
81+
-G "Unix Makefiles"
82+
$ cmake --build build.xmc48relax
83+
```
84+
85+
Workbench project
86+
-----------------
87+
88+
This creates a Makefile project that can be imported to Workbench. The
89+
project will be created in the build directory. The build directory
90+
should be located outside of the source tree.
91+
92+
```
93+
$ RTK=/path/to/rt-kernel BSP=xmc48relax cmake \
94+
-B build.xmc48relax -S /path/to/m-bus \
95+
-DCMAKE_TOOLCHAIN_FILE=cmake/tools/toolchain/rt-kernel.cmake \
96+
-DCMAKE_ECLIPSE_EXECUTABLE=/opt/rt-tools/workbench/Workbench \
97+
-DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE \
98+
-G "Eclipse CDT4 - Unix Makefiles"
99+
```
100+
101+
A source project will also be created in the m-bus tree. This project
102+
can also be imported to Workbench. After importing, right-click on the
103+
project and choose *New* -> *Convert to a C/C++ project*. This will
104+
setup the project so that the indexer works correctly and the
105+
Workbench revision control tools can be used.
106+
107+
The library and the unit tests will be built. Note that the tests
108+
require a stack of at least 6 kB. You may have to increase
109+
CFG_MAIN_STACK_SIZE in your bsp include/config.h file.
110+
111+
Contributions
112+
=============
113+
114+
Contributions are welcome. If you want to contribute you will need to
115+
sign a Contributor License Agreement and send it to us either by
116+
e-mail or by physical mail. More information is available
117+
[here](https://rt-labs.com/contribution).

include/mb_error.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*********************************************************************
2+
* _ _ _
3+
* _ __ | |_ _ | | __ _ | |__ ___
4+
* | '__|| __|(_)| | / _` || '_ \ / __|
5+
* | | | |_ _ | || (_| || |_) |\__ \
6+
* |_| \__|(_)|_| \__,_||_.__/ |___/
7+
*
8+
* www.rt-labs.com
9+
* Copyright 2012 rt-labs AB, Sweden.
10+
*
11+
* This software is dual-licensed under GPLv3 and a commercial
12+
* license. See the file LICENSE.md distributed with this software for
13+
* full license information.
14+
********************************************************************/
15+
16+
/**
17+
* \addtogroup mb_error Modbus error codes
18+
* \{
19+
*/
20+
21+
#ifndef MB_ERROR_H
22+
#define MB_ERROR_H
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/* Modbus exceptions. A slave callback can return these. A master read
29+
or write operation may result in one of these exceptions. */
30+
#define EILLEGAL_FUNCTION -1 /**< Modbus exception ILLEGAL_FUNCTION */
31+
#define EILLEGAL_DATA_ADDRESS -2 /**< Modbus exception ILLEGAL_DATA_ADDRESS */
32+
#define EILLEGAL_DATA_VALUE -3 /**< Modbus exception ILLEGAL_DATA_VALUE */
33+
#define ESLAVE_DEVICE_FAILURE -4 /**< Modbus exception SLAVE_DEVICE_FAILURE */
34+
35+
/* Modbus communication errors */
36+
#define ECRC_FAIL -101 /**< CRC check failed */
37+
#define EFRAME_NOK -102 /**< Received frame not valid */
38+
#define ESLAVE_ID -103 /**< Unexpected slave ID */
39+
#define ETIMEOUT -104 /**< Receive timed out */
40+
#define EUNKNOWN_EXCEPTION -105 /**< Modbus exception code not recognised */
41+
42+
static inline const char * mb_error_literal (int error)
43+
{
44+
switch (error)
45+
{
46+
case EILLEGAL_FUNCTION:
47+
return "EILLEGAL_FUNCTION";
48+
case EILLEGAL_DATA_ADDRESS:
49+
return "EILLEGAL_DATA_ADDRESS";
50+
case EILLEGAL_DATA_VALUE:
51+
return "EILLEGAL_DATA_VALUE";
52+
case ESLAVE_DEVICE_FAILURE:
53+
return "ESLAVE_DEVICE_FAILURE";
54+
case ECRC_FAIL:
55+
return "ECRC_FAIL";
56+
case EFRAME_NOK:
57+
return "EFRAME_NOK";
58+
case ESLAVE_ID:
59+
return "ESLAVE_ID";
60+
case ETIMEOUT:
61+
return "ETIMEOUT";
62+
case EUNKNOWN_EXCEPTION:
63+
return "EUNKNOWN_EXCEPTION";
64+
default:
65+
return "Unknown error";
66+
}
67+
}
68+
69+
#ifdef __cplusplus
70+
}
71+
#endif
72+
73+
#endif /* MB_ERROR_H */
74+
75+
/**
76+
* \}
77+
*/

0 commit comments

Comments
 (0)