diff --git a/CCSDSpy.egg-info/SOURCES.txt b/CCSDSpy.egg-info/SOURCES.txt deleted file mode 100644 index 0bc23b7da5367551a5363326aa62c4811fcf5987..0000000000000000000000000000000000000000 --- a/CCSDSpy.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -LICENSE -README.md -pyproject.toml -CCSDS/__init__.py -CCSDS/ccsds.py -CCSDSpy.egg-info/PKG-INFO -CCSDSpy.egg-info/SOURCES.txt -CCSDSpy.egg-info/dependency_links.txt -CCSDSpy.egg-info/requires.txt -CCSDSpy.egg-info/top_level.txt \ No newline at end of file diff --git a/CCSDSpy.egg-info/top_level.txt b/CCSDSpy.egg-info/top_level.txt deleted file mode 100644 index 3f831c89a5de66c94dcc9dfee914475e4df6bafe..0000000000000000000000000000000000000000 --- a/CCSDSpy.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -CCSDS diff --git a/README.md b/README.md index 92a4ae56a3b26e2ba0eb31b5fd409acfccee41db..e3e5997ce588d1cd06c3fe78a612bc4578dec60b 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ -# CCSDSpy +# PyCCSDS --- -CCSDSpy is a library to read a data packet coming from a space mission that follows the Consultative Committee for Space Data Systems (CCSDS) standard +PyCCSDS is a library to read a data packet coming from a space mission that follows the Consultative Committee for Space Data Systems (CCSDS) standard Current version **0.1.0** [[_TOC_]] ## Installation +```shell +python3 -m pip install Python-CCSDS +``` ## Usage ```python -from CCSDS import CCSDS +from PyCCSDS.ccsds import CCSDS dat = CCSDS('BepiColombo',packet) ``` @@ -72,4 +75,4 @@ classDiagram ```  -####Figure 1 - Telemetry Packet +#### Figure 1 - Telemetry Packet diff --git a/CCSDS/__init__.py b/build/lib/PyCCSDS/__init__.py similarity index 100% rename from CCSDS/__init__.py rename to build/lib/PyCCSDS/__init__.py diff --git a/CCSDS/ccsds.py b/build/lib/PyCCSDS/ccsds.py old mode 100755 new mode 100644 similarity index 98% rename from CCSDS/ccsds.py rename to build/lib/PyCCSDS/ccsds.py index 4ff1945a1c12e9d2507747cef3df5d80788fc398..e91ac45009fb136d6bc46ac2bf88bb94de86f301 --- a/CCSDS/ccsds.py +++ b/build/lib/PyCCSDS/ccsds.py @@ -94,6 +94,8 @@ class CCSDS: if type(missionID) is str: if missionID.lower() == 'bepicolombo': missionID=-121 + elif missionID.lower() == 'juice': + missionID=-29 else: if t0 == None: print("WARNING: the Mission name is not valid. time converte setted to 1970-01-01 00:00:00") diff --git a/dist/CCSDSpy-0.1.0.tar.gz b/dist/CCSDSpy-0.1.0.tar.gz deleted file mode 100644 index b3a02f34f867a2d2a51d9d5cf191b563bf403faf..0000000000000000000000000000000000000000 Binary files a/dist/CCSDSpy-0.1.0.tar.gz and /dev/null differ diff --git a/dist/Python-CCSDS-0.1.0.tar.gz b/dist/Python-CCSDS-0.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..67049480a221d14c67932173914cadf83bef5398 Binary files /dev/null and b/dist/Python-CCSDS-0.1.0.tar.gz differ diff --git a/dist/CCSDSpy-0.1.0-py3-none-any.whl b/dist/Python_CCSDS-0.1.0-py3-none-any.whl similarity index 76% rename from dist/CCSDSpy-0.1.0-py3-none-any.whl rename to dist/Python_CCSDS-0.1.0-py3-none-any.whl index 79d1fb908bf321b95c6cfa7e34d19e9466c37fd9..1853dc3b56884390bdbb5d31e5a5a3227a5891ad 100644 Binary files a/dist/CCSDSpy-0.1.0-py3-none-any.whl and b/dist/Python_CCSDS-0.1.0-py3-none-any.whl differ diff --git a/pyproject.toml b/pyproject.toml index 1797b3f19bbe2f7f3835cae1a466af7ae38d3efb..1eda487a55932fbdc21d0ef2323c2eeee7373aa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "CCSDSpy" +name = "Python-CCSDS" version = "0.1.0" dependencies = [ "rich", @@ -11,6 +11,8 @@ dependencies = [ authors = [{name="Romolo Politi", email ="romolo.politi@gmail.com" }] license = {text = "GNU GPL ver3"} readme = "README.md" +keywords =['python','ccsds','nasa','esa','packets'] +descriprion = 'Python library to read the CCSDS packets' [project.optional-dependencies] diff --git a/CCSDSpy.egg-info/dependency_links.txt b/src/PyCCSDS/__init__.py similarity index 100% rename from CCSDSpy.egg-info/dependency_links.txt rename to src/PyCCSDS/__init__.py diff --git a/src/PyCCSDS/ccsds.py b/src/PyCCSDS/ccsds.py new file mode 100755 index 0000000000000000000000000000000000000000..e91ac45009fb136d6bc46ac2bf88bb94de86f301 --- /dev/null +++ b/src/PyCCSDS/ccsds.py @@ -0,0 +1,111 @@ +#! /usr/bin/env python3 +from bitstring import BitStream +import spiceypy as spice +from datetime import datetime, timedelta +from rich.console import Console + + +class PacketId: + def __init__(self,data): + pID = BitStream(hex=data).unpack('uint: 3, 2*bin: 1, bits: 11') + self.VersionNum = pID[0] + self.packetType = pID[1] + self.dataFieldHeaderFlag = pID[2] + self.Apid = pID[3].uint + self.Pid = pID[3][0:7].uint + self.Pcat = pID[3][7:].uint + pass + def serialize(self): + return [self.VersionNum, self.packetType, self.dataFieldHeaderFlag, + self.Apid, self.Pid, self.Pcat] + +class SeqControl: + def __init__(self,data): + sq = BitStream(hex=data).unpack('bin:2,uint:14') + self.SegmentationFlag = sq[0] + self.SSC = sq[1] + + def serialize(self): + return [self.SegmentationFlag, self.SSC] + +class SourcePacketHeader: + def __init__(self,data): + # Read the Source Packet Header(48 bits) + # - Packet ID (16 bits) + self.packetId = PacketId(data[0:4]) + # - Packet Sequence Control (16 bits) + self.sequeceControl = SeqControl(data[4:8]) + """ + - Packet Length (16 bits) + In the packet is stored Packet length is an unsigned word + expressing “Number of octects contained in Packet Data Field” minus 1. + """ + self.packetLength = BitStream(hex=data[8:12]).unpack('uint:16')[0]+1 + # Based on BepiColombo SIMBIO-SYS + # ref: BC-SIM-GAF-IC-002 pag. 48 + def serialize(self): + return [*self.packetId.serialize(), *self.sequeceControl.serialize(), self.packetLength] + +class DataFieldHeader: + def __init__(self,data,missionID,t0): + # Read The Data Field Header (80 bit) + dfhData = BitStream(hex=data).unpack('bin:1,uint:3,bin:4,3*uint:8,uint:1,uint:31,uint:16') + self.pusVersion = dfhData[1] + self.ServiceType = dfhData[3] + self.ServiceSubType = dfhData[4] + self.DestinationId = dfhData[5] + self.Synchronization = dfhData[6] + self.CorseTime = dfhData[7] + self.FineTime = dfhData[8] + self.SCET = "%s.%s" % (self.CorseTime, self.FineTime) + if self.Synchronization == 0: + self.UTCTime = self.scet2UTC(missionID,t0) + else: + self.UTCTime = '1970-01-01T00:00:00.00000Z' + pass + + def serialize(self): + return [self.pusVersion, self.ServiceType, self.ServiceSubType, + self.DestinationId, self.SCET, self.UTCTime] + + def scet2UTC(self,missionID,t0): + if t0 == None: + et = spice.scs2e(missionID, "{}.{}".format(self.CorseTime, self.FineTime)) + ScTime = spice.et2utc(et, 'ISOC', 5) + else: + dateFormat = "%Y-%m-%dT%H:%M:%S.%f" + dt=datetime.strptime(t0,dateFormat) + sc = self.CorseTime + self.FineTime*(2**(-16)) + f=dt+timedelta(seconds=sc) + ScTime=f.strftime(dateFormat) + return ScTime+'Z' + +class PackeDataField: + def __init__(self,data, missionID,t0): + # Data Field Header + self.DFHeader = DataFieldHeader(data[0:20],missionID,t0) + # Data + self.Data = data[20:] + pass + +class CCSDS: + """ Reader for the CCSDS header """ + def __init__(self, missionID, data,console:Console=None,t0= None): + if type(missionID) is str: + if missionID.lower() == 'bepicolombo': + missionID=-121 + elif missionID.lower() == 'juice': + missionID=-29 + else: + if t0 == None: + print("WARNING: the Mission name is not valid. time converte setted to 1970-01-01 00:00:00") + t0 = "1970-01-01T00:00:00" + # Source Packet Header + self.SPH = SourcePacketHeader(data[0:12]) + # Packet Data Field + self.PDF = PackeDataField(data[12:],missionID,t0) + self.APID = self.SPH.packetId.Apid + self.Service=self.PDF.DFHeader.ServiceType + self.subService=self.PDF.DFHeader.ServiceSubType + self.Data=self.PDF.Data + diff --git a/CCSDSpy.egg-info/PKG-INFO b/src/Python_CCSDS.egg-info/PKG-INFO similarity index 87% rename from CCSDSpy.egg-info/PKG-INFO rename to src/Python_CCSDS.egg-info/PKG-INFO index e4885e87ab7afb7d608a28367e007045cdfc5872..c875206386855182d146f6c5f3913fc2c166373d 100644 --- a/CCSDSpy.egg-info/PKG-INFO +++ b/src/Python_CCSDS.egg-info/PKG-INFO @@ -1,26 +1,30 @@ Metadata-Version: 2.1 -Name: CCSDSpy +Name: Python-CCSDS Version: 0.1.0 Author-email: Romolo Politi <romolo.politi@gmail.com> License: GNU GPL ver3 +Keywords: python,ccsds,nasa,esa,packets Description-Content-Type: text/markdown Provides-Extra: docs License-File: LICENSE -# CCSDSpy +# PyCCSDS --- -CCSDSpy is a library to read a data packet coming from a space mission that follows the Consultative Committee for Space Data Systems (CCSDS) standard +PyCCSDS is a library to read a data packet coming from a space mission that follows the Consultative Committee for Space Data Systems (CCSDS) standard Current version **0.1.0** [[_TOC_]] ## Installation +```shell +python3 -m pip install Python-CCSDS +``` ## Usage ```python -from CCSDS import CCSDS +from PyCCSDS.ccsds import CCSDS dat = CCSDS('BepiColombo',packet) ``` @@ -81,4 +85,4 @@ classDiagram ```  -####Figure 1 - Telemetry Packet +#### Figure 1 - Telemetry Packet diff --git a/src/Python_CCSDS.egg-info/SOURCES.txt b/src/Python_CCSDS.egg-info/SOURCES.txt new file mode 100644 index 0000000000000000000000000000000000000000..40a8c61ce419231aed62ad6e83ab18906786ebf2 --- /dev/null +++ b/src/Python_CCSDS.egg-info/SOURCES.txt @@ -0,0 +1,10 @@ +LICENSE +README.md +pyproject.toml +src/PyCCSDS/__init__.py +src/PyCCSDS/ccsds.py +src/Python_CCSDS.egg-info/PKG-INFO +src/Python_CCSDS.egg-info/SOURCES.txt +src/Python_CCSDS.egg-info/dependency_links.txt +src/Python_CCSDS.egg-info/requires.txt +src/Python_CCSDS.egg-info/top_level.txt \ No newline at end of file diff --git a/src/Python_CCSDS.egg-info/dependency_links.txt b/src/Python_CCSDS.egg-info/dependency_links.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/src/Python_CCSDS.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/CCSDSpy.egg-info/requires.txt b/src/Python_CCSDS.egg-info/requires.txt similarity index 100% rename from CCSDSpy.egg-info/requires.txt rename to src/Python_CCSDS.egg-info/requires.txt diff --git a/src/Python_CCSDS.egg-info/top_level.txt b/src/Python_CCSDS.egg-info/top_level.txt new file mode 100644 index 0000000000000000000000000000000000000000..f5e2c924625c5671969e3f2e724bc5c04dfa807d --- /dev/null +++ b/src/Python_CCSDS.egg-info/top_level.txt @@ -0,0 +1 @@ +PyCCSDS