Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SRC OBDH TMTC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Mueller
SRC OBDH TMTC
Commits
f06623a0
Commit
f06623a0
authored
5 years ago
by
Robin.Mueller
Browse files
Options
Downloads
Patches
Plain Diff
deleted obsolete block
parent
98286ac3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tc/obsw_tc_service23.py
+3
-87
3 additions, 87 deletions
tc/obsw_tc_service23.py
with
3 additions
and
87 deletions
tc/obsw_tc_service23.py
+
3
−
87
View file @
f06623a0
...
...
@@ -11,90 +11,6 @@ from typing import Deque
from
tc.obsw_pus_tc_packer
import
PusTelecommand
class
Service23WriteToFile
:
"""
This class generates the telecommand packet for the custom PUS service [23, 128]
@param objectID(bytearray): The objectID of the filesystem handler (e.g. SD_CARD_HANDLER_ID, PLOCHandler)
@param repository_path(str): The directory of the file
@param filename(str): The name of the file (e.g. boot.bin)
@param file_data(bytearray): The data to write to the file
"""
def
__init__
(
self
,
repository_path
:
str
,
filename
:
str
,
size_of_data_blocks
:
int
,
object_id
:
bytearray
=
bytearray
([]),
file_data
:
bytearray
=
bytearray
([])):
"""
@param repository_path:
@param filename:
@param object_id:
@param file_data:
"""
self
.
file_data
=
[]
self
.
number_of_packets
=
0
self
.
file_data
=
file_data
self
.
data_to_pack
=
object_id
repository_path_length_h
=
len
(
bytearray
(
repository_path
,
'
utf-8
'
))
>>
8
repository_path_length_l
=
0x00FF
&
len
(
bytearray
(
repository_path
,
'
utf-8
'
))
self
.
data_to_pack
.
append
(
repository_path_length_h
)
self
.
data_to_pack
.
append
(
repository_path_length_l
)
if
repository_path
!=
""
:
self
.
data_to_pack
+=
bytearray
(
repository_path
,
'
utf-8
'
)
self
.
data_to_pack
.
append
(
len
(
bytearray
(
filename
,
'
utf-8
'
)))
self
.
data_to_pack
+=
bytearray
(
filename
,
'
utf-8
'
)
self
.
pus_packets
=
self
.
split_large_file
(
size_of_data_blocks
)
def
split_large_file
(
self
,
size_of_data_blocks
:
int
):
"""
This function splits a large file in multiple packets
This is necessary because the packet size is limited
:param size_of_data_blocks: The file is splitted in data blocks of this size
:return: List containing the PUS packets generated for each data block
"""
self
.
number_of_packets
=
math
.
floor
(
len
(
self
.
file_data
)
/
size_of_data_blocks
)
packetNumber
=
0
commands
=
[]
for
i
in
range
(
self
.
number_of_packets
):
# append packet number
self
.
data_to_pack
.
append
(
size_of_data_blocks
)
self
.
data_to_pack
.
append
(
packetNumber
>>
8
)
self
.
data_to_pack
.
append
(
0xFF
&
packetNumber
)
self
.
data_to_pack
+=
self
.
file_data
[
i
*
size_of_data_blocks
:(
i
+
1
)
*
size_of_data_blocks
]
commands
.
append
(
PusTelecommand
(
service
=
23
,
subservice
=
128
,
ssc
=
21
,
app_data
=
self
.
data_to_pack
))
# Last data block, packet number and data block size is removed to create new command with next data block,
# packet number and data block size
self
.
data_to_pack
=
self
.
data_to_pack
[:
len
(
self
.
data_to_pack
)
-
size_of_data_blocks
-
2
-
1
]
packetNumber
=
packetNumber
+
1
# Calculate remaining data bytes
remaining_data_size
=
len
(
self
.
file_data
)
-
self
.
number_of_packets
*
size_of_data_blocks
self
.
data_to_pack
.
append
(
remaining_data_size
)
self
.
data_to_pack
.
append
(
packetNumber
>>
8
)
self
.
data_to_pack
.
append
(
0xFF
&
packetNumber
)
self
.
data_to_pack
+=
self
.
file_data
[
self
.
number_of_packets
*
size_of_data_blocks
:
len
(
self
.
file_data
)]
commands
.
append
(
PusTelecommand
(
service
=
23
,
subservice
=
128
,
ssc
=
21
,
app_data
=
self
.
data_to_pack
))
return
commands
def
get_number_of_packets
(
self
):
return
self
.
number_of_packets
# def sendSoftwareUpdate(comInterface, tmtcPrinter, tmListener, tmTimeout, tcTimeoutFactor, doPrintToFile):
# """ This function sends all packets to upload a new version of the software image
# The new image is assumed to be stored in the tmtc directory
# """
# image = open("sourceobsw-at91sam9g20_ek-sdram.bin", "rb").read()
# update = Service23WriteToFile("", "boot.bin", objectID=[0x4D, 0x00, 0x73, 0xAD], file_data=image)
# updateQueue = deque()
# updateQueue.appendleft(("print", "Service 23 Software Update"))
# i = 1
# for packet in update.pus_packets:
# updateQueue.appendleft(
# ("print", "Packet " + str(i) + "/" + str(len(update.pus_packets)) + " of software update sent"))
# updateQueue.appendleft(packet.packCommandTuple())
# i = i + 1
# updateQueue.appendleft(("print", "Transmission of software update complete"))
# SenderAndReceiver = SequentialCommandSenderReceiver(comInterface, tmtcPrinter, tmListener, tmTimeout, updateQueue,
# tcTimeoutFactor, doPrintToFile)
# SenderAndReceiver.sendQueueTcAndReceiveTmSequentially()
def
generate_service23_subservice2_packet
(
filename
:
str
,
repositoryPath
:
str
=
""
,
object_id
=
bytearray
([])):
"""
This function generates the application data field of a service 23/subservice 2 to
...
...
@@ -228,9 +144,9 @@ def generate_service23_subservice129_packet(repository_path: str, filename: str,
def
pack_service23_test_into
(
tc_queue
:
Deque
)
->
Deque
:
sd_handler_id
=
g
.
SD_CARD_HANDLER_ID
tc_queue
.
appendleft
((
"
print
"
,
"
Testing Service 23
"
))
tc_queue
.
append
((
"
print
"
,
"
Create directory
'
test
'"
))
command
=
generate_service23_subservice9_packet
(
directory_name
=
"
test
"
,
object_id
=
sd_handler_id
)
tc_queue
.
appendleft
(
command
.
pack_command_tuple
())
#
tc_queue.append(("print", "Create directory 'test'"))
#
command = generate_service23_subservice9_packet(directory_name="test", object_id=sd_handler_id)
#
tc_queue.appendleft(command.pack_command_tuple())
# tc_queue.append(("print", "Create subdirectory 'subdir' in 'test'"))
# command = generate_service23_subservice9_packet(repository_path="test", directory_name="subdir",
# object_id=sd_handler_id)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment