Please enable JavaScript to view this site.

Waijung 2 User Guide

Navigation: » No topics above this level «

String processing block

Scroll Prev Top Next More

How this block appears in a Simulink model?

string_processing_block_1

What can be configured?

string_processing_block_2

Configuration Parameter

Selectable Option/Value

Description

Format

 

Enter the format of the output string.

Buffer size

 

Enter the size of the output buffer.

Enable output status

Check--Uncheck

Return the number of success parameters.

Enable pointer

Check--Uncheck

This will allow user to access pointer settings

Select pointer

 

List for pointer names will be listed in the drop-down. Select one to store data to it.

Output string pointer

Check--Uncheck

If it is checked, this block will output the memory address of the pointer.

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

Output

Vector

Scalar

uint8

uint32

Formatted string as a character vector

Output the memory address of the pointer

 

Function: sscanf

string_processing_block_3

Configuration Parameter

Selectable Option/Value

Description

Format

 

Enter the format of the output string.

Buffer size

 

Enter the size of the output buffer.

Enable output status

Check--Uncheck

Return the number of success parameters.

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

Input

Vector

uint8

Input string as a character vector

Function: strlen

string_processing_block_4

Configuration Parameter

Selectable Option/Value

Description

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

Input

Vector

uint8

Input string as a character vector

Length

Scalar

uint32

Character length of the input string.

Function: strcmp

string_processing_block_5

Configuration Parameter

Selectable Option/Value

Description

Buffer size

 

Enter the size of the buffer.

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

s1

Vector

uint8

Input string as a character vector

s2

Vector

uint8

Input string as a character vector

result

Scalar

int32

 

Function: strncmp

string_processing_block_6

Configuration Parameter

Selectable Option/Value

Description

Buffer size

 

Enter the size of the buffer.

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

s1

Vector

uint8

Input string as a character vector

s2

Vector

uint8

Input string as a character vector

Num

Scalar

uint32

the maximum number of characters to be compared

result

Scalar

int32

 

 

Function: strextract

string_processing_block_7

Configuration Parameter

Selectable Option/Value

Description

Begin delimiter

 

Enter the starting point.

End delimiter

 

Enter the end point.

Buffer size

 

Enter the size of the buffer.

Sample time (sec)

-1 (inherited or specify

Specify the sample time.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

Input

Vector

uint8

Input string as a character vector

Output

Vector

uint8

Output string as a character vector

When to use this block?

This block is used to do string processing available in C programming.

How does this block work?

The following functions are available in this block,

sprintf

Sends formatted output to a string pointed to. It will take the inputs and put it in a single string in the format user has specified.

sscanf

Reads formatted input from a string.

strlen

Calculate the length of the string.

strcmp

Compares the two strings provided. This function return values that are as follows,

1.if Return value < 0 then it indicates str1 is less than str2.

2.if Return value > 0 then it indicates str2 is less than str1.

3.if Return value = 0 then it indicates str1 is equal to str2.

strncmp

Parameters,

1.S1 = This is the first string to be compared.

2.S2 = This is the second string to be compared.

3.Num = the maximum number of characters to be compared.

This function return values that are as follows,

4.if Return value < 0 then it indicates str1 is less than str2.

5.if Return value > 0 then it indicates str2 is less than str1.

6.if Return value = 0 then it indicates str1 is equal to str2.

strextract

This function extracts the string between begin delimiter and end delimiter.

Demo

Demo file : esp32_string_processing_demo.slx

string_processing_block_8
string_processing_block_9

Description

This example shows how to use the String Processing Block on ESP32. In this example, sprintf and sscanf functions are used.

Setup

A serial monitor software application is required to get the expected results. For this example, PuTTY open-source SSH and telnet client is used to monitor the serial output.

What should be happening?

After the model file is compiled and uploaded to the ESP32 board, open the PuTTY software and connect to the relevant serial port with a baud rate of 115200. The following output should be visible on the serial monitor software.

string_processing_block_10

Copyright 2023 Aimagin Co.,Ltd. Rev.869