<< wgserialxcosio wgserialxcosio

wgserialxcosio >> wgserialxcosio > wgserialxcosio

wgserialxcosio

Integrates real hardware into the xcos simulation using a serial comport. This toolbox provides this block and the corresponding C-code for the embedded system.

Block Screenshot

Contents

General Description

This block provides a bidirectional way to receive the C structure of input signals from an embedded system to the XCOS simulation and to send an other C structure of output signal back to the embedded system.

Some possible embedded systems:

Block Configuration

Connection (COM-Port, IP):

There the serial com-port name can be configured (e.g.: Windows: COM4, Linux: /dev/ttyUSB0). In future a TCP-IP based communication is planed but not implemented in this version.

Parameter (Baudrate, TCP-Port):

Configure here the required baudrate of the serial connection.

Output signal frame format:

With a sequence of characters the C-struct structure and alignment of data can be configured. For the following C-struct example the corresponding frame format is "bbb_dw__f".

This example output signal frame format will create 6 block input signal connectors.

// Frame format specified within the embedded system
// and sent from the XCOS block to the embedded system.
struct rxFrame
{
    unsigned char    digitalOutputs0_7;
    unsigned char    analogOutput0;
    unsigned char    analogOutput1;
    unsigned char    spare0; // spare entry for correct alignment
    unsigned long    analogOutput2;
    unsigned short   analogOutput3;
    unsigned short   spare1; // spare entry for correct alignment
    float            analogOutput4;
    unsigned char    crc1;
    unsigned char    crc2;
};
Input signal frame format:

With a sequence of characters the C-struct structure and alignment of data can be configured. For the following C-struct example the corresponding frame format is "b_wfd".

This example input signal frame format will create 4 block output signal connectors.

// Frame format specified within the embedded system
// and sent from the embedded system to the XCOS block.
struct txFrame
{
    unsigned char    digitalInputs0_7;
    unsigned char    spare0; // spare entry for correct alignment
    unsigned short   analogInput0;
    unsigned float   analogInput0;
    unsigned long    counter; // position decoder
    unsigned char    crc1;
    unsigned char    crc2;
};
Using threading (1...yes, 0...no):

Implemented and works. Exact description is pending.

Threading priority:

Implemented and works. Exact description is pending.

C-Code Stack for the Embedded System

Following Arduino project for a standard IO application contains a valid implementation of the communication stack. Extract it to implement it into your custom application.

// ============================================================================
// Execute this script top open the Arduino standard IO application source code
// ============================================================================
editor(wgserialxcosio("getModulePath") +filesep()+ "arduino" + filesep()+"universalIO" + filesep()+"universalIO.ino");

Report an issue
<< wgserialxcosio wgserialxcosio