FIU Serial Library 1.0.0
FIU Serial Library
Loading...
Searching...
No Matches
C Interface

This interface provides a wrapper around the C++ library for use in C and other languages. More...

Collaboration diagram for C Interface:

Topics

 Error Codes
 Error codes returned by the FIU client functions.
 Channel States
 FIU channel states.

Classes

struct  FiuFirmwareVersion
 FIU firmware version. More...

Typedefs

typedef void * FiuClientHandle
 FIU client handle.

Functions

FIU_API unsigned int FiuClient_Version ()
 Get the version of the library as an unsigned base 10 integer.
FIU_API const char * FiuClient_ErrorMessage (int error)
 Get a message describing an error code returned by the library.
FIU_API int FiuClient_Init (FiuClientHandle *handle_out)
 Initialize an FIU client.
FIU_API void FiuClient_Destroy (FiuClientHandle *handle)
 Destroy an FIU client.
FIU_API int FiuClient_Open (FiuClientHandle handle, const char *port)
 Open a serial connection to the FIU.
FIU_API int FiuClient_Close (FiuClientHandle handle)
 Close the serial port.
FIU_API int FiuClient_SetBoxID (FiuClientHandle handle, uint8_t box_id)
 Set the target box ID.
FIU_API int FiuClient_GetBoxID (FiuClientHandle handle, uint8_t *box_id_out)
 Get the target box ID.
FIU_API int FiuClient_SetChannelState (FiuClientHandle handle, unsigned int channel, uint8_t state)
 Set the state of a channel.
FIU_API int FiuClient_SetAllChannelStates (FiuClientHandle handle, uint8_t state)
 Set the state of all channels.
FIU_API int FiuClient_GetChannelStates (FiuClientHandle handle, uint8_t states_out[], unsigned int states_len)
 Get the states of all 24 channels.
FIU_API int FiuClient_GetFirmwareVersion (FiuClientHandle handle, FiuFirmwareVersion *version_out)
 Get the firmware version loaded onto the FIU.
FIU_API int FiuClient_SetSoftwareInterlock (FiuClientHandle handle, bool en)
 Set the state of the software interlock.
FIU_API int FiuClient_GetInterlockState (FiuClientHandle handle, bool *interlock_out)
 Get the system interlock state.

Detailed Description

This interface provides a wrapper around the C++ library for use in C and other languages.

Function Documentation

◆ FiuClient_Close()

FIU_API int FiuClient_Close ( FiuClientHandle handle)

Close the serial port.

Note
This does not destroy the client.
Parameters
[in]handleFIU client
Returns
0 on success or a negative error code.

◆ FiuClient_Destroy()

FIU_API void FiuClient_Destroy ( FiuClientHandle * handle)

Destroy an FIU client.

Parameters
[in,out]handlepointer to a handle to destroy

◆ FiuClient_ErrorMessage()

FIU_API const char * FiuClient_ErrorMessage ( int error)

Get a message describing an error code returned by the library.

Note
This function never returns a null pointer.
Parameters
[in]errorerror code
Returns
A null-terminated error message.

◆ FiuClient_GetBoxID()

FIU_API int FiuClient_GetBoxID ( FiuClientHandle handle,
uint8_t * box_id_out )

Get the target box ID.

Parameters
[in]handleFIU client
[out]box_id_outaddress of an integer to store the box ID
Returns
0 on success or a negative error code.

◆ FiuClient_GetChannelStates()

FIU_API int FiuClient_GetChannelStates ( FiuClientHandle handle,
uint8_t states_out[],
unsigned int states_len )

Get the states of all 24 channels.

Parameters
[in]handleFIU client
[out]states_outarray to store states in
[in]states_lenlength of states_out
Returns
0 on success or a negative error code.

◆ FiuClient_GetFirmwareVersion()

FIU_API int FiuClient_GetFirmwareVersion ( FiuClientHandle handle,
FiuFirmwareVersion * version_out )

Get the firmware version loaded onto the FIU.

Parameters
[in]handleFIU client
[out]version_outaddress of a firmware version structure to store the result
Returns
0 on success or a negative error code.

◆ FiuClient_GetInterlockState()

FIU_API int FiuClient_GetInterlockState ( FiuClientHandle handle,
bool * interlock_out )

Get the system interlock state.

Parameters
[in]handleFIU client
[out]interlock_outaddress of a bool to store the interlock state
Returns
0 on success or a negative error code.

◆ FiuClient_Init()

FIU_API int FiuClient_Init ( FiuClientHandle * handle_out)

Initialize an FIU client.

Note
The caller must destroy the client with FiuClient_Destroy() when it is no longer needed.
Parameters
[out]handle_outpointer to a handle to initialize (handle should be zeroed)
Returns
0 on success or a negative error code.

◆ FiuClient_Open()

FIU_API int FiuClient_Open ( FiuClientHandle handle,
const char * port )

Open a serial connection to the FIU.

Parameters
[in]handleFIU client
[in]portserial port to open (e.g., COM4)
Returns
0 on success or a negative error code.

◆ FiuClient_SetAllChannelStates()

FIU_API int FiuClient_SetAllChannelStates ( FiuClientHandle handle,
uint8_t state )

Set the state of all channels.

This function can only be used with the connected and disconnected states, as the others require the use of shared resources.

Parameters
[in]handleFIU client
[in]statedesired channel state (see Channel States)
Returns
0 on success or a negative error code.

◆ FiuClient_SetBoxID()

FIU_API int FiuClient_SetBoxID ( FiuClientHandle handle,
uint8_t box_id )

Set the target box ID.

This can be changed on the fly to target multiple devices on the same bus.

Parameters
[in]handleFIU client
[in]box_idnew target box ID, 0-6
Returns
0 on success or a negative error code.

◆ FiuClient_SetChannelState()

FIU_API int FiuClient_SetChannelState ( FiuClientHandle handle,
unsigned int channel,
uint8_t state )

Set the state of a channel.

Parameters
[in]handleFIU client
[in]channeltarget channel, 0-23
[in]statedesired channel state (see Channel States)
Returns
0 on success or a negative error code.

◆ FiuClient_SetSoftwareInterlock()

FIU_API int FiuClient_SetSoftwareInterlock ( FiuClientHandle handle,
bool en )

Set the state of the software interlock.

Parameters
[in]handleFIU client
[in]enwhether to enable the software interlock
Returns
0 on success or a negative error code.

◆ FiuClient_Version()

FIU_API unsigned int FiuClient_Version ( )

Get the version of the library as an unsigned base 10 integer.

For example, version 1.2.3 would return 10203.

This is intended to be used to check for the existence of certain functionality based on library version, particularly in wrappers (such as Python).

Returns
The library version.