Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
raspberry
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
Container Registry
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
af3
raspberry
Commits
1f854191
Commit
1f854191
authored
7 years ago
by
fortissBot
Browse files
Options
Downloads
Patches
Plain Diff
Commented Methods
refs 7912
parent
d32e29f8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
+4
-2
4 additions, 2 deletions
...s.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c
+5
-16
5 additions, 16 deletions
org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c
with
9 additions
and
18 deletions
org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c
+
4
−
2
View file @
1f854191
#include
"inc/LaserRangeFinder.h"
/
/ init, terminate
/
** Initialize the laser range finder. */
void
lrf_init
()
{
//char port[] = "/dev/????????";
char
port
[
100
];
...
...
@@ -16,15 +16,17 @@ void lrf_init() {
uart_setup
(
port
);
}
/** Terminate the session. */
void
lrf_term
()
{
uart_close
();
}
/
/ getters
/
** Checking for noVal. */
GEN_TYPE_boolean
lrf_is_noval
()
{
return
false
;
}
/** Get one distance measurement from the laser range finder. */
GEN_TYPE_int
lrf_read
()
{
char
bytes
[
5
];
int
n_read
=
0
;
...
...
This diff is collapsed.
Click to expand it.
org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c
+
5
−
16
View file @
1f854191
...
...
@@ -7,6 +7,7 @@
int
uart_filestream
=
-
1
;
/** Initializing the UART connection. */
int
uart_setup
(
const
char
*
porta
)
{
strcpy
(
port
,
porta
);
uart_filestream
=
open
(
port
,
O_RDWR
|
O_NOCTTY
|
O_NDELAY
);
...
...
@@ -45,6 +46,7 @@ int uart_setup(const char *porta) {
return
uart_filestream
;
}
/** Sending one byte via UART. */
int
uart_send_byte
(
char
data
,
int
printt
)
{
if
(
uart_filestream
!=
-
1
)
{
int
n_written
=
0
;
...
...
@@ -61,22 +63,7 @@ int uart_send_byte(char data, int printt) {
return
-
1
;
}
int
uart_send_string
(
char
*
str
,
int
length
,
int
printt
)
{
if
(
uart_filestream
!=
-
1
)
{
int
n_written
=
0
;
n_written
=
write
(
uart_filestream
,
str
,
length
);
if
(
n_written
<
0
)
{
if
(
printt
)
fprintf
(
stderr
,
"[%s] Error sending string: %s
\n
"
,
port
,
strerror
(
errno
));
}
else
{
if
(
printt
)
printf
(
"[%s] Sent string %s
\n
"
,
port
,
str
);
return
0
;
}
}
return
-
1
;
}
/** Receive from the UART stream. */
int
uart_receive
(
char
*
c
,
int
bufLen
,
int
printt
)
{
fd_set
set
;
struct
timeval
timeout
;
...
...
@@ -122,10 +109,12 @@ int uart_receive(char *c, int bufLen, int printt) {
return
n_read
;
}
/** Close the UART connection. */
void
uart_close
()
{
close
(
uart_filestream
);
}
/** Flush the UART buffer. */
void
uart_flush
()
{
tcflush
(
uart_filestream
,
TCIFLUSH
);
}
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