Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

modeegdriver.c File Reference

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <nsnet.h>
#include <nsutil.h>
#include <nsser.h>
#include <openedf.h>
#include <config.h>

Go to the source code of this file.

Defines

#define PROTOWINDOW   17
 include neuroserver network support include neuroserver serial port functions include neuroserver European Data Format (EDF) functions include Software VERSION number/system information maximum size of a serial port data chunk

#define MINGOOD   6
#define P2CHAN   6

Functions

int isValidPacket (unsigned short nchan, unsigned short *samples)
int doesMatchP3 (unsigned char c, unsigned short *vals, int *nsamples)
int doesMatchP2 (unsigned char c, unsigned short *vals, int *nsamples)
int mGetOK (sock_t fd, struct InputBuffer *ib)
 get neuroserver response

void resetBuffer (void)
void gobbleChars (int howMany)
void eatCharacter (unsigned char c)
 this function does the real data processing of serial input data

void handleSamples (int packetCounter, int chan, unsigned short *vals)
void printHelp ()
 prints command line options / brief description of the program

int main (int argc, char **argv)

Variables

char buf [PROTOWINDOW]
sock_t sock_fd
int bufCount
int hasMatchedProtocol
int isP2
int isP3


Detailed Description

Author:
Rudi Cilibrasi
Device driver for the modularEEG from the OpenEEG project.

So far protocols P2 and P3 are supported. (For details regarding these protocols see )

Definition in file modeegdriver.c.


Define Documentation

#define MINGOOD   6
 

#define P2CHAN   6
 

#define PROTOWINDOW   17
 

include neuroserver network support include neuroserver serial port functions include neuroserver European Data Format (EDF) functions include Software VERSION number/system information maximum size of a serial port data chunk

Definition at line 51 of file modeegdriver.c.

Referenced by doesMatchOpenCNV(), doesMatchP2(), eatCharacter(), and main().


Function Documentation

int doesMatchP2 unsigned char  c,
unsigned short *  vals,
int *  nsamples
 

Definition at line 270 of file modeegdriver.c.

References handleSamples(), MAXCHANNELS, PROTOWINDOW, rexit(), and rprintf().

Referenced by eatCharacter().

int doesMatchP3 unsigned char  c,
unsigned short *  vals,
int *  nsamples
 

Definition at line 206 of file modeegdriver.c.

References handleSamples(), isP3, MAXCHANNELS, rprintf(), and samples.

Referenced by eatCharacter().

void eatCharacter unsigned char  c  ) 
 

this function does the real data processing of serial input data

number of frames until protocol is locked in

place to store eeg data

has the protocol been detected and validated ?

not yet, or error previously

now it detected the frame, from now on the protocol is fixed

check packet for validity

ok, didmatch is 0, so it didn't match so far

Definition at line 127 of file modeegdriver.c.

References buf, bufCount, doesMatchP2(), doesMatchP3(), hasMatchedProtocol, isP2, isP3, isValidPacket(), MAXCHANNELS, PROTOWINDOW, and rprintf().

void gobbleChars int  howMany  ) 
 

Definition at line 119 of file modeegdriver.c.

References buf, and bufCount.

void handleSamples int  packetCounter,
int  chan,
unsigned short *  vals
 

Definition at line 190 of file modeegdriver.c.

References buf, EDFDecodedHeader::dataRecordChannels, EDFDecodedConfig::hdr, ib, MAXLEN, mGetOK(), sock_fd, and writeString().

int isValidPacket unsigned short  nchan,
unsigned short *  samples
 

Definition at line 104 of file modeegdriver.c.

References samples.

int main int  argc,
char **  argv
 

buffer for reading from serial port

DEFAULTHOST;

DEFAULTPORT;

process command line inputs

Definition at line 347 of file modeegdriver.c.

References EDFDecodedConfig::chan, DEFAULTDEVICE, DEFAULTHOST, DEFAULTPORT, eatCharacter(), EDFPacket, ib, isEOF(), makeREDFConfig(), max_fd, MAXHEADERLEN, MAXLEN, mGetOK(), my_read(), openSerialPort(), OSTYPESTR, printHelp(), PROTOWINDOW, rconnectName(), readSerial(), rexit(), rinitNetworking(), rprintf(), rselect_timed(), rsocket(), EDFDecodedChannelHeader::sampleCount, ser_t, setblocking(), sock_fd, updateMaxFd(), writeBytes(), writeEDFString(), and writeString().

int mGetOK sock_t  fd,
struct InputBuffer ib
 

get neuroserver response

Definition at line 68 of file modeegdriver.c.

void printHelp  ) 
 

prints command line options / brief description of the program

Definition at line 339 of file modeegdriver.c.

References DEFAULTDEVICE, DEFAULTHOST, DEFAULTPORT, and rprintf().

Referenced by main().

void resetBuffer void   ) 
 

Definition at line 114 of file modeegdriver.c.

References bufCount.


Variable Documentation

char buf[PROTOWINDOW]
 

Definition at line 53 of file modeegdriver.c.

Referenced by addBlock(), cmdDataFrame(), cmdSetHeader(), cmdStatus(), eatCharacter(), getDMY(), getHMS(), gobbleChars(), handleSamples(), monitorLog(), readEDFString(), readSerial(), rprintf(), storeEDFDouble(), storeEDFInt(), storeEDFString(), stringifyErrorCode(), waitForNetEvent(), writeBytes(), writeEDFString(), writeNSBytes(), writeSerial(), and writeString().

int bufCount
 

Definition at line 55 of file modeegdriver.c.

Referenced by eatCharacter(), gobbleChars(), and resetBuffer().

int hasMatchedProtocol
 

Definition at line 60 of file modeegdriver.c.

Referenced by eatCharacter().

int isP2
 

Definition at line 61 of file modeegdriver.c.

Referenced by eatCharacter().

int isP3
 

Definition at line 61 of file modeegdriver.c.

Referenced by doesMatchP3(), and eatCharacter().

sock_t sock_fd
 

Definition at line 54 of file modeegdriver.c.


Generated on Tue Feb 8 00:05:17 2005 for Neuroserver by doxygen 1.3.3