Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Arpist
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Avionics
Autonomous Rocket Pointer
Arpist
Commits
20076359
Commit
20076359
authored
1 year ago
by
Federico Lolli
Browse files
Options
Downloads
Patches
Plain Diff
moved to a EOT ASCII byte as signal
parent
e91d5068
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+13
-6
13 additions, 6 deletions
src/main.rs
with
13 additions
and
6 deletions
src/main.rs
+
13
−
6
View file @
20076359
...
...
@@ -7,6 +7,8 @@ use std::time::Instant;
use
ffi
::
MavlinkPayloadFlightTM
;
use
serialport
::
SerialPort
;
const
EOT
:
u8
=
0x04
;
trait
MavLinkPort
{
fn
write_packet
(
&
mut
self
,
packet
:
MavlinkPayloadFlightTM
);
}
...
...
@@ -52,19 +54,24 @@ fn main() {
// read from buffer and print to stdout
let
mut
buffer
=
[
0u8
;
1000
];
let
mut
buffered_string
=
String
::
new
();
let
mut
start
:
Option
<
Instant
>
=
None
;
let
mut
times
=
Vec
::
new
();
let
mut
i
=
0
;
loop
{
match
port
.read
(
&
mut
buffer
)
{
Ok
(
t
)
=>
{
// encode the buffer into a string
let
input
=
String
::
from_utf8_lossy
(
&
buffer
[
..
t
]);
// check if we got the signal to start sending data
let
eot_f
=
buffer
[
..
t
]
.contains
(
&
EOT
);
// encode the buffer into a string (remove the EOT character)
let
input
=
if
eot_f
{
String
::
from_utf8_lossy
(
&
buffer
[
..
t
-
1
])
}
else
{
String
::
from_utf8_lossy
(
&
buffer
[
..
t
])
};
// if we got the signal to start sending data, send it
buffered_string
.push_str
(
&
input
);
if
buffered_string
.contains
(
"[WAITING]"
)
{
buffered_string
.clear
();
if
eot_f
{
if
let
Some
(
packet
)
=
iter
.next
()
{
if
let
Some
(
t
)
=
start
{
times
.push
(
t
.elapsed
()
.as_millis
());
...
...
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