Commit e00d57f2 authored by Damien George's avatar Damien George

Add Demo_uPy_WithC, where C and MicroPython call each other.

parent c6ef681e
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
MyBool ::= BOOLEAN
MyEnum ::= ENUMERATED { hello, world, howareyou }
MySeq ::= SEQUENCE {
input-data MyInteger,
output-data MyInteger,
validity ENUMERATED { valid, invalid }
}
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq
}
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
MyOctStr ::= OCTET STRING (SIZE (3))
-- You can also declare constants
myVar MySeqOf ::= { hello, world }
END
---------------------------------------------------
-- AADL2.0
-- TASTE
--
--
---------------------------------------------------
PACKAGE deploymentview::DV::Node1
PUBLIC
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS x86_partition
END x86_partition;
PROCESS IMPLEMENTATION x86_partition.others
END x86_partition.others;
END deploymentview::DV::Node1;
PACKAGE deploymentview::DV
PUBLIC
WITH ocarina_processors_x86;
WITH deploymentview::DV::Node1;
WITH Taste;
WITH Deployment;
WITH interfaceview::IV;
WITH TASTE_DV_Properties;
SYSTEM Node1
END Node1;
SYSTEM IMPLEMENTATION Node1.others
SUBCOMPONENTS
IV_GND : SYSTEM interfaceview::IV::GND.others {
Taste::coordinates => "990 990 1457 1452";
Taste::FunctionName => "GND";
};
IV_PAYLOAD : SYSTEM interfaceview::IV::PAYLOAD.others {
Taste::coordinates => "1636 980 2165 1421";
Taste::FunctionName => "PAYLOAD";
};
x86_partition : PROCESS deploymentview::DV::Node1::x86_partition.others {
Taste::coordinates => "664 752 2276 1614";
Deployment::Port_Number => 0;
};
x86_linux : PROCESSOR ocarina_processors_x86::x86.linux {
Taste::coordinates => "462 506 2477 1737";
};
PROPERTIES
Taste::APLC_Binding => (reference (x86_partition)) APPLIES TO IV_GND;
Taste::APLC_Binding => (reference (x86_partition)) APPLIES TO IV_PAYLOAD;
Actual_Processor_Binding => (reference (x86_linux)) APPLIES TO x86_partition;
END Node1.others;
SYSTEM deploymentview
END deploymentview;
SYSTEM IMPLEMENTATION deploymentview.others
SUBCOMPONENTS
Node1 : SYSTEM Node1.others {
Taste::coordinates => "210 154 2729 1913";
};
interfaceview : SYSTEM interfaceview::IV::interfaceview.others;
END deploymentview.others;
PROPERTIES
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.19";
Taste::interfaceView => "InterfaceView.aadl";
Taste::HWLibraries => ("../../tool-inst/share/ocarina/AADLv2/ocarina_components.aadl");
END deploymentview::DV;
-- copied aadl libraries
\ No newline at end of file
---------------------------------------------------
-- AADL2.0
-- TASTE
--
--
---------------------------------------------------
PACKAGE interfaceview::FV::GND
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_CYCLE
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_CYCLE;
SUBPROGRAM IMPLEMENTATION PI_CYCLE.others
END PI_CYCLE.others;
SUBPROGRAM PI_TM
FEATURES
a : IN PARAMETER DataView::MyBool {
Taste::encoding => NATIVE;
};
END PI_TM;
SUBPROGRAM IMPLEMENTATION PI_TM.others
END PI_TM.others;
SUBPROGRAM RI_TC
FEATURES
a : IN PARAMETER DataView::MyBool {
Taste::encoding => NATIVE;
};
END RI_TC;
SUBPROGRAM IMPLEMENTATION RI_TC.others
END RI_TC.others;
END interfaceview::FV::GND;
PACKAGE interfaceview::FV::PAYLOAD
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_TC
FEATURES
a : IN PARAMETER DataView::MyBool {
Taste::encoding => NATIVE;
};
END PI_TC;
SUBPROGRAM IMPLEMENTATION PI_TC.others
END PI_TC.others;
SUBPROGRAM RI_TM
FEATURES
a : IN PARAMETER DataView::MyBool {
Taste::encoding => NATIVE;
};
END RI_TM;
SUBPROGRAM IMPLEMENTATION RI_TM.others
END RI_TM.others;
END interfaceview::FV::PAYLOAD;
PACKAGE interfaceview::IV
PUBLIC
WITH interfaceview::FV::GND;
WITH interfaceview::FV::PAYLOAD;
WITH interfaceview::FV;
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SYSTEM GND
FEATURES
PI_CYCLE : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::GND::PI_CYCLE.others {
Taste::coordinates => "487 508";
Taste::RCMoperationKind => cyclic;
Taste::RCMperiod => 500 ms;
Taste::Deadline => 500 ms;
Taste::InterfaceName => "CYCLE";
};
PI_TM : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::GND::PI_TM.others {
Taste::coordinates => "1246 1185";
Taste::RCMoperationKind => unprotected;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "TM";
};
RI_TC : REQUIRES SUBPROGRAM ACCESS interfaceview::FV::PAYLOAD::PI_TC.others {
Taste::coordinates => "1246 805";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "TC";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (C);
END GND;
SYSTEM IMPLEMENTATION GND.others
SUBCOMPONENTS
CYCLE_impl : SUBPROGRAM interfaceview::FV::GND::PI_CYCLE.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
TM_impl : SUBPROGRAM interfaceview::FV::GND::PI_TM.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_CYCLE_impl : SUBPROGRAM ACCESS CYCLE_impl -> PI_CYCLE;
OpToPICnx_TM_impl : SUBPROGRAM ACCESS TM_impl -> PI_TM;
END GND.others;
SYSTEM PAYLOAD
FEATURES
PI_TC : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::PAYLOAD::PI_TC.others {
Taste::coordinates => "1621 780";
Taste::RCMoperationKind => unprotected;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "TC";
};
RI_TM : REQUIRES SUBPROGRAM ACCESS interfaceview::FV::GND::PI_TM.others {
Taste::coordinates => "1621 1195";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "TM";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (Micropython);
END PAYLOAD;
SYSTEM IMPLEMENTATION PAYLOAD.others
SUBCOMPONENTS
TC_impl : SUBPROGRAM interfaceview::FV::PAYLOAD::PI_TC.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_TC_impl : SUBPROGRAM ACCESS TC_impl -> PI_TC;
END PAYLOAD.others;
SYSTEM interfaceview
END interfaceview;
SYSTEM IMPLEMENTATION interfaceview.others
SUBCOMPONENTS
GND : SYSTEM interfaceview::IV::GND.others {
Taste::coordinates => "236 508 1246 1482";
};
PAYLOAD : SYSTEM interfaceview::IV::PAYLOAD.others {
Taste::coordinates => "1621 528 2698 1493";
};
CONNECTIONS
GND_TM_PAYLOAD_TM : SUBPROGRAM ACCESS GND.PI_TM -> PAYLOAD.RI_TM {
Taste::coordinates => "1621 1195 1433 1195 1433 1185 1246 1185";
};
PAYLOAD_TC_GND_TC : SUBPROGRAM ACCESS PAYLOAD.PI_TC -> GND.RI_TC {
Taste::coordinates => "1246 805 1433 805 1433 780 1621 780";
};
END interfaceview.others;
PROPERTIES
Taste::dataView => ("DataView");
Taste::dataViewPath => ("DataView.aadl");
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.19";
END interfaceview::IV;
PACKAGE interfaceview::FV
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
END interfaceview::FV;
44a97ceb63adbe8df866dd3740da7d6f InterfaceView.aadl
Demo_uPy_WithC
This system demonstrates calling a MicroPython PI from user C code, and then
calling user C code from MicroPython. There is a Function implemented in C
which has a cyclic PI and which makes a call to MicroPython. The MicroPython
function then calls a C function.
The expected output of the built binary is to print 3 lines of information
text every second.
#!/bin/bash -e
# This script will build your TASTE system.
# You should not change this file as it was automatically generated.
# If you need additional preprocessing, there are three hook files
# that you can provide and that are called dring the build:
# user_init_pre.sh, user_init_post.sh and user_init_last.sh
# These files will never get overwritten by TASTE.'
# Inside these files you may set some environment variables:
# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}
# unset USE_POHIC
CWD=$(pwd)
if [ -t 1 ] ; then
COLORON="\e[1m\e[32m"
COLOROFF="\e[0m"
else
COLORON=""
COLOROFF=""
fi
INFO="${COLORON}[INFO]${COLOROFF}"
if [ -f user_init_pre.sh ]
then
echo -e "${INFO} Executing user-defined init script"
source user_init_pre.sh
fi
# Use PolyORB-HI-C runtime
USE_POHIC=1
# Detect models from Ellidiss tools v2, and convert them to 1.3
INTERFACEVIEW=InterfaceView.aadl
grep "version => \"2" InterfaceView.aadl >/dev/null && {
echo -e "${INFO} Converting interface view from V2 to V1.3"
TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl
INTERFACEVIEW=__iv_1_3.aadl
};
if [ -z "$DEPLOYMENTVIEW" ]
then
DEPLOYMENTVIEW=DeploymentView.aadl
fi
# Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$DEPLOYMENTVIEW" >/dev/null && {
echo -e "${INFO} Converting deployment view from V2 to V1.3"
TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl
DEPLOYMENTVIEW=__dv_1_3.aadl
};
SKELS="./"
# Check if Dataview references existing files
taste-extract-asn-from-design.exe -i "$INTERFACEVIEW" -j /tmp/dv.asn
cd "$SKELS" && rm -f gnd.zip && zip gnd gnd/* && cd $OLDPWD
cd "$SKELS" && rm -f payload.zip && zip payload payload/* && cd $OLDPWD
[ ! -z "$CLEANUP" ] && rm -rf binary*
if [ -f ConcurrencyView.pro ]
then
ORCHESTRATOR_OPTIONS+=" -w ConcurrencyView.pro "
fi
if [ -f user_init_post.sh ]
then
echo -e "${INFO} Executing user-defined post-init script"
source user_init_post.sh
fi
if [ ! -z "$USE_POHIC" ]
then
OUTPUTDIR=binary.c
ORCHESTRATOR_OPTIONS+=" -p "
elif [ ! -z "$USE_POHIADA" ]
then
OUTPUTDIR=binary.ada
else
OUTPUTDIR=binary
fi
cd "$CWD" && assert-builder-ocarina.py \
--fast \
--debug \
--aadlv2 \
--keep-case \
--interfaceView "$INTERFACEVIEW" \
--deploymentView "$DEPLOYMENTVIEW" \
-o "$OUTPUTDIR" \
--subC gnd:"$SKELS"/gnd.zip \
--subMicroPython payload:"$SKELS"/payload.zip \
$ORCHESTRATOR_OPTIONS
if [ -f user_init_last.sh ]
then
echo -e "${INFO} Executing user-defined post-build script"
source user_init_last.sh
fi
/* User code: This file will not be overwritten by TASTE. */
#include <stdio.h>
#include "gnd.h"
static asn1SccMyBool state;
void gnd_startup()
{
/* Write your initialization code here,
but do not make any call to a required interface. */
printf("gnd_startup\n");
state = false;
}
void gnd_PI_CYCLE()
{
/* Write your code here! */
printf("gnd_PI_CYCLE --->\n");
gnd_RI_TC(&state);
state = !state;
}
void gnd_PI_TM(const asn1SccMyBool *IN_a)
{
/* Write your code here! */
printf("gnd_PI_TM %d\n", *IN_a);
}
/* This file was generated automatically: DO NOT MODIFY IT ! */
/* Declaration of the functions that have to be provided by the user */
#ifndef __USER_CODE_H_gnd__
#define __USER_CODE_H_gnd__
#include "C_ASN1_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
void gnd_startup();
void gnd_PI_CYCLE();
void gnd_PI_TM(const asn1SccMyBool *);
extern void gnd_RI_TC(const asn1SccMyBool *);
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
# User code: This file will not be overwritten by TASTE.
import micropython
# payload_RI_TM(IN_a: asn1SccMyBool)
from taste import payload_RI_TM
def payload_startup():
# Write your initialization code here,
# but do not make any call to a required interface.
print('payload_startup')
micropython.heap_lock()
def payload_PI_TC(IN_a):
# Write your code here!
print(' payload_PI_TC', IN_a)
print(' <--/')
payload_RI_TM(not IN_a)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment