10#ifndef CAN_ADDRESS_CLAIM_STATE_MACHINE_HPP
11#define CAN_ADDRESS_CLAIM_STATE_MACHINE_HPP
A class that represents a control function's NAME.
General constants used throughout this library.
Forward declare CANMessage.
std::uint8_t m_randomClaimDelay_ms
The random delay as required by the ISO11783 standard.
bool send_address_claim(std::uint8_t address)
Sends the address claim message.
void process_commanded_address(std::uint8_t commandedAddress)
Attempts to process a commanded address.
void update()
Updates the state machine, should be called periodically.
void set_current_state(State value)
Sets the current state machine state.
std::uint32_t m_timestamp_ms
A generic timestamp in milliseconds used to find timeouts.
std::uint8_t m_preferredAddress
The address we'd prefer to claim as (we may not get it)
std::uint8_t get_claimed_address() const
Returns the address claimed by the state machine or 0xFE if none claimed.
NAME m_isoname
The ISO NAME to claim as.
State get_current_state() const
Returns the current state of the state machine.
std::uint8_t m_portIndex
The CAN channel index to claim on.
std::uint8_t m_claimedAddress
The actual address we ended up claiming.
bool send_request_to_claim() const
Sends the PGN request for the address claim PGN.
State
Defines the state machine states for address claiming.
@ WaitForRequestContentionPeriod
State machine is waiting for the address claim contention period.
@ SendRequestForClaim
State machine is sending the request for address claim.
@ UnableToClaim
State machine could not claim an address.
@ SendReclaimAddressOnRequest
An ECU requested address claim, inform the bus of our current address.
@ None
Address claiming is uninitialized.
@ SendPreferredAddressClaim
State machine is claiming the preferred address.
@ WaitForClaim
State machine is waiting for the random delay time.
@ ContendForPreferredAddress
State machine is contending the preferred address.
@ SendArbitraryAddressClaim
State machine is claiming an address.
@ AddressClaimingComplete
Address claiming is complete and we have an address.
void on_address_violation()
Used to inform the address claim state machine that two CFs are using the same source address....
bool m_enabled
Enable/disable state for this state machine.
AddressClaimStateMachine(std::uint8_t preferredAddressValue, NAME ControlFunctionNAME, std::uint8_t portIndex)
The constructor of the state machine class.
~AddressClaimStateMachine()
The destructor for the address claim state machine.
void set_is_enabled(bool value)
Enables or disables the address claimer.
State m_currentState
The address claim state machine state.
static void process_rx_message(const CANMessage &message, void *parentPointer)
Processes a CAN message.
bool get_enabled() const
Returns if the address claimer is enabled.
A class that represents a generic CAN message of arbitrary length.
A class that represents an ISO11783 control function NAME from an address claim.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
constexpr std::uint8_t NULL_CAN_ADDRESS
The NULL CAN address defined by J1939 and ISO11783.