WPILibC++ 2023.4.3
Main loop functions

Functions

void HAL_SetMain (void *param, void(*mainFunc)(void *), void(*exitFunc)(void *))
 Sets up the system to run the provided main loop in the main thread (e.g. More...
 
HAL_Bool HAL_HasMain (void)
 Returns true if HAL_SetMain() has been called. More...
 
void HAL_RunMain (void)
 Runs the main function provided to HAL_SetMain(). More...
 
void HAL_ExitMain (void)
 Causes HAL_RunMain() to exit. More...
 
HAL_RelayHandle HAL_InitializeRelayPort (HAL_PortHandle portHandle, HAL_Bool fwd, const char *allocationLocation, int32_t *status)
 Initializes a relay. More...
 
void HAL_FreeRelayPort (HAL_RelayHandle relayPortHandle)
 Frees a relay port. More...
 
HAL_Bool HAL_CheckRelayChannel (int32_t channel)
 Checks if a relay channel is valid. More...
 
void HAL_SetRelay (HAL_RelayHandle relayPortHandle, HAL_Bool on, int32_t *status)
 Sets the state of a relay output. More...
 
HAL_Bool HAL_GetRelay (HAL_RelayHandle relayPortHandle, int32_t *status)
 Gets the current state of the relay channel. More...
 

Detailed Description

Function Documentation

◆ HAL_CheckRelayChannel()

HAL_Bool HAL_CheckRelayChannel ( int32_t  channel)

Checks if a relay channel is valid.

Parameters
channelthe channel to check
Returns
true if the channel is valid, otherwise false

◆ HAL_ExitMain()

void HAL_ExitMain ( void  )

Causes HAL_RunMain() to exit.

If HAL_SetMain() has been called, this calls the exit function provided to that function.

◆ HAL_FreeRelayPort()

void HAL_FreeRelayPort ( HAL_RelayHandle  relayPortHandle)

Frees a relay port.

Parameters
relayPortHandlethe relay handle

◆ HAL_GetRelay()

HAL_Bool HAL_GetRelay ( HAL_RelayHandle  relayPortHandle,
int32_t *  status 
)

Gets the current state of the relay channel.

Parameters
[in]relayPortHandlethe relay handle
[out]statusError status variable. 0 on success.
Returns
true for on, false for off

◆ HAL_HasMain()

HAL_Bool HAL_HasMain ( void  )

Returns true if HAL_SetMain() has been called.

Returns
True if HAL_SetMain() has been called, false otherwise.

◆ HAL_InitializeRelayPort()

HAL_RelayHandle HAL_InitializeRelayPort ( HAL_PortHandle  portHandle,
HAL_Bool  fwd,
const char *  allocationLocation,
int32_t *  status 
)

Initializes a relay.

Note this call will only initialize either the forward or reverse port of the relay. If you need both, you will need to initialize 2 relays.

Parameters
[in]portHandlethe port handle to initialize
[in]fwdtrue for the forward port, false for the reverse port
[in]allocationLocationthe location where the allocation is occurring (can be null)
[out]statusError status variable. 0 on success.
Returns
the created relay handle

◆ HAL_RunMain()

void HAL_RunMain ( void  )

Runs the main function provided to HAL_SetMain().

If HAL_SetMain() has not been called, simply sleeps until HAL_ExitMain() is called.

◆ HAL_SetMain()

void HAL_SetMain ( void *  param,
void(*)(void *)  mainFunc,
void(*)(void *)  exitFunc 
)

Sets up the system to run the provided main loop in the main thread (e.g.

the thread in which main() starts execution) and run the robot code in a separate thread.

Normally the robot code runs in the main thread, but some GUI systems require the GUI be run in the main thread.

To be effective, this function must be called before the robot code starts the main loop (e.g. by frc::StartRobot()).

Parameters
paramparameter data to pass to mainFunc and exitFunc
mainFuncthe function to be run when HAL_RunMain() is called.
exitFuncthe function to be run when HAL_ExitMain() is called.

◆ HAL_SetRelay()

void HAL_SetRelay ( HAL_RelayHandle  relayPortHandle,
HAL_Bool  on,
int32_t *  status 
)

Sets the state of a relay output.

Parameters
[in]relayPortHandlethe relay handle
[in]ontrue for on, false for off
[out]statusError status variable. 0 on success.