Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
# re-include specifically what is desired from images folder
!/images/contact.jpg
!/ccsds-frames-cfdp

# include xtce-decoding folder
!/xtce-decoding
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ When a stream of CCSDS telemetry is available from a TCP client only, this clien

### ccsds-frames-cfdp
This is the same as the ccsds-frames example from yamcs but with the addition of the CFDP service. The CFDP shares the same virtual channel with the regular TCs but has lower priority.

### xtce-decoding
Shows how to use Yamcs as a general-purpose library for decoding packets based on an XTCE XML definition.
It decodes a single packet initialized in the code, and prints the result to the terminal.
To run: $ mvn exec:java

19 changes: 18 additions & 1 deletion ccsds-frames-cfdp/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand All @@ -36,5 +36,22 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions ccsds-frames-cfdp/.settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 5 additions & 4 deletions ccsds-frames-cfdp/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
1 change: 1 addition & 0 deletions xtce-decoding/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/cache/
84 changes: 84 additions & 0 deletions xtce-decoding/mdb/xtce_v12_UT.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<xtce:SpaceSystem xmlns:xtce="http://www.omg.org/space/xtce"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="XTCE_V12_UT"
xsi:schemaLocation="http://www.omg.org/space/xtce xtcev1_2.xsd"
shortDescription="Defines telemetry tabble for the IIF subsystems">
<xtce:Header version="0.5.0" validationStatus="draft"/>
<!-- All things pertaining to telemetry fall within the TelemetryMetaData section. -->
<!-- Some system level parameter type definitions in this section can be used by both telemetry and commands. -->
<xtce:TelemetryMetaData>
<xtce:ParameterTypeSet>
<xtce:BinaryParameterType name="Byte">
<xtce:BinaryDataEncoding>
<xtce:SizeInBits>
<xtce:FixedValue>8</xtce:FixedValue>
</xtce:SizeInBits>
</xtce:BinaryDataEncoding>
</xtce:BinaryParameterType>

<!-- These define a set of generic parameter types that can be used for both telemetry and commands. -->
<!-- The name reflects the encoded size of the parameter and the native size is large enough to hold it -->
<xtce:IntegerParameterType name="UInt3">
<xtce:IntegerDataEncoding sizeInBits="3"/>
</xtce:IntegerParameterType>
<xtce:IntegerParameterType name="UInt5">
<xtce:IntegerDataEncoding sizeInBits="5"/>
</xtce:IntegerParameterType>
<xtce:IntegerParameterType name="UInt12">
<xtce:IntegerDataEncoding sizeInBits="12"/>
</xtce:IntegerParameterType>
<xtce:IntegerParameterType name="UInt32">
<xtce:IntegerDataEncoding sizeInBits="32"/>
</xtce:IntegerParameterType>
<xtce:FloatParameterType name="Float32"/>
<xtce:BooleanParameterType name="Boolean"/>
<!-- The following represents a bit pattern of some telemetry value using a binary type with binary data encoding.
This type as defined here is not much different from the Unsigned8BitInteger type defined above except
the telemetry values using this type are interpreted as hex bit patterns rather than as numbers. -->
</xtce:ParameterTypeSet>
<!-- These are the parameters that can be used in containers. -->
<xtce:ParameterSet>
<!-- These are parameters that may be used in abstract telemetry or command containers to define system-level settings. -->
<xtce:Parameter name="SyncByte1" parameterTypeRef="Byte"/>
<xtce:Parameter name="SyncByte2" parameterTypeRef="Byte"/>
<xtce:Parameter name="SubsystemID" parameterTypeRef="UInt3"/>
<xtce:Parameter name="EventID" parameterTypeRef="UInt5"/>
<xtce:Parameter name="NumberOfDataBytesFollowing" parameterTypeRef="UInt32"/>
<xtce:Parameter name="NumberOfSamples" parameterTypeRef="UInt32"/>
<xtce:Parameter name="Samples" parameterTypeRef="UInt12"/>
</xtce:ParameterSet>

<xtce:ContainerSet>
<xtce:SequenceContainer name="FrameHeader" abstract="true">
<xtce:EntryList>
<xtce:ParameterRefEntry parameterRef="SyncByte1"/>
<xtce:ParameterRefEntry parameterRef="SyncByte2"/>
<xtce:ParameterRefEntry parameterRef="SubsystemID"/>
<xtce:ParameterRefEntry parameterRef="EventID"/>
</xtce:EntryList>
</xtce:SequenceContainer>
<xtce:SequenceContainer name="SENSOR_X_EVENT_Y">
<xtce:EntryList>
<xtce:ParameterRefEntry parameterRef="NumberOfDataBytesFollowing"/>
<xtce:ParameterRefEntry parameterRef="Samples">
<xtce:RepeatEntry>
<xtce:Count>
<xtce:FixedValue>4</xtce:FixedValue>
</xtce:Count>
</xtce:RepeatEntry>
</xtce:ParameterRefEntry>
</xtce:EntryList>
<xtce:BaseContainer containerRef="FrameHeader">
<xtce:RestrictionCriteria>
<xtce:ComparisonList>
<xtce:Comparison parameterRef="SyncByte1" value="A7"/>
<xtce:Comparison parameterRef="SyncByte2" value="F3"/>
<xtce:Comparison parameterRef="SubsystemID" value="5"/>
<xtce:Comparison parameterRef="EventID" value="31"/>
</xtce:ComparisonList>
</xtce:RestrictionCriteria>
</xtce:BaseContainer>
</xtce:SequenceContainer>
</xtce:ContainerSet>
</xtce:TelemetryMetaData>
</xtce:SpaceSystem>
52 changes: 52 additions & 0 deletions xtce-decoding/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.yamcs.snippets</groupId>
<artifactId>xtce-decoding</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>

<name>Yamcs :: Examples :: XTCE Decoding</name>
<description>
Shows how to use Yamcs as a general-purpose library for decoding packets based on an XTCE XML definition.
</description>

<properties>
<yamcsVersion>5.12.4-SNAPSHOT</yamcsVersion>
</properties>

<dependencies>
<dependency>
<groupId>org.yamcs</groupId>
<artifactId>yamcs-core</artifactId>
<version>${yamcsVersion}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.yamcs</groupId>
<artifactId>yamcs-maven-plugin</artifactId>
<version>1.2.9</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>org.yamcs.snippets.XtceDecodingSnippet</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.yamcs.snippets;

import java.util.logging.LogManager;

import org.yamcs.mdb.ContainerProcessingResult;
import org.yamcs.mdb.Mdb;
import org.yamcs.mdb.MdbFactory;
import org.yamcs.mdb.XtceTmExtractor;
import org.yamcs.parameter.ParameterValue;
import org.yamcs.parameter.Value;
import org.yamcs.utils.TimeEncoding;

/**
* Shows how to use Yamcs as a general-purpose library for decoding packets based on an XTCE XML definition.
*/
public class XtceDecodingSnippet {

public static void main(String... args) {
// Make Yamcs aware of leap seconds
TimeEncoding.setUp();

// Silence log messages from Yamcs libraries
LogManager.getLogManager().reset();

// The name here must match with an entry in mdb.yaml which by
// default is scanned from the classpath.
Mdb mdb = MdbFactory.createInstanceByConfig("example", false);
XtceTmExtractor extractor = new XtceTmExtractor(mdb);

// Tell the extractor to do a full scan. For efficiency reasons
// you may also instruct it to scan only the parameters or containers
// of your choice.
extractor.provideAll();

// Generate a fake packet that matches our example XTCE definition.
byte[] p1 = new byte[] {
(byte) 0xA7, // SyncByte1
(byte) 0xF3, // SyncByte2
(byte) ((5 << 5) | 31), // SubsystemID
0x00, 0x00, 0x00, 0x06, // NumberOfDataBytesFollowing
0x00, 0x10, 0x02, 0x00, 0x30, 0x04
}; // 4 Samples

long t = TimeEncoding.getWallclockTime();
ContainerProcessingResult result = extractor.processPacket(p1, t, t, 0);

System.out.printf("%-30s %-15s %-15s\n", "Parameter", "Engineering", "Raw");
System.out.printf("%-30s %-15s %-15s\n", "---------", "-----------", "---");
for (ParameterValue value : result.getParameterResult()) {
String parameterName = value.getParameter().getName();
Value engValue = value.getEngValue();
Value rawValue = value.getRawValue();
System.out.printf("%-30s %-15s %-15s\n", parameterName, engValue, rawValue);
}
}
}
6 changes: 6 additions & 0 deletions xtce-decoding/src/main/resources/mdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
example:
- type: org.yamcs.mdb.XtceLoader
args:
# This path reference is resolved from the file system.
# Relative paths start from your cwd
file: "mdb/xtce_v12_UT.xml"
6 changes: 6 additions & 0 deletions xtce-decoding/target/classes/mdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
example:
- type: org.yamcs.mdb.XtceLoader
args:
# This path reference is resolved from the file system.
# Relative paths start from your cwd
file: "mdb/xtce_v12_UT.xml"
Binary file not shown.
5 changes: 5 additions & 0 deletions xtce-decoding/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Mon Dec 15 13:54:48 CET 2025
groupId=org.yamcs.snippets
artifactId=xtce-decoding
version=1.0.0
Binary file added xtce-decoding/target/xtce-decoding-1.0.0.jar
Binary file not shown.