#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <pthread.h>
#include <getopt.h>
#include <sys/termios.h>
#include <fcntl.h>
#include "nsds_util.h"
#include "flog.h"
#include "adxl_util.h"
Go to the source code of this file.
Data Structures | |
struct | thread_params_t |
Struct passed to data thread - holds TCP port descriptor and serial port. More... | |
Functions | |
int | data_active_count (void) |
Return number of active channels. | |
bool | data_channel_enabled (const int channel_id) |
Is a channel subscribed? | |
int | data_channel_flag (const int channel_id, const bool subscribe) |
Mark a channel as subscribed or unsubscribed. | |
void * | daq_thread_main (void *arg) |
Data handling thread. | |
int | daq_do_work (const int control_socket, const int data_socket, const thread_params_t *thread_params) |
Main worker routine: read / parse / respond. | |
void | daq_main_loop (const int daq_port, const char *serial_portname, const int sample_delay) |
Open network socket, loop doing work until control-c. | |
int | main (int argc, char *argv[]) |
Init the network, talk to all. | |
Variables | |
const int | DAQ_PORT = 55050 |
Default TCP port to listen on. | |
bool | streaming_active |
Semaphore boolean. | |
const int | TCP_Q_LEN = 1 |
Depth of TCP queue. | |
struct { | |
pthread_mutex_t mutex | |
bool active [NUM_ADXL_CHANNELS] | |
int num_active | |
} | chan_struct |
Shared structure for subscribed data channels. |
Definition in file nees-adxl.c.
|
Main worker routine: read / parse / respond.
Definition at line 375 of file nees-adxl.c. References daq_thread_main(), data_active_count(), data_channel_flag(), NUM_ADXL_CHANNELS, and streaming_active. Referenced by daq_main_loop(). |
|
Open network socket, loop doing work until control-c.
Definition at line 624 of file nees-adxl.c. References control_break, daq_do_work(), thread_params_t::delay_usec, thread_params_t::serial_port, thread_params_t::socket_fd, streaming_active, and TCP_Q_LEN. Referenced by main(). |
|
Data handling thread. Transient thread to send data out the data channel. Dead simple.
Definition at line 245 of file nees-adxl.c. References adxl_close(), ADXL_DATUM_LEN, adxl_open(), adxl_read(), control_break, data_active_count(), data_channel_enabled(), thread_params_t::delay_usec, adxl_reading_t::G, NUM_ADXL_CHANNELS, thread_params_t::serial_port, thread_params_t::socket_fd, and streaming_active. Referenced by daq_do_work(). |
|
Return number of active channels.
Definition at line 74 of file nees-adxl.c. References chan_struct. Referenced by daq_do_work(), and daq_thread_main(). |
|
Is a channel subscribed? Locks mutex and checks array to see if a channel is subscribed.
Definition at line 112 of file nees-adxl.c. References chan_struct, and NUM_ADXL_CHANNELS. Referenced by daq_thread_main(). |
|
Mark a channel as subscribed or unsubscribed. Lock the mutex, set the bit, report if it changed.
Definition at line 159 of file nees-adxl.c. References chan_struct, and NUM_ADXL_CHANNELS. Referenced by daq_do_work(). |
|
Init the network, talk to all. Parse options, installs signal handler, calls worker routine.
Definition at line 719 of file nees-adxl.c. References ADXL_MAX_RATE_HZ, adxl_sighandler(), control_break, daq_main_loop(), DAQ_PORT, and NUM_ADXL_CHANNELS. |
|
R/W mutex for struct.
Definition at line 54 of file nees-adxl.c. |
|
Shared structure for subscribed data channels.
Referenced by data_active_count(), data_channel_enabled(), and data_channel_flag(). |
|
Default TCP port to listen on.
Definition at line 42 of file nees-adxl.c. Referenced by main(). |
|
Definition at line 53 of file nees-adxl.c. |
|
Definition at line 55 of file nees-adxl.c. |
|
Semaphore boolean.
Definition at line 45 of file nees-adxl.c. Referenced by daq_do_work(), daq_main_loop(), and daq_thread_main(). |
|
Depth of TCP queue.
Definition at line 48 of file nees-adxl.c. Referenced by daq_main_loop(). |