Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

di_source.c File Reference

A source of data that sends same out over TCP. More...

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <stdint.h>
#include "di194.h"

Go to the source code of this file.

Functions

int socket_make (void)
 Create server socket, ready for accept().

void sighandler (int signal)
 Control-break handler. Sets global flag to indicate exit request.

int daq_loop (const int CLIENT_SOCKET, const int USEC_DELAY)
 Read data, convert to ASCII, send out over port.

void main_loop (const int usec_delay)
 Setup a socket, wait for a connection, start streaming.

int main (int argc, char *argv[])
 Driver / test routine to exercise the DI code.


Variables

const int SRV_PORT = 31337
 TCP server port.

const int QUEUE_LENGTH = 64
 TCP connection queue length.

bool do_exit
 Global boolean set by signal handler to force exit.


Detailed Description

A source of data that sends same out over TCP.

This file implements a simple daemon process for sourcing data from the DI-194. It waits for a TCP connection to its port, at which point it starts reading data (currently a fixed rate) which it converts to ASCII and sends it out over the port.

Intended use is for testing SOAP, meaning that ASCII will need to become XML/XSIL.

To test this, start di_source and then telnet to localhost, port 31337 - you should see streaming data!

Author:
Paul Hubbard
Date:
5/19/02

Definition in file di_source.c.


Function Documentation

int daq_loop const int  CLIENT_SOCKET,
const int  USEC_DELAY
 

Read data, convert to ASCII, send out over port.

Note:
Runs until control-c detected or error occurrs

Tries environment var DI194_PORT

USEC_DELAY ignored for now; sends full rate

Parameters:
CLIENT_SOCKET File descriptor of clients' TCP socket
USEC_DELAY Is ignored for now; crude rate setting

Definition at line 159 of file di_source.c.

References daq_reading_t::analog, di_close(), di_daq_sync(), di_open(), di_read(), di_start(), daq_reading_t::digital, and do_exit.

int main int  argc,
char *  argv[]
 

Driver / test routine to exercise the DI code.

Note:
Uses contents of "DI194_PORT" if set
Main. Open the port, init the card, do some daq.

Too: -p port parsing, will need for USB serial. getopt!

Parameters:
argc Argc as passed by shell
argv Argv as passed by shell
Returns:
0 All is good

Non-zero All is not good

Definition at line 318 of file di_source.c.

References do_exit, main_loop(), and sighandler().

void main_loop const int  usec_delay  ) 
 

Setup a socket, wait for a connection, start streaming.

Date:
5/20/02
Parameters:
usec_delay Delay, in microseconds, between samples

Definition at line 240 of file di_source.c.

References daq_loop(), do_exit, and socket_make().

void sighandler int  signal  ) 
 

Control-break handler. Sets global flag to indicate exit request.

Assumes Installed in interrupt chain by someone else

Parameters:
signal Signal number
Date:
3/25/02

Definition at line 139 of file di_source.c.

References do_exit.

int socket_make void   ) 
 

Create server socket, ready for accept().

Note:
Uses compiled vars SRV_PORT and QUEUE_LENGTH

Borrowed from FNAL server code

Date:
5/19/02
Return values:
> 0 (Socket, OK)
<=0 (Error)

Definition at line 50 of file di_source.c.

References QUEUE_LENGTH, and SRV_PORT.

Referenced by main_loop().


Variable Documentation

bool do_exit
 

Global boolean set by signal handler to force exit.

Definition at line 40 of file di_source.c.

const int QUEUE_LENGTH = 64
 

TCP connection queue length.

Definition at line 38 of file di_source.c.

Referenced by socket_make().

const int SRV_PORT = 31337
 

TCP server port.

Definition at line 36 of file di_source.c.

Referenced by socket_make().


Generated on Thu May 1 11:31:46 2003 for DI-194 driver by doxygen1.3