mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
fix pipe
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user