This commit is contained in:
kirkscheper
2018-07-02 10:25:44 +02:00
parent 69327cb0a5
commit 6a31d8d9d3
4 changed files with 37 additions and 31 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
Each pipe is comprised of two half-duplex fifos, one for reading from the client and one for Each pipe is comprised of two half-duplex fifos, one for reading from the client and one for
writing to them. writing to them.
To activate a specific pipe peripheral, define flag USE_PIPEX_WRITER with the file path to the 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. 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 You can also configure the size of the incoming and outgoing buffer using PIPE_RX_BUFFER_SIZE
and PIPE_TX_BUFFER_SIZE and PIPE_TX_BUFFER_SIZE
+24 -18
View File
@@ -49,13 +49,13 @@ void pipe_arch_init(void)
{ {
pthread_mutex_init(&pipe_mutex, NULL); pthread_mutex_init(&pipe_mutex, NULL);
#if USE_PIPE0_WRITER || USE_PIPE0_READER #if defined(USE_PIPE0_WRITER) || defined(USE_PIPE0_READER)
PIPE0Init(); PIPE0Init();
#endif #endif
#if USE_PIPE1_WRITER || USE_PIPE1_READER #if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
PIPE1Init(); PIPE1Init();
#endif #endif
#if USE_PIPE2_WRITER || USE_PIPE2_READER #if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
PIPE2Init(); PIPE2Init();
#endif #endif
@@ -203,22 +203,28 @@ static void *pipe_thread(void *data __attribute__((unused)))
FD_ZERO(&fds_master); FD_ZERO(&fds_master);
/* add used file descriptors */ /* add used file descriptors */
int fd __attribute__((unused)); int fd __attribute__((unused));
#if USE_PIPE0_READER #ifdef USE_PIPE0_READER
FD_SET(pipe0.fd_read, &fds_master); if (pipe0.fd_read >= 0){
if (pipe0.fd_read > fdmax) { FD_SET(pipe0.fd_read, &fds_master);
fdmax = pipe0.fd_read; if (pipe0.fd_read > fdmax) {
fdmax = pipe0.fd_read;
}
} }
#endif #endif
#if USE_PIPE1_READER #ifdef USE_PIPE1_READER
FD_SET(pipe1.fd_read, &socks_master); if(pipe1.fd_read >= 0){
if (pipe1.fd_read > fdmax) { FD_SET(pipe1.fd_read, &socks_master);
fdmax = pipe1.fd_read; if (pipe1.fd_read > fdmax) {
fdmax = pipe1.fd_read;
}
} }
#endif #endif
#if USE_PIPE2_READER #ifdef USE_PIPE2_READER
FD_SET(pipe2.fd_read, &socks_master); if(pipe2.fd_read >= 0){
if (pipe2.fd_read > fdmax) { FD_SET(pipe2.fd_read, &socks_master);
fdmax = pipe2.fd_read; if (pipe2.fd_read > fdmax) {
fdmax = pipe2.fd_read;
}
} }
#endif #endif
@@ -232,17 +238,17 @@ static void *pipe_thread(void *data __attribute__((unused)))
if (select(fdmax + 1, &fds, NULL, NULL, NULL) < 0) { if (select(fdmax + 1, &fds, NULL, NULL, NULL) < 0) {
fprintf(stderr, "pipe_thread: select failed!"); fprintf(stderr, "pipe_thread: select failed!");
} else { } else {
#if USE_PIPE0_READER #ifdef USE_PIPE0_READER
if (FD_ISSET(pipe0.fd_read, &fds)) { if (FD_ISSET(pipe0.fd_read, &fds)) {
pipe_receive(&pipe0); pipe_receive(&pipe0);
} }
#endif #endif
#if USE_PIPE1_READER #ifdef USE_PIPE1_READER
if (FD_ISSET(pipe1.fd_read, &fds)) { if (FD_ISSET(pipe1.fd_read, &fds)) {
pipe_receive(&pipe1); pipe_receive(&pipe1);
} }
#endif #endif
#if USE_PIPE2_READER #ifdef USE_PIPE2_READER
if (FD_ISSET(pipe2.fd_read, &fds)) { if (FD_ISSET(pipe2.fd_read, &fds)) {
pipe_receive(&pipe2); pipe_receive(&pipe2);
} }
+9 -9
View File
@@ -30,39 +30,39 @@
#include <string.h> #include <string.h>
/* Print the configurations */ /* Print the configurations */
#if USE_PIPE0_WRITER || USE_PIPE0_READER #if defined(USE_PIPE0_WRITER) || defined(USE_PIPE0_READER)
struct pipe_periph pipe0; struct pipe_periph pipe0;
#endif #endif
#if USE_PIPE0_WRITER #ifdef USE_PIPE0_WRITER
PRINT_CONFIG_VAR(USE_PIPE0_WRITER) PRINT_CONFIG_VAR(USE_PIPE0_WRITER)
#endif #endif
#if USE_PIPE0_READER #ifdef USE_PIPE0_READER
PRINT_CONFIG_VAR(USE_PIPE0_READER) PRINT_CONFIG_VAR(USE_PIPE0_READER)
#endif #endif
#if USE_PIPE1_WRITER || USE_PIPE1_READER #if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
struct pipe_periph pipe1; struct pipe_periph pipe1;
#endif #endif
#if USE_PIPE1_WRITER #ifdef USE_PIPE1_WRITER
PRINT_CONFIG_VAR(USE_PIPE1_WRITER) PRINT_CONFIG_VAR(USE_PIPE1_WRITER)
#endif #endif
#if USE_PIPE1_READER #ifdef USE_PIPE1_READER
PRINT_CONFIG_VAR(USE_PIPE1_READER) PRINT_CONFIG_VAR(USE_PIPE1_READER)
#endif #endif
#if USE_PIPE2_WRITER || USE_PIPE2_READER #if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
struct pipe_periph pipe2; struct pipe_periph pipe2;
#endif #endif
#if USE_PIPE2_WRITER #ifdef USE_PIPE2_WRITER
PRINT_CONFIG_VAR(USE_PIPE2_WRITER) PRINT_CONFIG_VAR(USE_PIPE2_WRITER)
#endif #endif
#if USE_PIPE2_READER #ifdef USE_PIPE2_READER
PRINT_CONFIG_VAR(USE_PIPE2_READER) PRINT_CONFIG_VAR(USE_PIPE2_READER)
#endif #endif
+3 -3
View File
@@ -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_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); 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; extern struct pipe_periph pipe0;
#ifndef USE_PIPE0_WRITER #ifndef USE_PIPE0_WRITER
@@ -73,7 +73,7 @@ extern struct pipe_periph pipe0;
#define PIPE0Init() pipe_periph_init(&pipe0, STRINGIFY(USE_PIPE0_READER), STRINGIFY(USE_PIPE0_WRITER)) #define PIPE0Init() pipe_periph_init(&pipe0, STRINGIFY(USE_PIPE0_READER), STRINGIFY(USE_PIPE0_WRITER))
#endif // USE_PIPE0 #endif // USE_PIPE0
#if USE_PIPE1_WRITER || USE_PIPE1_READER #if defined(USE_PIPE1_WRITER) || defined(USE_PIPE1_READER)
extern struct pipe_periph pipe1; extern struct pipe_periph pipe1;
#ifndef USE_PIPE1_WRITER #ifndef USE_PIPE1_WRITER
@@ -87,7 +87,7 @@ extern struct pipe_periph pipe1;
#define PIPE1Init() pipe_periph_init(&pipe1, STRINGIFY(USE_PIPE1_READER), STRINGIFY(USE_PIPE1_WRITER)) #define PIPE1Init() pipe_periph_init(&pipe1, STRINGIFY(USE_PIPE1_READER), STRINGIFY(USE_PIPE1_WRITER))
#endif // USE_PIPE1 #endif // USE_PIPE1
#if USE_PIPE2_WRITER || USE_PIPE2_READER #if defined(USE_PIPE2_WRITER) || defined(USE_PIPE2_READER)
extern struct pipe_periph pipe2; extern struct pipe_periph pipe2;
#ifndef USE_PIPE2_WRITER #ifndef USE_PIPE2_WRITER