Commit 44ad9ca8 authored by kirov's avatar kirov
Browse files

+ Added Serial Line stuff



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@58 45c4679d-1946-429d-baad-37912b19538b
parent 6cffbfd9
#ifndef ESPIASERIALLINE_H
#define ESPIASERIALLINE_H
#include <string>
#include "Exceptions.h"
#include "HwSerialLine.h"
namespace lima {
class EspiaSerialLine : public HwSerialLine
{
public :
EspiaSerialLine( char line_term='\r', double timeout=1.0 );
~EspiaSerialLine();
void serialGetAvail( int &avail );
void serialRead( std::string& buffer, int& len, double timeout );
void serialWrite( const std::string& buffer, int block_size = 0,
double block_delay = 0, bool no_wait = false );
void serialFlush();
private :
};
}
#endif /* ESPIASERIALLINE_H */
#include "EspiaSerialLine.h"
using namespace lima;
using namespace std;
#define check_null(ptr) if( NULL == ptr ) \
{\
throw LIMA_HW_EXC(InvalidValue, #ptr " is NULL");\
}
EspiaSerialLine::EspiaSerialLine( char line_term, double timeout ) :
HwSerialLine(line_term, timeout)
{
}
EspiaSerialLine::~EspiaSerialLine()
{
}
void EspiaSerialLine::serialGetAvail( int &avail )
{
}
void EspiaSerialLine::serialRead( string& buffer, int& len, double timeout )
{
}
void EspiaSerialLine::serialWrite( const string& buffer, int block_size,
double block_delay, bool no_wait )
{
}
void EspiaSerialLine::serialFlush()
{
}
#ESPIA_DRV_BASE = ../../../../../../bliss/source/driver/linux-2.6/espia
ESPIA_DRV_BASE = /segfs/bliss/source/driver/linux-2.6/espia
ESPIA_DRV_INC = $(ESPIA_DRV_BASE)/src
CXXFLAGS = -I../include -I../../../../hardware/include \
-I../../../../common/include -I$(ESPIA_DRV_INC)
all: clean Espia.o
all: clean Espia.o EspiaSerialLine.o
clean:
......
#ifndef HWSERIALLINE_H
#define HWSERIALLINE_H
#include <string>
#include "Exceptions.h"
namespace lima {
class HwSerialLine
{
public :
HwSerialLine( char line_term='\r', double timeout=1.0 );
virtual ~HwSerialLine();
virtual void getAvail( int &avail ) = 0;
virtual void read( std::string& buffer, int& len, double timeout ) = 0;
virtual void write( const std::string& buffer, int block_size = 0,
double block_delay = 0, bool no_wait = false ) = 0;
virtual void readStr( std::string& buffer, int max_len,
const std::string& term, double timeout );
virtual void readLine( std::string& buffer, int max_len,
double timeout );
virtual void writeRead( );
virtual void writeReadStr();
virtual void flush();
virtual void readAvailable();
private :
char m_line_term;
double m_timeout;
};
}
#endif /* HWSERIALLINE_H */
#include "HwSerialLine.h"
#include "Timestamp.h"
using namespace lima;
using namespace std;
#define check_null(ptr) if( NULL == ptr ) \
{\
throw LIMA_HW_EXC(InvalidValue, #ptr " is NULL");\
}
HwSerialLine::HwSerialLine( char line_term, double timeout ) :
m_line_term(line_term),
m_timeout(timeout)
{
}
HwSerialLine::~HwSerialLine()
{
}
/**
* @brief Read the serial line until term.
*/
void HwSerialLine::readStr( string& buffer, int max_len,
const string& term, double timeout )
{
Timestamp start=Timestamp::now();
int match=0, n, term_len=term.length();
bool have_timeout = (timeout > 0);
double tout=timeout;
string buf;
buffer = "";
while( ((!have_timeout) || (tout > 0)) && (buffer.length() < max_len) ) {
n = 1;
read( buf, n, tout );
if( 0 == n )
break; // ???
buffer += buf;
if( 0 == term.compare(match, n, buf) ) {
match += n;
if( match == term_len ) {
return;
}
} else {
match = 0;
}
if( have_timeout )
tout = timeout - double(Timestamp::now() - start);
}
}
/**
* @brief Read the serial line until line term.
*/
void HwSerialLine::readLine( string& buffer, int max_len, double timeout )
{
readStr( buffer, max_len, string(1, m_line_term), timeout );
}
/**
* @brief Write and then immediately Read the serial line until available?
*/
void HwSerialLine::writeRead()
{
}
/**
* @brief Write and then immediately Read the serial line until term.
*/
void HwSerialLine::writeReadStr()
{
}
/**
* @brief Flush the serial RX buffer
*/
void HwSerialLine::flush()
{
// Get available
// Read until there is something to read and thow it away
}
/**
* @brief Read the serial line until there is something to read
*/
void HwSerialLine::readAvailable()
{
// Get available
// Read until there is something to read
}
hw-objs := HwInterface.o HwCap.o HwSyncCtrlObj.o HwFrameInfo.o \
HwFrameCallback.o HwBufferCtrlObj.o HwBufferMgr.o \
HwShutterCtrlObj.o HwDetInfoCtrlObj.o HwBinCtrlObj.o
HwShutterCtrlObj.o HwDetInfoCtrlObj.o HwBinCtrlObj.o \
HwSerialLine.o
CXXFLAGS += -I../include -I../../common/include -Wall -pthread
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment