Skip to content

Commit

Permalink
[NMEA2K]: Altered value change detection to ignore timestamp
Browse files Browse the repository at this point in the history
Fixed every NMEA2K message triggering a callback/event because
the timestamp was being considered as something that changed.
  • Loading branch information
ad3154 committed Oct 28, 2023
1 parent 3973e97 commit 7cd8c88
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
9 changes: 6 additions & 3 deletions examples/nmea2000/fast_packet_protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
cmake_minimum_required(VERSION 3.16)
project(fast_packet_protocol_example)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT BUILD_EXAMPLES)
find_package(isobus REQUIRED)
endif()
find_package(Threads REQUIRED)

add_executable(NMEA2KFastPacketTarget main.cpp)

set_target_properties(
NMEA2KFastPacketTarget
PROPERTIES CXX_STANDARD 14
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)

target_link_libraries(
NMEA2KFastPacketTarget PRIVATE isobus::Isobus isobus::HardwareIntegration
Threads::Threads isobus::Utility)
9 changes: 6 additions & 3 deletions examples/nmea2000/nmea2000_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
cmake_minimum_required(VERSION 3.16)
project(nmea2000_generator_example)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT BUILD_EXAMPLES)
find_package(isobus REQUIRED)
endif()
find_package(Threads REQUIRED)

add_executable(NMEA2KGeneratorTarget main.cpp)

set_target_properties(
NMEA2KGeneratorTarget
PROPERTIES CXX_STANDARD 14
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)

target_link_libraries(
NMEA2KGeneratorTarget PRIVATE isobus::Isobus isobus::HardwareIntegration
Threads::Threads isobus::Utility)
2 changes: 1 addition & 1 deletion examples/nmea2000/nmea2000_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ find_package(Threads REQUIRED)
add_executable(NMEA2KParserTarget main.cpp)

set_target_properties(
NMEA2KExampleTarget
NMEA2KParserTarget
PROPERTIES CXX_STANDARD 14
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)
Expand Down
10 changes: 5 additions & 5 deletions isobus/src/nmea2000_message_definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace isobus
retVal |= set_magnetic_deviation(receivedMessage.get_uint16_at(3));
retVal |= set_magnetic_variation(receivedMessage.get_uint16_at(5));
retVal |= set_sensor_reference(static_cast<HeadingSensorReference>(receivedMessage.get_uint8_at(7) & 0x03));
retVal |= set_timestamp(SystemTiming::get_timestamp_ms());
set_timestamp(SystemTiming::get_timestamp_ms());
}
else
{
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace isobus
turnRate |= (static_cast<std::int32_t>(receivedMessage.get_uint8_at(4)) << 24);
retVal |= set_sequence_id(receivedMessage.get_uint8_at(0));
retVal |= set_rate_of_turn(turnRate);
retVal |= set_timestamp(SystemTiming::get_timestamp_ms());
set_timestamp(SystemTiming::get_timestamp_ms());
}
else
{
Expand Down Expand Up @@ -334,7 +334,7 @@ namespace isobus
decodedLongitude |= (static_cast<std::int32_t>(receivedMessage.get_uint8_at(7)) << 24);
retVal |= set_latitude(decodedLatitude);
retVal |= set_longitude(decodedLongitude);
retVal |= set_timestamp(SystemTiming::get_timestamp_ms());
set_timestamp(SystemTiming::get_timestamp_ms());
}
else
{
Expand Down Expand Up @@ -452,7 +452,7 @@ namespace isobus
retVal |= set_course_over_ground_reference(static_cast<CourseOverGroundReference>(receivedMessage.get_uint8_at(1) & 0x03));
retVal |= set_course_over_ground(receivedMessage.get_uint16_at(2));
retVal |= set_speed_over_ground(receivedMessage.get_uint16_at(4));
retVal |= set_timestamp(SystemTiming::get_timestamp_ms());
set_timestamp(SystemTiming::get_timestamp_ms());
}
else
{
Expand Down Expand Up @@ -575,7 +575,7 @@ namespace isobus
retVal |= set_time_delta(receivedMessage.get_uint8_at(1));
retVal |= set_latitude_delta(receivedMessage.get_uint24_at(2));
retVal |= set_longitude_delta(receivedMessage.get_uint24_at(5));
retVal |= set_timestamp(SystemTiming::get_timestamp_ms());
set_timestamp(SystemTiming::get_timestamp_ms());
}
else
{
Expand Down

0 comments on commit 7cd8c88

Please sign in to comment.