Skip to content

Commit

Permalink
Update CAN Stack to latest AgIsoStack
Browse files Browse the repository at this point in the history
Updated AgIsoStack to 29dab887a48bb204aae983b06052d52b0f2314d5
  • Loading branch information
ad3154 committed Oct 20, 2024
1 parent a2cdca9 commit d5b5dce
Show file tree
Hide file tree
Showing 92 changed files with 3,654 additions and 2,603 deletions.
10 changes: 5 additions & 5 deletions examples/VirtualTerminal/VirtualTerminal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ void setup() {
deviceNAME.set_ecu_instance(0);
deviceNAME.set_function_instance(0);
deviceNAME.set_device_class_instance(0);
deviceNAME.set_manufacturer_code(64);
// Change 0x81 to be your preferred address, but 0x81 is the base arbitrary address
ISOBUSControlFunction = InternalControlFunction::create(deviceNAME, 0x81, 0);
deviceNAME.set_manufacturer_code(1407); // This is the Open-Agriculture manufacturer code. You are welcome to use it if you want.
// If you want to set a preferred address, you can add another parameter below, like (deviceNAME, 0, 0x81), otherwise the CAN stack will choose one automatically.
ISOBUSControlFunction = CANNetworkManager::CANNetwork.create_internal_control_function(deviceNAME, 0);
ISOBUSDiagnostics = std::make_shared<DiagnosticProtocol>(ISOBUSControlFunction);
ISOBUSDiagnostics->initialize();

Expand All @@ -142,11 +142,11 @@ void setup() {
// Set up virtual terminal client
const NAMEFilter filterVirtualTerminal(NAME::NAMEParameters::FunctionCode, static_cast<std::uint8_t>(NAME::Function::VirtualTerminal));
const std::vector<NAMEFilter> vtNameFilters = { filterVirtualTerminal };
auto TestPartnerVT = PartneredControlFunction::create(0, vtNameFilters);
auto TestPartnerVT = CANNetworkManager::CANNetwork.create_partnered_control_function(0, vtNameFilters);
ExampleVirtualTerminalClient = std::make_shared<VirtualTerminalClient>(TestPartnerVT, ISOBUSControlFunction);
ExampleVirtualTerminalClient->set_object_pool(0, VT3TestPool, sizeof(VT3TestPool), "AIS1");
ExampleVirtualTerminalClient->get_vt_button_event_dispatcher().add_listener(handleVTKeyEvents);
ExampleVirtualTerminalClient->get_vt_button_event_dispatcher().add_listener(handleVTKeyEvents);
ExampleVirtualTerminalClient->get_vt_soft_key_event_dispatcher().add_listener(handleVTKeyEvents);
ExampleVirtualTerminalClient->initialize(false);
}

Expand Down
93 changes: 47 additions & 46 deletions src/AgIsoStack.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
** @file AgIsoStack.hpp
** @author Automatic Code Generation
** @date February 08, 2024 at 19:36:28
** @date October 19, 2024 at 23:45:04
** @brief Includes all important files in the AgIsoStack library.
**
** Copyright 2024 The AgIsoStack++ Developers
Expand All @@ -10,62 +10,63 @@
#ifndef AG_ISO_STACK_HPP
#define AG_ISO_STACK_HPP

#include <can_address_claim_state_machine.hpp>
#include <can_badge.hpp>
#include <can_hardware_plugin.hpp>
#include <flex_can_t4_plugin.hpp>
#include <can_callbacks.hpp>
#include <can_constants.hpp>
#include <isobus_language_command_interface.hpp>
#include <isobus_virtual_terminal_client.hpp>
#include <can_NAME.hpp>
#include <event_dispatcher.hpp>
#include <can_partnered_control_function.hpp>
#include <isobus_time_date_interface.hpp>
#include <circular_buffer.hpp>
#include <can_network_configuration.hpp>
#include <can_network_manager.hpp>
#include <isobus_maintain_power_interface.hpp>
#include <can_message_frame.hpp>
#include <nmea2000_message_definitions.hpp>
#include <can_control_function.hpp>
#include <can_extended_transport_protocol.hpp>
#include <can_general_parameter_group_numbers.hpp>
#include <can_hardware_abstraction.hpp>
#include <can_hardware_interface_single_thread.hpp>
#include <can_hardware_plugin.hpp>
#include <can_identifier.hpp>
#include <isobus_shortcut_button_interface.hpp>
#include <kinetis_flexcan.hpp>
#include <isobus_guidance_interface.hpp>
#include <isobus_functionalities.hpp>
#include <isobus_task_controller_client_objects.hpp>
#include <isobus_device_descriptor_object_pool.hpp>
#include <nmea2000_message_interface.hpp>
#include <isobus_virtual_terminal_objects.hpp>
#include <can_internal_control_function.hpp>
#include <can_message.hpp>
#include <isobus_virtual_terminal_base.hpp>
#include <isobus_data_dictionary.hpp>
#include <can_message_data.hpp>
#include <can_message_frame.hpp>
#include <can_NAME.hpp>
#include <can_NAME_filter.hpp>
#include <can_network_configuration.hpp>
#include <can_network_manager.hpp>
#include <isobus_standard_data_description_indices.hpp>
#include <isobus_virtual_terminal_client_state_tracker.hpp>
#include <thread_synchronization.hpp>
#include <isobus_task_controller_client.hpp>
#include <processing_flags.hpp>
#include <nmea2000_fast_packet_protocol.hpp>
#include <isobus_preferred_addresses.hpp>
#include <to_string.hpp>
#include <can_parameter_group_number_request_protocol.hpp>
#include <can_partnered_control_function.hpp>
#include <can_protocol.hpp>
#include <can_stack_logger.hpp>
#include <platform_endianness.hpp>
#include <can_extended_transport_protocol.hpp>
#include <imxrt_flexcan.hpp>
#include <can_transport_protocol.hpp>
#include <can_transport_protocol_base.hpp>
#include <circular_buffer.hpp>
#include <can_NAME_filter.hpp>
#include <data_span.hpp>
#include <event_dispatcher.hpp>
#include <can_identifier.hpp>
#include <FlexCAN_T4.hpp>
#include <flex_can_t4_plugin.hpp>
#include <imxrt_flexcan.hpp>
#include <isobus_data_dictionary.hpp>
#include <isobus_device_descriptor_object_pool.hpp>
#include <isobus_diagnostic_protocol.hpp>
#include <isobus_functionalities.hpp>
#include <isobus_guidance_interface.hpp>
#include <isobus_language_command_interface.hpp>
#include <isobus_maintain_power_interface.hpp>
#include <isobus_preferred_addresses.hpp>
#include <isobus_shortcut_button_interface.hpp>
#include <isobus_speed_distance_messages.hpp>
#include <isobus_standard_data_description_indices.hpp>
#include <isobus_task_controller_client.hpp>
#include <isobus_task_controller_client_objects.hpp>
#include <isobus_virtual_terminal_client.hpp>
#include <isobus_virtual_terminal_client_state_tracker.hpp>
#include <isobus_heartbeat.hpp>
#include <isobus_virtual_terminal_client_update_helper.hpp>
#include <isobus_virtual_terminal_objects.hpp>
#include <kinetis_flexcan.hpp>
#include <nmea2000_fast_packet_protocol.hpp>
#include <nmea2000_message_definitions.hpp>
#include <nmea2000_message_interface.hpp>
#include <platform_endianness.hpp>
#include <processing_flags.hpp>
#include <can_hardware_abstraction.hpp>
#include <system_timing.hpp>
#include <thread_synchronization.hpp>
#include <to_string.hpp>
#include <can_constants.hpp>
#include <can_badge.hpp>
#include <can_stack_logger.hpp>
#include <can_message.hpp>
#include <isobus_speed_distance_messages.hpp>
#include <isobus_diagnostic_protocol.hpp>
#include <can_hardware_interface_single_thread.hpp>

#endif // AG_ISO_STACK_HPP
16 changes: 8 additions & 8 deletions src/can_NAME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// @brief A class that represents a control function's NAME
/// @author Adrian Del Grosso
///
/// @copyright 2022 Adrian Del Grosso
/// @copyright 2022 The Open-Agriculture Developers
//================================================================================================
#include "can_NAME.hpp"
#include "can_stack_logger.hpp"
Expand Down Expand Up @@ -41,7 +41,7 @@ namespace isobus
{
if (value > 0x07)
{
CANStackLogger::error("[NAME]: Industry group out of range, must be between 0 and 7");
LOG_ERROR("[NAME]: Industry group out of range, must be between 0 and 7");
}
rawName &= ~static_cast<std::uint64_t>(0x7000000000000000);
rawName |= (static_cast<std::uint64_t>(value & 0x07) << 60);
Expand All @@ -56,7 +56,7 @@ namespace isobus
{
if (value > 0x0F)
{
CANStackLogger::error("[NAME]: Device class instance out of range, must be between 0 and 15");
LOG_ERROR("[NAME]: Device class instance out of range, must be between 0 and 15");
}
rawName &= ~static_cast<std::uint64_t>(0xF00000000000000);
rawName |= (static_cast<std::uint64_t>(value & 0x0F) << 56);
Expand All @@ -71,7 +71,7 @@ namespace isobus
{
if (value > 0x7F)
{
CANStackLogger::error("[NAME]: Device class out of range, must be between 0 and 127");
LOG_ERROR("[NAME]: Device class out of range, must be between 0 and 127");
}
rawName &= ~static_cast<std::uint64_t>(0xFE000000000000);
rawName |= (static_cast<std::uint64_t>(value & 0x7F) << 49);
Expand All @@ -97,7 +97,7 @@ namespace isobus
{
if (value > 0x1F)
{
CANStackLogger::error("[NAME]: Function instance out of range, must be between 0 and 31");
LOG_ERROR("[NAME]: Function instance out of range, must be between 0 and 31");
}
rawName &= ~static_cast<std::uint64_t>(0xF800000000);
rawName |= (static_cast<std::uint64_t>(value & 0x1F) << 35);
Expand All @@ -112,7 +112,7 @@ namespace isobus
{
if (value > 0x07)
{
CANStackLogger::error("[NAME]: ECU instance out of range, must be between 0 and 7");
LOG_ERROR("[NAME]: ECU instance out of range, must be between 0 and 7");
}
rawName &= ~static_cast<std::uint64_t>(0x700000000);
rawName |= (static_cast<std::uint64_t>(value & 0x07) << 32);
Expand All @@ -127,7 +127,7 @@ namespace isobus
{
if (value > 0x07FF)
{
CANStackLogger::error("[NAME]: Manufacturer code out of range, must be between 0 and 2047");
LOG_ERROR("[NAME]: Manufacturer code out of range, must be between 0 and 2047");
}
rawName &= ~static_cast<std::uint64_t>(0xFFE00000);
rawName |= (static_cast<std::uint64_t>(value & 0x07FF) << 21);
Expand All @@ -142,7 +142,7 @@ namespace isobus
{
if (value > 0x001FFFFF)
{
CANStackLogger::error("[NAME]: Identity number out of range, must be between 0 and 2097151");
LOG_ERROR("[NAME]: Identity number out of range, must be between 0 and 2097151");
}
rawName &= ~static_cast<std::uint64_t>(0x1FFFFF);
rawName |= static_cast<std::uint64_t>(value & 0x1FFFFF);
Expand Down
83 changes: 82 additions & 1 deletion src/can_NAME.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// @brief A class that represents a control function's NAME
/// @author Adrian Del Grosso
///
/// @copyright 2022 Adrian Del Grosso
/// @copyright 2022 The Open-Agriculture Developers
//================================================================================================

#ifndef CAN_NAME_HPP
Expand Down Expand Up @@ -37,6 +37,21 @@ namespace isobus
ArbitraryAddressCapable ///< Defines if this ECU supports address arbitration
};

/// @brief The industry group is part of the ISO NAME.
/// It allocates devices and their functions by a specific industry.
/// Function codes' meanings are defined in relation to industry group and device class.
enum class IndustryGroup : std::uint8_t
{
Global = 0, ///< Global applies to all industries
OnHighwayEquipment = 1,
AgriculturalAndForestryEquipment = 2,
ConstructionEquipment = 3,
Marine = 4,
IndustrialOrProcessControl = 5,
Reserved1 = 6, ///< Reserved for future assignment by SAE. Should not be used.
Reserved2 = 7 ///< Reserved for future assignment by SAE. Should not be used.
};

/// @brief See ISO11783-1 and www.isobus.net For complete descriptions of the ISO NAME function codes
/// @note Functions are defined in relation to industry group and device class. See www.isobus.net for more info.
enum class Function : std::uint8_t
Expand Down Expand Up @@ -341,6 +356,72 @@ namespace isobus
MaxFunctionCode = 255 ///< Max allocated function code
};

/// @brief The device class is part of the ISO NAME and is known in J1939 as the "vehicle system".
/// This is a 7-bit field defined and assigned by SAE.
/// Device class provides a common name for a group of functions
/// within a connected network.
enum class DeviceClass
{
NonSpecific = 0,
Tractor = 1, ///< Industry Group 1 and 2
SkidSteerLoader = 1, ///< Industry Group 3
Trailer = 2, ///< Industry group 1 and 2
ArticulatedDumpTruck = 2, ///< Industry group 3
SecondaryTillage = 3, ///< Industry group 2
Backhoe = 3, ///< Industry group 3
PlanterSeeder = 4, ///< Industry group 2
Crawler = 4, ///< Industry group 3
Fertilizer = 5, ///< Industry group 2
Excavator = 5, ///< Industry group 3
Sprayer = 6, ///< Industry group 2
Forklift = 6, ///< Industry group 3
Harvester = 7, ///< Industry group 2
FourWheelDriveLoader = 7, ///< Industry group 3
RootHarvester = 8, ///< Industry group 2
Grader = 8, ///< Industry group 3
Forage = 9, ///< Industry group 2
MillingMachine = 9, ///< Industry group 3
Irrigation = 10, ///< Industry group 2
RecyclerAndSoilStabilizer = 10, ///< Industry group 3
SystemTools = 10, ///< Industry group 4
TransportTrailer = 11, ///< Industry group 2
BindingAgentSpreader = 11, ///< Industry group 3
FarmYardOperations = 12, ///< Industry group 2
Paver = 12, ///< Industry group 3
PoweredAuxiliaryDevices = 13, ///< Industry group 2
Feeder = 13, ///< Industry group 3
SpecialCrops = 14, ///< Industry group 2
ScreeningPlant = 14, ///< Industry group 3
Earthwork = 15, ///< Industry group 2
Stacker = 15, ///< Industry group 3
Skidder = 16, ///< Industry group 2
Roller = 16, ///< Industry group 3
SensorSystems = 17, ///< Industry group 2
Crusher = 17, ///< Industry group 3
TimberHarvester = 19, ///< Industry group 2
Forwarder = 20, ///< Industry group 2
SafetySystems = 20, ///< Industry group 4
TimberLoader = 21, ///< Industry group 2
TimberProcessor = 22, ///< Industry group 2
Mulcher = 23, ///< Industry group 2
UtilityVehicle = 24, ///< Industry group 2
SlurryManureApplicator = 25, ///< Industry group 2
Gateway = 25, ///< Industry group 4
FeederMixer = 26, ///< Industry group 2
WeederNonChemical = 27, ///< Industry group 2
TurfOrLawnCareMower = 28, ///< Industry group 2
ProductMaterialHandling = 29, ///< Industry group 2
PowerManagementAndLightingSystem = 30, ///< Industry group 4
SteeringSystems = 40, ///< Industry group 4
PropulsionSystems = 50, ///< Industry group 4
NavigationSystems = 60, ///< Industry group 4
CommunicationsSystems = 70, ///< Industry group 4
InstrumentationOrGeneral = 80, ///< Industry group 4
EnvironmentalHVACSystem = 90, ///< Industry group 4
DeckCargoOrFishingEquipment = 100, ///< Industry group 4
NotAvailable = 127 //< Applicable to all IGs
};

/// @brief A useful way to compare session objects to each other for equality
/// @param[in] obj The rhs of the operator
/// @returns `true` if the objects are "equal"
Expand Down
2 changes: 1 addition & 1 deletion src/can_NAME_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// ECU you want to talk to when creating a partnered control function.
/// @author Adrian Del Grosso
///
/// @copyright 2022 Adrian Del Grosso
/// @copyright 2022 The Open-Agriculture Developers
//================================================================================================
#include "can_NAME_filter.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/can_NAME_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// ECU you want to talk to when creating a partnered control function.
/// @author Adrian Del Grosso
///
/// @copyright 2022 Adrian Del Grosso
/// @copyright 2022 The Open-Agriculture Developers
//================================================================================================

#ifndef CAN_NAME_FILTER_HPP
Expand Down
Loading

0 comments on commit d5b5dce

Please sign in to comment.