Code Monkey home page Code Monkey logo

jsle's Introduction

Java implementation for the CCSDS SLE (Space Link Extension) protocol.

Currently implemented services are:

  • Forward CLTU Service
  • Return All Frame Service
  • Return Channel Frame Service

Both user (client) and provider(server) are implemented.

There is also a SLE to UDP bridge which implements a standalone SLE provider useful as frontend for a simulator. See below.

This library is independent from Yamcs; it's only dependencies are

  • netty used to implement the network communication
  • ASN.1 library jasn1 used to encode/decode the SLE messages.

The yamcs-sle package is based on this library and offers data links implementation that allow Yamcs to connect to SLE.

TODO: add some automated tests

SLE to UDP bridge

The SLE to UDP bridge is useful for testing a SLE connection to an existing simulator in a setup like this:

MCS with SLE (e.g. Yamcs) <--- RAF/RCF/FCLTU SLE --> SleUdpBridge <---- CLTU/AOS|TM frames/UDP ----> Simulator

The configuration is in bridge.properties. logging.properties can be adjusted to increase the logging at SLE level.

To start the bridge, please launch the script: ./udp-sle-bridge.sh

To start the bridge directly in the source repository: mvn exec:java

Known Problems and Limitations of the SLE to UDP bridge

  • RCF works effectively as RAF, no filtering on VCID is performed by the provider

jsle's People

Contributors

dependabot[bot] avatar xpromache avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsle's Issues

Possible resource leak in jsle

I see this error occasionally when using the SLE-UDP bridge code.

2022-11-10 15:57:00.804 [nioEventLoopGroup-2-5] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
Created at:
	io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:385)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178)
	io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:139)
	io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:150)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	java.base/java.lang.Thread.run(Thread.java:829)

"-h" option on UDP bridge does not print help

There is a check for "-h", "-help", and "--help" in main(), but no help is printed.

This patch adds a call to printUsageAndExit(), though it terminates with a nonzero exit code.

diff --git a/src/main/java/org/yamcs/sle/udpslebridge/SleUdpBridge.java b/src/main/java/org/yamcs/sle/udpslebridge/SleUdpBridge.java
index 87e4323d4f..b050ee966f 100644
--- a/src/main/java/org/yamcs/sle/udpslebridge/SleUdpBridge.java
+++ b/src/main/java/org/yamcs/sle/udpslebridge/SleUdpBridge.java
@@ -96,7 +96,7 @@ public class SleUdpBridge {
         String lfile = "logging.properties";
         for (int i = 0; i < args.length; i++) {
             if ("-h".equals(args[i]) || "-help".equals(args[i]) || "--help".equals(args[i])) {
-
+                printUsageAndExit();
             } else if ("-c".equals(args[i])) {
                 if (i == args.length) {
                     printUsageAndExit();

Nits in TimeCCSDS

TimeCCSDSpico is not available in SLE service versions 1 and 2 (while it is in 4 and 5) so I believe
https://github.com/yamcs/jsle/blob/a41ba54f76d05866f4c7c2b15271979388dccd7e/src/main/java/org/yamcs/jsle/CcsdsTime.java#L226C1-L226C30
should be
if (sleVersion <= 2) ...

There are 10^9 picoseconds in a millisecond so I believe

long picoOfMillisec = picosecInDay % 1000_000;

should be
long picoOfMillisec = picosecInDay % 1000_000_000;

Inter-frame sleep time calculation can generate invalid sleep time

What is observed when running the SLE bridge and sending a CLTU:

Exception in thread "Thread-2" java.lang.IllegalArgumentException: nanosecond timeout value out of range
	at java.lang.Thread.sleep(Thread.java:332)
	at org.yamcs.sle.udpslebridge.UdpCltuUplinker.uplink(UdpCltuUplinker.java:54)
	at org.yamcs.sle.provider.CltuServiceProvider.uplinkCltu(CltuServiceProvider.java:438)
	at org.yamcs.sle.provider.CltuServiceProvider.runUplinkQueue(CltuServiceProvider.java:426)
	at org.yamcs.sle.provider.CltuServiceProvider.lambda$processStartInvocation$0(CltuServiceProvider.java:152)
	at java.lang.Thread.run(Thread.java:748)

This appears to be caused by insufficient precision in the sleep duration calculation:

        long durationNs = cltuData.length * 8 * 1000_000_000 / bitrate;
        int millis = (int) (durationNs / 1000_000);
        int nanos = (int) (durationNs % 1000_000);

The problem is that cltuData.length is of type int, as are all the operands: two constants 8 and 1000_000_000, and the bitrate. This causes the multiplication and division on the right-hand side to use int precision, which can overflow and generate a negative value for durationNs.

The easiest way to fix this is to change the constants to long type:

        long durationNs = cltuData.length * 8L * 1000_000_000L / bitrate;
        int millis = (int) (durationNs / 1000_000);
        int nanos = (int) (durationNs % 1000_000);

Distribution does not build if group IDs are too large (OS X, for example)

Recommend adding a small configuration change to the maven-assembly-plugin to support systems with large values for user group IDs. On OS X, for example, the group IDs may be too large to fit into the appropriate field in the tar file, and the assembly plugin throws an error. To fix this, change the assembly plugin configuration to use Posix mode.

diff --git a/pom.xml b/pom.xml
index 54397efb21..3f5505e500 100644
--- a/pom.xml
+++ b/pom.xml
@@ -227,6 +227,7 @@
                                                                <descriptor>distribution/jsle.descriptor.xml</descriptor>
                                                        </descriptors>
                                                        <appendAssemblyId>false</appendAssemblyId>
+                                                       <tarLongFileMode>posix</tarLongFileMode>
                                                </configuration>
                                                <executions>
                                                        <execution>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.