SFP in - SFP input mailbox

The SFP input mailbox block allows receiving float (single) signals via the SFP optic cables. To send data float (single), the SFP output mailbox block should be used.

The SFP input mailbox block reads data and applies it to the output port of the block. It also features a second output that indicates when new data has been received. The value on the output data port will remain unchanged until new data are received.

To see how to use SFP blocks in simulation and code generation please refer to the multi-master product note.

Signal specification

  • The data output signal “d” returns a vector containing the data read. The vector length can be configured with the  Number of signals parameter. The output data type is set to single.
  • The second signal is the data valid output “v“. It is set to 1 each time new data are available. The port is hidden by default but it can be shown using the Show data valid port checkbox.

Parameters

  • Name: defines the input mailbox name. An SFP input mailbox is linked to an SFP output mailbox when they have the same name.
  • Number of signals: sets the vector length of the output data.
  • Initial value(s): set the initial value of the data output port.
  • Show data valid port: shows or hide the data valid signal “v”.
  • Show simulation input port defines if the simulation input port is displayed or not.

PLECS block

Signal specification

  • The data output signal “d” returns a vector containing the data read. The vector length can be configured with the  Number of signals parameter.The output data type is set to single.
  • The second signal is the data valid output “v“. It is set to 1 each time new data are available. The port is hidden by default but it can be shown using the Show data valid port checkbox.

Parameters

  • Name: defines the input mailbox name. Data coming from a SFP output mailbox with the same name is applied to the data output port of the block.
  • Number of signals: sets the vector length of the output data.
  • Initial value(s): set the initial value of the data output port.
  • Data valid output: shows or hide the data valid signal “v”.

C++ functions

int Sfp_ConfigureInput(int uid, const char* name, int size_bytes, void* initial_data)Code language: C++ (cpp)

Configures an SFP input mailbox.

It has to be called in UserInit().

Parameters

  • uid: a unique ID used to distiguish mailboxes.
  • name: sets the name of the mailbox. SFP input and ouput mailboxes with the same name will be linked together.
  • size_bytes: sets the size in bytes of the data to be read.
  • initial_data: sets the initial value of the mailbox’s data.

Return value

  • int: returns false if too many input mailboxes were created or if two input mailboxes have the same name.
int Sfp_Read(int uid, void* data)Code language: C++ (cpp)

This function is used to read the data.

It has to be called during the control interrupt

Parameters

  • uid: a unique ID used to distiguish mailboxes.
  • data: data read from the input mailbox

Return value

  • int: returns 1 if new data is available since the last read. Returns 0 otherwise.