Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
serial-framing-protocol-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
CdF
CdF 2020-2021
modules
libraries
communication
serial-framing-protocol-python
Commits
189218cc
Commit
189218cc
authored
4 years ago
by
Charles Javerliat
Browse files
Options
Downloads
Patches
Plain Diff
Update readme
parent
b3411be3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+8
-4
8 additions, 4 deletions
README.md
with
8 additions
and
4 deletions
README.md
+
8
−
4
View file @
189218cc
...
@@ -7,12 +7,14 @@ This library provides a way to frame and send data safely over serial, this incl
...
@@ -7,12 +7,14 @@ This library provides a way to frame and send data safely over serial, this incl
### Framing data
### Framing data
```
python
```
python
from
sfp.sfp
import
frame_data
import
binascii
# The data to be framed
# The data to be framed
data
=
bytearray
([
0x12
,
0x34
,
0x56
])
data
=
bytearray
([
0x12
,
0x34
,
0x56
])
# Frame and store the result in framed_data
# Frame and store the result in framed_data
framed_data
=
bytearray
()
framed_data
=
frame_data
(
data
)
frame_data
(
data
,
framed_data
)
# Print the hexadecimal representation of the result
# Print the hexadecimal representation of the result
# This will return b'7e0003123456bf127f'
# This will return b'7e0003123456bf127f'
...
@@ -30,12 +32,14 @@ In those bytes:
...
@@ -30,12 +32,14 @@ In those bytes:
### Unframing data
### Unframing data
```
python
```
python
from
sfp.sfp
import
unframe_data
import
binascii
# The frame to unframe the data from
# The frame to unframe the data from
framed_data
=
bytearray
([
0x7e
,
0x0
,
0x3
,
0x12
,
0x34
,
0x56
,
0xbf
,
0x12
,
0x7f
])
framed_data
=
bytearray
([
0x7e
,
0x0
,
0x3
,
0x12
,
0x34
,
0x56
,
0xbf
,
0x12
,
0x7f
])
# Unframe and store the result in unframed_data
# Unframe and store the result in unframed_data
unframed_data
=
bytearray
()
unframed_data
=
unframe_data
(
framed_data
)
unframe_data
(
framed_data
,
unframed_data
)
# Print the hexadecimal representation of the result
# Print the hexadecimal representation of the result
# This will return b'123456'
# This will return b'123456'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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