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
572e90ca
Commit
572e90ca
authored
1 year ago
by
Federico Lolli
Browse files
Options
Downloads
Patches
Plain Diff
removed comments
parent
725917aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+0
-43
0 additions, 43 deletions
src/main.rs
with
0 additions
and
43 deletions
src/main.rs
+
0
−
43
View file @
572e90ca
//! Duplex example
//!
//! This example tests the ability to clone a serial port. It works by creating
//! a new file descriptor, and therefore a new `SerialPort` object that's safe
//! to send to a new thread.
//!
//! This example selects the first port on the system, clones the port into a child
//! thread that writes data to the port every second. While this is running the parent
//! thread continually reads from the port.
//!
//! To test this, have a physical or virtual loopback device connected as the
//! only port in the system.
use
std
::
io
::{
Read
,
Write
};
use
std
::
io
::{
Read
,
Write
};
use
std
::
time
::
Duration
;
use
std
::
time
::
Duration
;
use
std
::{
io
,
thread
};
use
std
::{
io
,
thread
};
fn
main
()
{
fn
main
()
{
// let mut s = String::new();
// let mut f = std::fs::File::open("mavlink.csv").expect("Unable to open file");
// f.read_to_string(&mut s).expect("Unable to read string");
// let values = s
// .trim()
// .split(',')
// .map(|s| s.parse::<f64>().unwrap())
// .collect::<Vec<_>>();
// dbg!(&values);
// Open the first serialport available.
// Open the first serialport available.
let
port_name
=
"/dev/tty.usbmodem143203"
;
let
port_name
=
"/dev/tty.usbmodem143203"
;
let
mut
port
=
serialport
::
new
(
port_name
,
115200
)
let
mut
port
=
serialport
::
new
(
port_name
,
115200
)
...
@@ -46,17 +22,6 @@ fn main() {
...
@@ -46,17 +22,6 @@ fn main() {
}
}
mavlink_buffer
[
152
..
158
]
.fill
(
100u8
);
mavlink_buffer
[
152
..
158
]
.fill
(
100u8
);
// mavlink_buffer[158] = b'\n';
// let mut send_buffer = [0u8; 316];
// for i in 0..316 {
// if i % 2 == 0 {
// send_buffer[i] = mavlink_buffer[i / 2];
// } else {
// send_buffer[i] = b'\n';
// }
// }
clone
clone
// .write_all(&send_buffer)
// .write_all(&send_buffer)
.write_all
(
&
mavlink_buffer
)
.write_all
(
&
mavlink_buffer
)
...
@@ -69,14 +34,6 @@ fn main() {
...
@@ -69,14 +34,6 @@ fn main() {
match
port
.read
(
&
mut
buffer
)
{
match
port
.read
(
&
mut
buffer
)
{
Ok
(
t
)
=>
{
Ok
(
t
)
=>
{
io
::
stdout
()
.write_all
(
&
buffer
[
..
t
])
.unwrap
();
io
::
stdout
()
.write_all
(
&
buffer
[
..
t
])
.unwrap
();
// let mut read = 0;
// for chunk in buffer[..bytes].chunks(4) {
// read += 4;
// let mut utfbuf = [0u8; 4];
// utfbuf[0..chunk.len()].copy_from_slice(chunk);
// let value = String::from_utf8_lossy(&utfbuf);
// print!("{}", value);
// }
}
}
Err
(
ref
e
)
if
e
.kind
()
==
io
::
ErrorKind
::
TimedOut
=>
(),
Err
(
ref
e
)
if
e
.kind
()
==
io
::
ErrorKind
::
TimedOut
=>
(),
Err
(
e
)
=>
eprintln!
(
"{:?}"
,
e
),
Err
(
e
)
=>
eprintln!
(
"{:?}"
,
e
),
...
...
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