Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

di_tempd.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, send data and close.

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


Variables

const int SRV_PORT = 51307
 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.

Supposed to read a single LM35CAZ on channel zero.

A client connects to the socket, and this triggers a read of channel zero. This is converted to ASCII (fixed format, 5.2f) and printed out to the socket. A purpose-built hack of di_source used for remote monitoring.

Author:
Paul Hubbard
Date:
7/16/02

Definition in file di_tempd.c.


Function Documentation

int daq_loop const int  CLIENT_SOCKET,
const int  USEC_DELAY
 

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

Note:
Tries environment var DI194_PORT
Parameters:
CLIENT_SOCKET File descriptor of clients' TCP socket
USEC_DELAY Is ignored for now; crude rate setting

Definition at line 153 of file di_tempd.c.

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

Referenced by main_loop().

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 305 of file di_tempd.c.

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

void main_loop const int  usec_delay  ) 
 

Setup a socket, wait for a connection, send data and close.

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

Definition at line 227 of file di_tempd.c.

Referenced by main().

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 135 of file di_tempd.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 46 of file di_tempd.c.

References QUEUE_LENGTH, and SRV_PORT.


Variable Documentation

bool do_exit
 

Global boolean set by signal handler to force exit.

Definition at line 36 of file di_tempd.c.

const int QUEUE_LENGTH = 64
 

TCP connection queue length.

Definition at line 34 of file di_tempd.c.

const int SRV_PORT = 51307
 

TCP server port.

Definition at line 32 of file di_tempd.c.


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