kopia lustrzana https://github.com/SP8EBC/ParaTNC
modbus rtu
rodzic
2f3e304b23
commit
b44dbca663
|
@ -24,8 +24,8 @@
|
|||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.9827544" name="Data sections (-fdata-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.687021169" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.434251993" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format" useByScannerDiscovery="true"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn.1974616790" name="Enable all common warnings (-Wall)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.48269422" name="Enable extra warnings (-Wextra)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn.1974616790" name="Enable all common warnings (-Wall)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.48269422" name="Enable extra warnings (-Wextra)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding.384626981" name="Assume freestanding environment (-ffreestanding)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants.2101974172" name="Disable loop invariant move (-fno-move-loop-invariants)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name.130401718" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name" useByScannerDiscovery="false" value="GNU Tools for ARM Embedded Processors" valueType="string"/>
|
||||
|
@ -79,7 +79,7 @@
|
|||
<listOptionValue builtIn="false" value="USE_STDPERIPH_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.otherwarnings.1338324911" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="-Wunused-function" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.otherwarnings.1338324911" name="Other warning flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="-Wunused-function" valueType="string"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.726748309" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.204317376" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
|
||||
|
@ -102,6 +102,7 @@
|
|||
<listOptionValue builtIn="false" value="USE_STDPERIPH_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.otherwarnings.2014375249" name="Other warning flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.otherwarnings" useByScannerDiscovery="true" value="-Wunused-function" valueType="string"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.90169505" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.2078057424" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-254140881837021966" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-231650764009955027" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
|
|
@ -12,6 +12,7 @@ RM := rm -rf
|
|||
-include system/src/umb_master/subdir.mk
|
||||
-include system/src/stm32f1-stdperiph/subdir.mk
|
||||
-include system/src/newlib/subdir.mk
|
||||
-include system/src/modbus_rtu/subdir.mk
|
||||
-include system/src/drivers/subdir.mk
|
||||
-include system/src/diag/subdir.mk
|
||||
-include system/src/davis_vantage/subdir.mk
|
||||
|
|
|
@ -34,6 +34,7 @@ system/src/cortexm \
|
|||
system/src/davis_vantage \
|
||||
system/src/diag \
|
||||
system/src/drivers \
|
||||
system/src/modbus_rtu \
|
||||
system/src/newlib \
|
||||
system/src/stm32f1-stdperiph \
|
||||
system/src/umb_master \
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* rtu_coil_data_t.h
|
||||
*
|
||||
* Created on: 28.08.2020
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_MODBUS_RTU_RTU_COIL_DATA_T_H_
|
||||
#define INCLUDE_MODBUS_RTU_RTU_COIL_DATA_T_H_
|
||||
|
||||
typedef struct rtu_coil_data_t {
|
||||
|
||||
uint8_t number_of_coils;
|
||||
|
||||
}rtu_coil_data_t;
|
||||
|
||||
#endif /* INCLUDE_MODBUS_RTU_RTU_COIL_DATA_T_H_ */
|
|
@ -10,6 +10,18 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
uint16_t rtu_parser_stream_crc(uint16_t previous_crc, uint8_t current_data);
|
||||
inline uint16_t rtu_parser_stream_crc(uint16_t previous_crc, uint8_t current_data) {
|
||||
int i;
|
||||
|
||||
previous_crc ^= (uint16_t)current_data;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
if (previous_crc & 1)
|
||||
previous_crc = (previous_crc) ^ 0xA001;
|
||||
else
|
||||
previous_crc = (previous_crc >> 1);
|
||||
}
|
||||
|
||||
return previous_crc;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_MODBUS_RTU_RTU_PARSER_H_ */
|
||||
|
|
|
@ -8,6 +8,14 @@
|
|||
#ifndef INCLUDE_MODBUS_RTU_RTU_SERIAL_IO_H_
|
||||
#define INCLUDE_MODBUS_RTU_RTU_SERIAL_IO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint16_t rtu_serial_previous_crc;
|
||||
|
||||
uint8_t rtu_serial_callback(uint8_t current_data, const uint8_t * const rx_buffer, uint16_t rx_bytes_counter);
|
||||
|
||||
inline void rtu_serial_reset_crc(void) {
|
||||
rtu_serial_previous_crc = 0xFFFF;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_MODBUS_RTU_RTU_SERIAL_IO_H_ */
|
||||
|
|
|
@ -7,16 +7,4 @@
|
|||
|
||||
#include "./modbus_rtu/rtu_parser.h"
|
||||
|
||||
uint16_t rtu_parser_stream_crc(uint16_t previous_crc, uint8_t current_data) {
|
||||
int i;
|
||||
|
||||
previous_crc ^= (uint16_t)current_data;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
if (previous_crc & 1)
|
||||
previous_crc = (previous_crc) ^ 0xA001;
|
||||
else
|
||||
previous_crc = (previous_crc >> 1);
|
||||
}
|
||||
|
||||
return previous_crc;
|
||||
}
|
||||
|
|
|
@ -5,4 +5,40 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "modbus_rtu/rtu_serial_io.h"
|
||||
#include "modbus_rtu/rtu_parser.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
|
||||
|
||||
/**
|
||||
* CRC value after the last call to rtu_serial_callback
|
||||
*/
|
||||
uint16_t rtu_serial_previous_crc = 0;
|
||||
|
||||
/**
|
||||
* A callback for stream CRC calculation
|
||||
*/
|
||||
uint8_t rtu_serial_callback(uint8_t current_data, const uint8_t * const rx_buffer, uint16_t rx_bytes_counter) {
|
||||
|
||||
uint8_t retval = 0;
|
||||
|
||||
uint16_t new_crc = 0;
|
||||
|
||||
// calculate new crc
|
||||
new_crc = rtu_parser_stream_crc(rtu_serial_previous_crc, current_data);
|
||||
|
||||
// if the new CRC value equals 0x0000 it means that this was MSB
|
||||
// of CRC from correctly received Modbus-RTU frame
|
||||
if (new_crc == 0) {
|
||||
// return '1' to terminate the transmission
|
||||
retval = 1;
|
||||
}
|
||||
else {
|
||||
rtu_serial_previous_crc = new_crc;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue