15#include "isobus/utility/system_timing.hpp"
23 sourceControlFunction(internalControlFunction),
24 txFlags(static_cast<std::uint32_t>(
TransmitFlags::NumberOfFlags), process_flags, this),
25 actAsISBServer(serverEnabled)
69 LOG_ERROR(
"[ISB]: All implement operations must stop. (Triggered internally)");
73 LOG_INFO(
"[ISB]: Internal ISB state is now permitted.");
80 LOG_ERROR(
"[ISB]: You are attempting to set the internal ISB state but the ISB interface is not configured as a server!");
98 retVal = ISB->commandedState;
112 return SystemTiming::time_expired_ms(isb.messageReceivedTimestamp_ms, TRANSMISSION_TIMEOUT_MS);
123 assert(
nullptr != parentPointer);
131 bool transmitSuccessful =
true;
132 assert(
nullptr != parent);
136 transmitSuccessful = myInterface->send_stop_all_implement_operations_switch_state();
138 if (transmitSuccessful)
140 myInterface->stopAllImplementOperationsTransitionNumber++;
144 if (!transmitSuccessful)
146 myInterface->txFlags.set_flag(flag);
158 auto matches_isoname = [messageNAME](
ISBServerData &isb) {
return isb.ISONAME == messageNAME; };
160 auto &messageData = message.
get_data();
175 std::uint8_t newTransitionCount = messageData.at(6);
177 if (((ISB->stopAllImplementOperationsTransitionNumber == 255) &&
178 (0 != newTransitionCount)) ||
179 ((ISB->stopAllImplementOperationsTransitionNumber < 255) &&
180 (newTransitionCount > ISB->stopAllImplementOperationsTransitionNumber + 1)))
191 ISB->messageReceivedTimestamp_ms = SystemTiming::get_timestamp_ms();
192 ISB->stopAllImplementOperationsTransitionNumber = messageData.at(6);
195 if (previousState != newState)
203 LOG_INFO(
"[ISB]: Implement operations now permitted.");
211 LOG_WARNING(
"[ISB]: Received malformed All Implements Stop Operations Switch State. DLC must be 8.");
218 std::array<std::uint8_t, CAN_DATA_LENGTH> buffer = {
226 static_cast<std::uint8_t
>(0xFC |
static_cast<std::uint8_t
>(
commandedState))
General constants used throughout this library.
Defines some PGNs that are used in the library or are very common.
The main class that manages the ISOBUS stack including: callbacks, Name to Address management,...
A class that acts as a logging sink. The intent is that someone could make their own derived class of...
@ Priority3
Priority highest - 3 (Control messages priority)
std::uint8_t get_source_address() const
Returns the source address of the frame encoded in the identifier.
std::uint32_t get_parameter_group_number() const
Returns the PGN encoded in the identifier.
A class that represents a generic CAN message of arbitrary length.
std::uint8_t get_can_port_index() const
Returns the CAN channel index associated with the message.
const std::vector< std::uint8_t > & get_data() const
Gets a reference to the data in the CAN message.
std::uint32_t get_data_length() const
Returns the length of the data in the CAN message.
std::shared_ptr< ControlFunction > get_source_control_function() const
Gets the source control function that the message is from.
CANIdentifier get_identifier() const
Returns the identifier of the message.
void add_global_parameter_group_number_callback(std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent)
This is how you register a callback for any PGN destined for the global address (0xFF)
static CANNetworkManager CANNetwork
Static singleton of the one network manager. Use this to access stack functionality.
void remove_global_parameter_group_number_callback(std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent)
This is how you remove a callback for any PGN destined for the global address (0xFF)
bool send_can_message(std::uint32_t parameterGroupNumber, const std::uint8_t *dataBuffer, std::uint32_t dataLength, std::shared_ptr< InternalControlFunction > sourceControlFunction, std::shared_ptr< ControlFunction > destinationControlFunction=nullptr, CANIdentifier::CANPriority priority=CANIdentifier::CANPriority::PriorityDefault6, TransmitCompleteCallback txCompleteCallback=nullptr, void *parentPointer=nullptr, DataChunkCallback frameChunkCallback=nullptr)
This is the main way to send a CAN message of any length.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
constexpr std::uint8_t CAN_DATA_LENGTH
The length of a classical CAN frame.