diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c index 1b43284d63eeae370e6aaa4efaec188fe47b9227..c440bf9477041c67138ca66f7dcfa49e3cda1ff2 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c @@ -1,7 +1,7 @@ #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; diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c index d8494a8755cdf43a339ad2d45f32df4686c21a59..28f6b5497888473aa9f3bd279ef356edba863fc9 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/libuart.c @@ -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); }