Skip to content

Commit

Permalink
fix pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkscheper committed Jul 2, 2018
1 parent 69327cb commit 6a31d8d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion conf/modules/pipe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Each pipe is comprised of two half-duplex fifos, one for reading from the client and one for
writing to them.
To activate a specific pipe peripheral, define flag USE_PIPEX_WRITER with the file path to the
location where paparazzi whoudl wrtie to and USE_PIPEX_READER for the file location where
location where paparazzi would wrtie to and USE_PIPEX_READER for the file location where
it should read from, where X is your pipe peripheral number.
You can also configure the size of the incoming and outgoing buffer using PIPE_RX_BUFFER_SIZE
and PIPE_TX_BUFFER_SIZE
Expand Down
42 changes: 24 additions & 18 deletions sw/airborne/arch/linux/mcu_periph/pipe_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ void pipe_arch_init(void)
{
pthread_mutex_init(&pipe_mutex, NULL);

#if USE_PIPE0_WRITER || USE_PIPE0_READER
#if defined(USE_PIPE0_WRITER) || defined(USE_PIPE0_READER)
PIPE0Init();
#endif
#if USE_PIPE1_WRITER || USE_PIPE1_READER
#if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
PIPE1Init();
#endif
#if USE_PIPE2_WRITER || USE_PIPE2_READER
#if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
PIPE2Init();
#endif

Expand Down Expand Up @@ -203,22 +203,28 @@ static void *pipe_thread(void *data __attribute__((unused)))
FD_ZERO(&fds_master);
/* add used file descriptors */
int fd __attribute__((unused));
#if USE_PIPE0_READER
FD_SET(pipe0.fd_read, &fds_master);
if (pipe0.fd_read > fdmax) {
fdmax = pipe0.fd_read;
#ifdef USE_PIPE0_READER
if (pipe0.fd_read >= 0){
FD_SET(pipe0.fd_read, &fds_master);
if (pipe0.fd_read > fdmax) {
fdmax = pipe0.fd_read;
}
}
#endif
#if USE_PIPE1_READER
FD_SET(pipe1.fd_read, &socks_master);
if (pipe1.fd_read > fdmax) {
fdmax = pipe1.fd_read;
#ifdef USE_PIPE1_READER
if(pipe1.fd_read >= 0){
FD_SET(pipe1.fd_read, &socks_master);
if (pipe1.fd_read > fdmax) {
fdmax = pipe1.fd_read;
}
}
#endif
#if USE_PIPE2_READER
FD_SET(pipe2.fd_read, &socks_master);
if (pipe2.fd_read > fdmax) {
fdmax = pipe2.fd_read;
#ifdef USE_PIPE2_READER
if(pipe2.fd_read >= 0){
FD_SET(pipe2.fd_read, &socks_master);
if (pipe2.fd_read > fdmax) {
fdmax = pipe2.fd_read;
}
}
#endif

Expand All @@ -232,17 +238,17 @@ static void *pipe_thread(void *data __attribute__((unused)))
if (select(fdmax + 1, &fds, NULL, NULL, NULL) < 0) {
fprintf(stderr, "pipe_thread: select failed!");
} else {
#if USE_PIPE0_READER
#ifdef USE_PIPE0_READER
if (FD_ISSET(pipe0.fd_read, &fds)) {
pipe_receive(&pipe0);
}
#endif
#if USE_PIPE1_READER
#ifdef USE_PIPE1_READER
if (FD_ISSET(pipe1.fd_read, &fds)) {
pipe_receive(&pipe1);
}
#endif
#if USE_PIPE2_READER
#ifdef USE_PIPE2_READER
if (FD_ISSET(pipe2.fd_read, &fds)) {
pipe_receive(&pipe2);
}
Expand Down
18 changes: 9 additions & 9 deletions sw/airborne/mcu_periph/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,39 @@
#include <string.h>

/* Print the configurations */
#if USE_PIPE0_WRITER || USE_PIPE0_READER
#if defined(USE_PIPE0_WRITER) || defined(USE_PIPE0_READER)
struct pipe_periph pipe0;
#endif

#if USE_PIPE0_WRITER
#ifdef USE_PIPE0_WRITER
PRINT_CONFIG_VAR(USE_PIPE0_WRITER)
#endif

#if USE_PIPE0_READER
#ifdef USE_PIPE0_READER
PRINT_CONFIG_VAR(USE_PIPE0_READER)
#endif

#if USE_PIPE1_WRITER || USE_PIPE1_READER
#if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
struct pipe_periph pipe1;
#endif

#if USE_PIPE1_WRITER
#ifdef USE_PIPE1_WRITER
PRINT_CONFIG_VAR(USE_PIPE1_WRITER)
#endif

#if USE_PIPE1_READER
#ifdef USE_PIPE1_READER
PRINT_CONFIG_VAR(USE_PIPE1_READER)
#endif

#if USE_PIPE2_WRITER || USE_PIPE2_READER
#if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
struct pipe_periph pipe2;
#endif

#if USE_PIPE2_WRITER
#ifdef USE_PIPE2_WRITER
PRINT_CONFIG_VAR(USE_PIPE2_WRITER)
#endif

#if USE_PIPE2_READER
#ifdef USE_PIPE2_READER
PRINT_CONFIG_VAR(USE_PIPE2_READER)
#endif

Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/mcu_periph/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern bool pipe_check_free_space(struct pipe_periph *p, long *fd, uint16_t
extern void pipe_put_byte(struct pipe_periph *p, long fd, uint8_t data);
extern void pipe_put_buffer(struct pipe_periph *p, long fd, const uint8_t *data,uint16_t len);

#if USE_PIPE0_WRITER || USE_PIPE0_READER
#if defined(USE_PIPE0_WRITER) || defined(USE_PIPE0_READER)
extern struct pipe_periph pipe0;

#ifndef USE_PIPE0_WRITER
Expand All @@ -73,7 +73,7 @@ extern struct pipe_periph pipe0;
#define PIPE0Init() pipe_periph_init(&pipe0, STRINGIFY(USE_PIPE0_READER), STRINGIFY(USE_PIPE0_WRITER))
#endif // USE_PIPE0

#if USE_PIPE1_WRITER || USE_PIPE1_READER
#if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
extern struct pipe_periph pipe1;

#ifndef USE_PIPE1_WRITER
Expand All @@ -87,7 +87,7 @@ extern struct pipe_periph pipe1;
#define PIPE1Init() pipe_periph_init(&pipe1, STRINGIFY(USE_PIPE1_READER), STRINGIFY(USE_PIPE1_WRITER))
#endif // USE_PIPE1

#if USE_PIPE2_WRITER || USE_PIPE2_READER
#if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
extern struct pipe_periph pipe2;

#ifndef USE_PIPE2_WRITER
Expand Down

0 comments on commit 6a31d8d

Please sign in to comment.