Commit b84d634d authored by Damien George's avatar Damien George

Add Demo_uPy_TypesPI, to test all types input to a MicroPython PI.

parent 37b9bbb1
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
This diff is collapsed.
b3bf1cb905c9901d9c09712bc3c6c7ca InterfaceView.aadl
#!/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
This diff is collapsed.
This diff is collapsed.
#include <stdio.h>
#include "gnd.h"
void gnd_startup()
{
/* Write your initialization code here,
but do not make any call to a required interface. */
}
void gnd_PI_CYCLE()
{
/* Write your code here! */
asn1SccMySeq mySeq1, mySeq2;
asn1SccMyChoice myChoice1, myChoice2;
asn1SccMyOctStr myOctStr1, myOctStr2;
asn1SccMySeqOf mySeqOf1, mySeqOf2;
myOctStr1.arr[0] = 'M';
myOctStr1.arr[1] = 'P';
myOctStr1.arr[2] = 'Y';
gnd_RI_TC_OctStr_NATIVE(&myOctStr1, &myOctStr2);
printf("got myOctStr2: %c%c%c\n", myOctStr2.arr[0], myOctStr2.arr[1], myOctStr2.arr[2]);
mySeq1.input_data = 10;
mySeq1.output_data = 11;
mySeq1.validity = asn1Sccinvalid;
gnd_RI_TC_Seq_NATIVE(&mySeq1, &mySeq2);
printf("got mySeq2: %llu %llu %u\n", mySeq2.input_data, mySeq2.output_data, mySeq2.validity);
mySeq1.input_data = 20;
mySeq1.output_data = 21;
mySeq1.validity = asn1Sccvalid;
gnd_RI_TC_Seq_UPER(&mySeq1, &mySeq2);
printf("got mySeq2: %llu %llu %u\n", mySeq2.input_data, mySeq2.output_data, mySeq2.validity);
mySeqOf1.arr[0] = asn1Scchello;
mySeqOf1.arr[1] = asn1Sccworld;
gnd_RI_TC_SeqOf_NATIVE(&mySeqOf1, &mySeqOf2);
printf("got mySeqOf2: %u %u\n", mySeqOf2.arr[0], mySeqOf2.arr[1]);
myChoice1.kind = a_PRESENT;
myChoice1.u.a = 1;
gnd_RI_TC_Choice_NATIVE(&myChoice1, &myChoice2);
printf("got myChoice2: kind=%u a=%u\n", myChoice2.kind, myChoice2.u.a);
myChoice1.kind = b_PRESENT;
myChoice1.u.b.input_data = 30;
myChoice1.u.b.output_data = 31;
myChoice1.u.b.validity = asn1Sccvalid;
gnd_RI_TC_Choice_NATIVE(&myChoice1, &myChoice2);
printf("got myChoice2: kind=%u b=(%llu %llu %u)\n", myChoice2.kind, myChoice2.u.b.input_data, myChoice2.u.b.output_data, myChoice2.u.b.validity);
}
/* 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();
extern void gnd_RI_TC_Seq_NATIVE(const asn1SccMySeq *,
asn1SccMySeq *);
extern void gnd_RI_TC_Seq_UPER(const asn1SccMySeq *,
asn1SccMySeq *);
extern void gnd_RI_TC_Choice_NATIVE(const asn1SccMyChoice *,
asn1SccMyChoice *);
extern void gnd_RI_TC_OctStr_NATIVE(const asn1SccMyOctStr *,
asn1SccMyOctStr *);
extern void gnd_RI_TC_SeqOf_NATIVE(const asn1SccMySeqOf *,
asn1SccMySeqOf *);
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
# User code: This file will not be overwritten by TASTE.
import micropython
from taste import * # import all ASN types
def payload_startup():
# Write your initialization code here,
# but do not make any call to a required interface.
# It's recommended to lock the heap once initialisation is done, but
# note that without the heap some Python operations are not possible.
micropython.heap_lock()
def payload_PI_TC_Seq_NATIVE(IN_a: asn1SccMySeq, OUT_b: asn1SccMySeq):
print('TC_Seq_NATIVE')
print(' IN_a:', IN_a)
OUT_b.val.input_data = IN_a.input_data + 10
OUT_b.val.output_data = IN_a.output_data + 10
OUT_b.val.validity = 1 - IN_a.validity
def payload_PI_TC_Seq_UPER(IN_a: asn1SccMySeq, OUT_b: asn1SccMySeq):
print('TC_Seq_UPER')
print(' IN_a:', IN_a)
OUT_b.val.input_data = IN_a.input_data + 10
OUT_b.val.output_data = IN_a.output_data + 10
OUT_b.val.validity = 1 - IN_a.validity
def payload_PI_TC_OctStr_NATIVE(IN_a: asn1SccMyOctStr, OUT_b: asn1SccMyOctStr):
print('TC_OctStr_NATIVE')
print(' IN_a:', IN_a)
for i in range(len(IN_a)):
OUT_b.val[i] = IN_a[i] + 1
def payload_PI_TC_SeqOf_NATIVE(IN_a: asn1SccMySeqOf, OUT_b: asn1SccMySeqOf):
print('TC_SeqOf_NATIVE')
print(' IN_a:', IN_a)
for i in range(len(IN_a)):
OUT_b.val[i] = IN_a[i] + 1
def payload_PI_TC_Choice_NATIVE(IN_a: asn1SccMyChoice, OUT_b: asn1SccMyChoice):
print('TC_Choice_NATIVE')
print(' IN_a:', IN_a)
if hasattr(IN_a, 'a'):
IN_a.a = 1 - IN_a.a
else:
IN_a.b.input_data += 10
IN_a.b.output_data += 10
IN_a.b.validity = 1 - IN_a.b.validity
OUT_b.val = 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