MX Foundation 4

Functions

uint32 mxfFlexDIOModeSet (HMXF_CHANNEL channel, uint64 pin, uint64 mode)
 
uint32 mxfFlexDIOModeGet (HMXF_CHANNEL channel, uint64 pin, uint64 *mode)
 
uint32 mxfFlexDIOTemperatureGet (HMXF_CHANNEL channel, double *value)
 
uint32 mxfFlexDIOCurrentLimitSet (HMXF_CHANNEL channel, uint64 pin, uint64 limit)
 
uint32 mxfFlexDIOCurrentLimitGet (HMXF_CHANNEL channel, uint64 pin, uint64 *limit)
 
uint32 mxfFlexDIOAlarmGet (HMXF_CHANNEL channel, uint64 *global, uint64 *chnCurrent)
 
uint32 mxfFlexDIORxSamplingSync (HMXF_CHANNEL channel, uint64 period, uint64 startTime)
 
uint32 mxfFlexDIOTxAperiodicWrite (HMXF_BUFFER buffer, uint64 options, uint64 startTime, uint64 count, MXF_FLEXDIO_DATAREC *rec)
 
uint32 mxfFlexDIORxAcqRead (HMXF_BUFFER buffer, uint64 maxMsgCount, uint64 maxBytesCount, uint64 *status, uint64 *msgCount, uint64 *byteCount, MXF_FLEXDIO_DATAREC *rec)
 
uint32 mxfFlexDIORxSamplingRead (HMXF_BUFFER buffer, uint64 flags, uint64 maxMsgCount, uint64 maxBytesCount, uint64 *msgCount, uint64 *byteCount, MXF_FLEXDIO_SAMPREC *rec)
 
uint32 mxfFlexDIONextDataRecordPtrGet (MXF_FLEXDIO_DATAREC *currentRec, MXF_FLEXDIO_DATAREC **nextRec)
 
uint32 mxfFlexDIOChannelRead (HMXF_CHANNEL channel, uint64 mask, uint64 *data)
 
uint32 mxfFlexDIOChannelWrite (HMXF_CHANNEL channel, uint64 mask, uint64 data)
 

Detailed Description

Function Documentation

uint32 mxfFlexDIOModeSet ( HMXF_CHANNEL  channel,
uint64  pin,
uint64  mode 
)
C#
public static extern UInt32 mxfFlexDIOModeSet(UInt64 channel, UInt64 pin, UInt64 mode);

Sets the mode of a discrete pin.

Parameters
[in]channelchannel handle.
[in]pinport pin number.
[in]modedesired mode.
Mode Meaning Value
MXF_FLEXDIO_MODE_IN The pin is an input 0
MXF_FLEXDIO_MODE_IN_PULLUP The pin in an input with internal pull-up of 12 kOhm 1
MXF_FLEXDIO_MODE_OUT_HS The pin is an output (High-Side, Open/28V) 2
MXF_FLEXDIO_MODE_OUT_LS The pin is an output (Low-Side, Open/Ground) 3
MXF_FLEXDIO_MODE_OUT_LS_PULLUP The pin is an output with internal pull-up (Low-Side, Open/Ground) 4
MXF_FLEXDIO_MODE_OUT_PP The pin is an output (Push-pull) 5
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOModeGet()
Examples:
flexdio.c, flexdio_event_handler.c, flexdio_fifo.c, flexdio_fifo_sampling.c, flexdio_sampling_acq.c, and flexdio_sync.c.
uint32 mxfFlexDIOModeGet ( HMXF_CHANNEL  channel,
uint64  pin,
uint64 *  mode 
)
C#
public static extern UInt32 mxfFlexDIOModeGet(UInt64 channel, UInt64 pin, out UInt64 mode);

Gets the mode of a discrete pin.

Parameters
[in]channelchannel handle.
[in]pinport pin number.
[out]modereturned mode.
Mode Meaning Value
MXF_FLEXDIO_MODE_IN The pin is an input 0
MXF_FLEXDIO_MODE_IN_PULLUP The pin in an input with internal pull-up of 12 kOhm 1
MXF_FLEXDIO_MODE_OUT_HS The pin is an output (High-Side, Open/28V) 2
MXF_FLEXDIO_MODE_OUT_LS The pin is an output (Low-Side, Open/Ground) 3
MXF_FLEXDIO_MODE_OUT_LS_PULLUP The pin is an output with internal pull-up (Low-Side, Open/Ground) 4
MXF_FLEXDIO_MODE_OUT_PP The pin is an output (Push-pull) 5
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOModeSet()
uint32 mxfFlexDIOTemperatureGet ( HMXF_CHANNEL  channel,
double *  value 
)
C#
public static extern UInt32 mxfFlexDIOTemperatureGet(UInt64 channel, out double value);

Gets the temperature of a discrete channel.

Parameters
[in]channelchannel handle.
[out]valuereturned temperature.
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOModeSet()
uint32 mxfFlexDIOCurrentLimitSet ( HMXF_CHANNEL  channel,
uint64  pin,
uint64  limit 
)
C#
public static extern UInt32 mxfFlexDIOCurrentLimitSet(UInt64 channel, UInt64 pin, UInt64 limit);

Sets the current limit of pin 0 or 32 of a discrete channel.

This function can't be used when the physical jumper is present.

Parameters
[in]channelchannel handle.
[in]pinport pin number (0 or 32).
[in]limitdesired current limit.
Current Limit Meaning Value
MXF_FLEXDIO_CURRENT_LIMIT_LOW The pin current limit is 200mA 0
MXF_FLEXDIO_CURRENT_LIMIT_HIGH The pin current limit is 2A 1
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOCurrentLimitGet()
mxfFlexDIOAlarmGet()
Examples:
flexdio_fifo.c.
uint32 mxfFlexDIOCurrentLimitGet ( HMXF_CHANNEL  channel,
uint64  pin,
uint64 *  limit 
)
C#
public static extern UInt32 mxfFlexDIOCurrentLimitGet(UInt64 channel, UInt64 pin, out UInt64 limit);

Gets the current limit of pin 0 or 32 of a discrete channel.

Parameters
[in]channelchannel handle.
[in]pinport pin number (0 or 32).
[in]limitreturned current limit.
Current Limit Meaning Value
MXF_FLEXDIO_CURRENT_LIMIT_LOW The pin current limit is 200mA 0
MXF_FLEXDIO_CURRENT_LIMIT_HIGH The pin current limit is 2A 1
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOCurrentLimitSet()
mxfFlexDIOAlarmGet()
uint32 mxfFlexDIOAlarmGet ( HMXF_CHANNEL  channel,
uint64 *  global,
uint64 *  chnCurrent 
)
C#
public static extern UInt32 mxfFlexDIOAlarmGet(UInt64 channel, out UInt64 global, out UInt64 chnCurrent);

Gets the alarm status of a discrete channel.

Parameters
[in]channelchannel handle.
[out]globalreturned global status mask
Global status Meaning Value
MXF_FLEXDIO_ALARM_STS_OOR_VOLTAGE_IN The voltage is out of range 0x1
MXF_FLEXDIO_ALARM_STS_OOR_CURRENT The current is out of range 0x2
[out]chnCurrentreturned over-current channel mask (1 bit for each pin, set to 1 when pin is in over-current condition)
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOCurrentLimitSet()
Examples:
flexdio_fifo.c.
uint32 mxfFlexDIORxSamplingSync ( HMXF_CHANNEL  channel,
uint64  period,
uint64  startTime 
)
C#
public static extern UInt32 mxfFlexDIORxSamplingSync(UInt64 channel, UInt64 period, UInt64 startTime);

Sets the period and the start time of the sampling period for a channel.

Useful to synchronize the start of sampling of multiple channels at the same time.

Parameters
[in]channelchannel handle.
[in]periodperiod (1-1000 ms) based on the timebase resolution.
[in]startTimeAbsolute start time based on the timebase format (max of 30 seconds in the future).
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
Examples:
flexdio_sync.c.
uint32 mxfFlexDIOTxAperiodicWrite ( HMXF_BUFFER  buffer,
uint64  options,
uint64  startTime,
uint64  count,
MXF_FLEXDIO_DATAREC rec 
)
C#
public static extern UInt32 mxfFlexDIOTxAperiodicWrite(UInt64 buffer, UInt64 options, UInt64 startTime, UInt64 count, IntPtr rec);

Sends aperiodic data records for transmission. The data items to be transmitted are specified within the records, along with an optional time tag. The first data item is transmitted at the specified starting time.

The records to transmit on time tag must be placed in chronological order in the array. The same time tag must not appear more than once in the array. When the start time is specified the time tag of the first record or the start time should be at least 50 msec in advance to be relatively precise otherwise it will be sent as soon as possible. Also, the cumulative time of all record’s time tag and the start time must be smaller than 30 seconds.

Note
This function is the specific version for Discrete IO of the multi-protocol mxfTxAperiodicWrite() function.
Parameters
[in]bufferbuffer handle.
[in]optionsoptions for controlling the transmitter before sending the data records. The details of the options are explained below.
  • MXF_TXAPERIODIC_FLAG_DEFAULT
  • MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME
  • MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME
  • MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME
[in]startTimestart time based on the timebase. This is the time at which the data held in the first record is transmitted by the device. The time is either expressed accordingly to the process time base or relative to the current real-time clock value (i.e. offset in the future). If the bit MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME of the transmit flag is set, then the start time is specified in absolute time (rather than relative). MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME or MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME options cannot be used with a start time.
[in]countnumber of records to write.
[in]recpointer to MXF_FLEXDIO_DATAREC records to write. The records in the buffer need to be indexed using the mxfFlexDIONextDataRecordPtrGet() function.


The options modifies the transmission scheme as described below;

  • MXF_TXAPERIODIC_FLAG_DEFAULT

    This is the default transmission flag, the scheduling priority defined when the buffer area was defined (see mxfTxAperiodicBufferAlloc()) is used to schedule the transmissions.

    The time tag field is not used and must be set to 0. The records are transmitted with minimum delay between them.

  • MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME

    When set, the absolute transmit time of each data must be set in the record time tag. The time tag must be formatted according to the process time base.

    This flag cannot be used with MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME, MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME or a start time.

  • MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME

    When set, the relative transmit time of each data must be set in the record time tag. The process time base resolution is used, but the time base itself is ignored.

    This option causes transmission of the first record at the specified offset and transmission of the remaining records after a delay that is computed by subtracting the record time tag from the time tag of preceding records (i.e. delta time).

    Let’s assume N data records to be transmitted with the MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME.

    The actual record data transmit time will be computed as follows:

    Time rec1 = Transmission offset (min 50 msec)
    Time rec2 = Time rec1 + (rec2 time tag – rec1 time tag )
    Time rec3 = Time rec2 + (rec3 time tag – rec2 time tag )

    Time recN = Time recN-1 + (recN time tag - recN-1 time tag )

    This flag can’t be used with MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME, MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME or a start time.

  • MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME

    When set, the startTime parameter must be formatted according to the process time base.

    If not set, the startTime parameter is expressed as a relative time from the current real time clock value.The process time base resolution is used, but the time base itself is ignored.

    This flag cannot be used with MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME or MXF_TXAPERIODIC_FLAG_USE_RECORD_RELATIVE_TIME options.
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfTxAperiodicWrite()
mxfTxAperiodicBufferAlloc()
mxfTxAperiodicBufferStatusGet()
mxfTxAperiodicClear()
mxfSystemTimeBaseSet()
mxfFlexDIONextDataRecordPtrGet()
Examples:
flexdio_event_handler.c, and flexdio_fifo.c.
uint32 mxfFlexDIORxAcqRead ( HMXF_BUFFER  buffer,
uint64  maxMsgCount,
uint64  maxBytesCount,
uint64 *  status,
uint64 *  msgCount,
uint64 *  byteCount,
MXF_FLEXDIO_DATAREC rec 
)
C#
public static extern UInt32 mxfFlexDIORxAcqRead(UInt64 buffer, UInt64 maxMsgCount, UInt64 maxBytesCount, out UInt64 status, out UInt64 msgCount, out UInt64 byteCount, IntPtr rec);

Transfers the records from the channel acquisition buffer to the calling application.

Note
This function is the specific version for Discrete IO of the multi-protocol mxfRxAcqRead() function.
Parameters
[in]bufferbuffer handle.
[in]maxMsgCountmaximum messages to read (0 means all messages).
[in]maxBytesCountmaximum number of bytes to be read.
[out]statuslast status set.
[out]msgCountnumber of records returned.
[out]byteCountnumber of bytes returned.
[out]recaddress of data records. The records in the buffer need to be indexed using mxfFlexDIONextDataRecordPtrGet() function.

<

Note
In edge mode, the first record read after a mxfRxAcqStart() call is the current state of discrete input pins. The following records are generated according to specified discrete input transitions.
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfRxAcqRead()
mxfRxAcqStart()
mxfRxAcqBufferAlloc()
mxfRxAcqStop()
mxfFlexDIONextDataRecordPtrGet()
Examples:
flexdio_event_handler.c, flexdio_fifo.c, and flexdio_sync.c.
uint32 mxfFlexDIORxSamplingRead ( HMXF_BUFFER  buffer,
uint64  flags,
uint64  maxMsgCount,
uint64  maxBytesCount,
uint64 *  msgCount,
uint64 *  byteCount,
MXF_FLEXDIO_SAMPREC rec 
)
C#
public static extern UInt32 mxfFlexDIORxSamplingRead(UInt64 buffer, UInt64 flags, UInt64 maxMsgCount, UInt64 maxBytesCount, out UInt64 msgCount, out UInt64 byteCount, IntPtr rec);

Reads the sampling record from the sampling buffer to the application buffer.

The sampling process keeps the last record received. A record is considered received if it were received within the kill-time period. A record refresh from the receive port resets the kill-time timer and an updated copy is made available to the application.

The sampling record contains information on the arrival rate as well as the latest discrete input lines state.

Note
This function is the specific version for Discrete IO of the multi-protocol mxfRxSamplingRead() function.
Parameters
[in]bufferbuffer handle.
[in]flagsoption flag.
Flags Description
MXF_RXSAMPLING_FLAG_DEFAULT The record is kept in the buffer and the same record can be read again by the current or another application.
MXF_RXSAMPLING_FLAG_ERASE_WHEN_READ After the sampling record is returned, it is removed from the buffer.
[in]maxMsgCountmaximum number of messages to read. Normally one, maximum of one sampling record available.
[in]maxBytesCountmaximum number of bytes to read. Normally sizeof MXF_FLEXDIO_SAMPREC structure.
[out]msgCountnumber of messages returned.
[out]byteCountnumber of bytes returned.
[out]recpointer to MXF_FLEXDIO_SAMPREC record structure.
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfRxSamplingRead()
mxfRxSamplingBufferAlloc()
mxfRxSamplingMsgSelectSet()
mxfRxSamplingStart()
Examples:
flexdio_fifo_sampling.c.
uint32 mxfFlexDIONextDataRecordPtrGet ( MXF_FLEXDIO_DATAREC currentRec,
MXF_FLEXDIO_DATAREC **  nextRec 
)
C#
public static extern UInt32 mxfFlexDIONextDataRecordPtrGet(IntPtr currentRec, out IntPtr nextRec);

Returns the next buffer address in a MXF_FLEXDIO_DATAREC buffer array.

Note
This function is the specific version for Flex Discrete IO of the multi-protocol mxfNextRecordPtrGet() function.
Parameters
[in]currentRecpointer to the beginning or the current record in the buffer.
[out]nextRecpointer to next record in the buffer.
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfNextRecordPtrGet()
mxfFlexDIORxAcqRead()
mxfFlexDIOTxAperiodicWrite()
Examples:
flexdio_event_handler.c, flexdio_sampling_acq.c, and flexdio_sync.c.
uint32 mxfFlexDIOChannelRead ( HMXF_CHANNEL  channel,
uint64  mask,
uint64 *  data 
)
C#
public static extern UInt32 mxfFlexDIOChannelRead(UInt64 channel, UInt64 mask, out UInt64 data);

Reads the current discrete input lines state on a discrete channel.

Parameters
[in]channelchannel handle.
[in]maskport mask.
[out]datadata returned.

Port Mask Example

The mask bit 0 selects the channel first port, bit 1 the second port, etc.

Therefore, to get the state of the port #1, set the mask to 0x00000002.

Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOChannelWrite()
Examples:
flexdio.c.
uint32 mxfFlexDIOChannelWrite ( HMXF_CHANNEL  channel,
uint64  mask,
uint64  data 
)
C#
public static extern UInt32 mxfFlexDIOChannelWrite(UInt64 channel, UInt64 mask, UInt64 data);

Sets the discrete output lines state on a discrete channel.

Parameters
[in]channelchannel handle.
[in]maskport mask.
[in]datadata to set.

Port Mask Example

The mask bit 0 selects the channel first port, bit 1 the second port, etc.

Therefore, to set the state of the port #1, set the mask to 0x00000002.

Data value

This table explains the discrete pin output value for each output mode.

Mode Discrete Value State Description
MXF_FLEXDIO_MODE_OUT_HS MXF_FLEXDIO_VALUE_OUT_HS_OPEN (0) Open Output pin = floating
The load should pull down the value close to 0 V
MXF_FLEXDIO_VALUE_OUT_HS_SUPPLY (1) DC In Output pin = DC In
MXF_FLEXDIO_MODE_OUT_LS MXF_FLEXDIO_VALUE_OUT_LS_GND (0) Ground Output pin = Ground
MXF_FLEXDIO_VALUE_OUT_LS_OPEN (1) Open Output pin = floating
External pull-up should get the value close to DC In supply
MXF_FLEXDIO_MODE_OUT_LS_PULLUP MXF_FLEXDIO_VALUE_OUT_LS_GND (0) Ground Output pin = Ground
MXF_FLEXDIO_VALUE_OUT_LS_OPEN (1) Open Output pin = DC In supply
Internal pull-up should get the value close to DC In supply
MXF_FLEXDIO_MODE_OUT_PP MXF_FLEXDIO_VALUE_OUT_PP_GND (0) Ground Output pin = Ground
MXF_FLEXDIO_VALUE_OUT_PP_SUPPLY (1) DC In supply Output pin = DC In supply
Returns
MAXT_SUCCESS is returned when the function has succeeded.
Refer to mxf_error.h for a list of defined errors.
Call mxfSystemErrorStringGet() to transform the return code into a text string.
Availability:
Available in MX Foundation 4.5.0 and later.
See also
mxfFlexDIOChannelRead()
Examples:
flexdio.c.
Updated 10/23/2023