This provides the lowest level access to an interface marked as external. Each of the external interface is exported as a raw stream_buffer and can be written to from a C/C++ Api. In order to use it, the context has to be generated as a shared library. The resulting shared library can be loaded by an external system using
[dlopen](http://man7.org/linux/man-pages/man3/dlopen.3.html) explicitly or linked against using the
api.h file that is generated in the public folder.
For the purpose of demonstration in this walkthrough, we will use a simple function included in vsi_examples repository. Using git, clone the vsi_examples repository:
Create a new project and work through the wizard to the end. Select any part/board as it won’t matter since we’re only going to be using the software for the walkthrough.
menu->flow->Create Platform. Accept the prefilled default options and Press okay.
menu->flow->Create Context. Change the dropdown to
Softwareand enter name as
api_walkthrough. Press okay.
Open Context block properties by double clicking inside
api_walkthroughand scroll down to
Software Parameters->map exposed interfaces as. Make sure that
Scroll down to
C/C++ optionsand ensure that
-staticflag is NOT included in
C++compile options. Remove it if you see it included.
Buildsdropdown and select Shared Library.
Press okay to close the properties dialog.
Then create a system canvas by selecting
flow->create system. Accept the prefilled defaults.
Open the newly created system canvas and select
Double click the
api_walkthroughcontext to enter hierarchy.
Add a new
VSI Software Wizardblock by right clicking and selecting
VSI Software Wizard.
Open newly added block properties by double-clicking it.
Click browse beside
Source Directoryand browse to select source code directory
C/C++ Functiondropdown box should be populated with multiple entries. Open and select
Arg 1in Arguments section.
Change the direction of
Arg 2in Arguments section to
output. Press okay to close properties.
Right click each interface and select
flow->Build Software Contextsand then Select
Wait for the build to successfully complete.
Browse to the directory
<project_dir>/vsi_auto_gen/sw/system_1in a terminal.
VSI automatically generate an example executable to demonstrate the api usage. Run the example by using the following command
The example will write to each input interface marked external and then read from each output marked external A statement on console is printed for each read and write.
Analyze the example code for API walkthrough in
<project_dir>/vsi_auto_gen/sw/system_1/api_walkthrough/example. Modify it to read data from a file instead of a variable and write to the input interface.