Skip to content
Snippets Groups Projects
Commit 1f854191 authored by fortissBot's avatar fortissBot
Browse files

Commented Methods

refs 7912
parent d32e29f8
No related branches found
No related tags found
No related merge requests found
#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;
......
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment