Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
permocar
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
Model registry
Operate
Environments
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
Robert Hedman
permocar
Commits
6d825633
Commit
6d825633
authored
7 years ago
by
Robert Hedman
Browse files
Options
Downloads
Patches
Plain Diff
added port and address constants
parent
f2e7a90b
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
+9
-4
9 additions, 4 deletions
src/main.rs
with
9 additions
and
4 deletions
src/main.rs
+
9
−
4
View file @
6d825633
...
@@ -16,6 +16,12 @@ use serial::prelude::*;
...
@@ -16,6 +16,12 @@ use serial::prelude::*;
//use std::str;
//use std::str;
// constants
const
LIDAR_ADDRESS
:
&
str
=
"127.0.0.1:8080"
;
const
COUNTER_SERIAL_PORT
:
&
str
=
"/dev/cu.usbmodem41"
;
// should the map matrix be two dim array of const size, vecs of dynamic, or what?
// should the map matrix be two dim array of const size, vecs of dynamic, or what?
...
@@ -25,7 +31,7 @@ const COLS: usize = 100;
...
@@ -25,7 +31,7 @@ const COLS: usize = 100;
fn
main
()
{
fn
main
()
{
// dummy thread for replacing lidar
// dummy thread for replacing lidar
let
server
=
thread
::
spawn
(||
{
let
server
=
thread
::
spawn
(||
{
let
listener
=
TcpListener
::
bind
(
"127.0.0.1:8080"
)
.unwrap
();
let
listener
=
TcpListener
::
bind
(
LIDAR_ADDRESS
)
.unwrap
();
let
mut
stream
;
let
mut
stream
;
let
mut
message
=
[
0u8
;
2
];
let
mut
message
=
[
0u8
;
2
];
match
listener
.accept
()
{
match
listener
.accept
()
{
...
@@ -60,8 +66,7 @@ fn main() {
...
@@ -60,8 +66,7 @@ fn main() {
println!
(
"Tracker started."
);
println!
(
"Tracker started."
);
let
mut
serial_buf
:
[
u8
;
8
]
=
[
0
;
8
];
let
mut
serial_buf
:
[
u8
;
8
]
=
[
0
;
8
];
let
device
=
String
::
from
(
"/dev/cu.usbmodem41"
);
let
mut
port
=
serial
::
open
(
&
COUNTER_SERIAL_PORT
)
.unwrap
();
let
mut
port
=
serial
::
open
(
&
device
)
.unwrap
();
interact
(
&
mut
port
)
.unwrap
();
interact
(
&
mut
port
)
.unwrap
();
...
@@ -111,7 +116,7 @@ fn main() {
...
@@ -111,7 +116,7 @@ fn main() {
let
mut
pos
:
(
i32
,
i32
);
//= (0,0);
let
mut
pos
:
(
i32
,
i32
);
//= (0,0);
// set up connection to lidar
// set up connection to lidar
let
mut
stream
=
TcpStream
::
connect
(
"127.0.0.1:8080"
)
.unwrap
();
let
mut
stream
=
TcpStream
::
connect
(
&
LIDAR_ADDRESS
)
.unwrap
();
let
mut
lidar_buf
:
[
u8
;
2
]
=
[
0
;
2
];
let
mut
lidar_buf
:
[
u8
;
2
]
=
[
0
;
2
];
// main loop for this thread
// main loop for this thread
...
...
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