Skip to content
architek edited this page Aug 3, 2012 · 11 revisions

Welcome to the wiki of Ccsds-utils!

This wiki helps to install the Ccsds module from sources and gives short examples on possible use cases

#Overview

The present library allows decoding and encoding of CCSDS stream defined in the PSS/ECSS standards. It relies on the Data::ParseBinary module which helps greatly in doing these kind of tasks. TM/TC binary encoding and decoding of source packet as well as frame level is supported. It is possible to customize the library to suite a specific need. Basic Unit tests for regression are included. Plateform supported: any plateform where Perl has been successfully ported ie: Windows, Linux, Mac, Tablets, iPhone,...

       #Decode binary input as CCSDS TM Source Packet
       my $tm         = $TMSourcePacket->parse($input);

       my $header     = $tm->{'Packet Header'};
       my $dataf      = $tm->{'Packet Data Field'};
       my $data       = $dataf->{'Data Field'};
       my $pid        = $header->{'Packet Id'}->{'Apid'}->{'PID'};

#Install Get source

  • clone the repository:

      $ git clone git://github.com/architek/ccsds-standalone.git
    

or if you are behind a firewall :

    $ git clone https://[email protected]/architek/ccsds-standalone.git
  • build

      $ cd ccsds-standalone/Ccsds
      $ perl Makefile.PL
    
  • you need to run the following command as root to trigger automatic build and installation of dependencies

      $ make 
    
  • install to your system

      $ sudo make install
    
  • check

      $ make test
    

[...]

PASS

    $ perl -MCcsds -e 'print "$Ccsds::VERSION\n"'
    2.4

#Install under windows Under windows, use strawberry perl. Replace make by dmake and do not use sudo..

  • Install Strawberry Perl

  • Download ccsds-standalone

  • cd Ccsds

  • perl Makefile.PL

Allow to download dependencies by pressing [y]

  • dmake

  • dmake install

  • dmake test

#Usage

    #!/usr/bin/perl
    use strict;
    use warnings;

    use Data::Dumper;
    use Ccsds::TM::SourcePacket;  # the TM Source parser
    use Ccsds::TM::Printer;             # "pretty" printer

    #Convert ascii input into binary packed stream. 
    my $pstring = pack ( qq{H*} , qq{$buf} );

    #parse binary, including s2k header
    my $decoded=$ScosTMSourcePacket->parse($pstring);

    #you can also rebuild the packet now:
    my $decoded->Field('PacketId')=0x3232;
    my $data = $tmsourcepacket->build($decoded);

    #display its content, raw of using TMPrint
    print Dumper($decoded);   # unordered hashes..
    TMPrint($decoded);

Some working applications are available:

  • decoder.pl which takes as input a ascii representation of packets, either pure TM source packet or SCOS TM source packet (includes a SCOS Header)

  • decoder_raw which takes as input binary TM Source packets

  • proxy is an a tcp proxy with one end always connected (requirement). The lib can be used for every transmitted PDU to decode CCSDS packets or encode TC to send them

  • s2packet decodes a file containing frames into packets

  • ccsds-web is a small perl CGI using the ccsds library which allow to decode and print structures

  • scos_tm_tc is a script that takes as input TM Frame and TC Cltu and a SCOS Database and outputs a colored output

  • open_decom is a GUI application to browse TM/TC logfiles and apply complex filters, export subset of data, plot figures on several criterias

#Customization As the standard is flexible and allows mission customization, it is possible to override some of the structures (Sat_Time, PacketSecHeader,..) from the caller application. Here is one way to do it: Remark: It is important that the customization file begin with a capital letter.

    #!/usr/bin/perl
    use strict;
    use warnings;
    
    #Redefine with own structures
    BEGIN { require Custo-projet.pm; }
    use Ccsds::TM::SourcePacket;  # the TM Source parser
    use Data::Dumper;

    #Parse binary
    my $decoded=$TMSourcePacket->parse($pstring);

Custo-projet.pm:

    #Sample customization for PROJECT
    #############################
    package Ccsds::Custo;
    use Data::ParseBinary;
    our $Sat_Time = Struct( 'Sat_Time',
    
        UBInt32('Seconds'),
        UBInt16('SubSeconds'),
        Value(
            'OBT', sub { $_->ctx->{'Seconds'} + \
                    $_->ctx->{'SubSeconds'} / 65535 }
        )
    );
    
    our $TMSourceSecondaryHeader = 
    Struct('TMSourceSecondaryHeader',  
      Value('Length',10),                                             
      BitStruct('SecHeadFirstField',              
        BitField('Spare1',1),
        BitField('PUS Version Number',3),
        Nibble('Spare2')
      ),
      UBInt8('Service Type'),                         
      UBInt8('Service Subtype'),                   
      UBInt8('Destination Id'),                        
      $Sat_Time,                                              
    );

The element Length shall be provided as a virtual element containing the size of your TM Source Packet Sec Header.

#Standard Time

In the Recommendation, four Levels of time code formats can be defined based on the four degrees of interpretability of the code.

This library allows to decode CUC and CDS formats. Currently, PField and self-identified OBT type is not auto-detected, it must be provided by the user if needed.

  • CUC

     1 to 4 octets of Coarse time, 0 to 3 of Fine time This allows 136 years and 60ns granularity
    
         #Sample customization for PROJECT
         #############################
         package Ccsds::Custo;
         use Ccsds::StdTime;
         # CUC 48 bits
         our $Sat_Time = CUC(4,2);
         # or CUC 56 bits
         our $Sat_Time = CUC(4,3);
    
  • CDS

     16 or 24 bits for DAY, 32 bits for MS of the day, submilliseconds of ms (0,16 or 32 bits) This code is UTC based and leap second correction has to be made
     (with perl libraries)
    
         #Sample customization for PROJECT
         #############################
         package Ccsds::Custo
         use Ccsds::StdTime;
         # or CDS with DoE on 24 bits and no submilli, epoch is 1/1/1958
         our $Sat_Time = CDS(24,0);
         # CDS with DoE on 16 bits and submilli on 16 bits, epoch is 1/1/2000
         our $Sat_Time = CDS(16,16,2000);
    

#Multithread By providing two configuration parameters (skip and frame_nr), the library will start at a specified frame number and will go on for the specified number of frames.

These start and stop are done on packet boundary: where First Header Pointer indicates that the current frame contains a start of packet so that no information is lost.

With this, it is very simple to use N processors or N machines to launch a multithreaded frame decoding.

An example using Parallel::ForkManager is given in the examples directory.

#Support Feel free to contact me for questions, bug reports, ...

Clone this wiki locally