Exemple #1
0
static apr_status_t
write_lisp_line (apr_socket_t * socket, const char * data)
{
  RELAY_ERROR (write_lisp_data (socket, data, (strlen (data))));
  RELAY_ERROR (write_lisp_data (socket, "\n", 1));
  return (APR_SUCCESS);
}
Exemple #2
0
static int picc_receive_capdu(driver_data_t *driver_data,
        unsigned char **capdu, size_t *len)
{
    ssize_t linelen;
    struct picc_data *data = driver_data;

    if (!data || !capdu || !len)
        return 0;


    /* read C-APDU */
    linelen = getline(&data->line, &data->linemax, data->fd);
    if (linelen <= 0) {
        if (linelen < 0) {
            RELAY_ERROR("Error reading from %s: %s\n", PICCDEV, strerror(errno));
            return 0;
        }
        if (linelen == 0) {
            *len = 0;
            return 1;
        }
    }
    if (fflush(data->fd) != 0)
        RELAY_ERROR("Warning, fflush failed: %s\n", strerror(errno));

    DEBUG("%s", data->line);


    /* decode C-APDU */
    return picc_decode_apdu(data->line, linelen, capdu, len);
}
Exemple #3
0
static int picc_send_rapdu(driver_data_t *driver_data,
        const unsigned char *rapdu, size_t len)
{
    struct picc_data *data = driver_data;
    size_t buflen;

    if (!data || !rapdu)
        return 0;


    /* encode R-APDU */
    if (!picc_encode_rapdu(rapdu, len, &data->e_rapdu, &buflen))
        return 0;


    /* write R-APDU */
    DEBUG("INF: Writing R-APDU\r\n%s\r\n", data->e_rapdu);

    if (fprintf(data->fd,"%s\r\n", data->e_rapdu) < 0) {
        RELAY_ERROR("Error writing to %s: %s\n", PICCDEV, strerror(errno));
        return 0;
    }
    if (fflush(data->fd) != 0)
        RELAY_ERROR("Warning, fflush failed: %s\n", strerror(errno));


    return 1;
}
Exemple #4
0
static apr_status_t
write_lisp_header (apr_socket_t * socket,
                   const char * name, const char * value)
{
  RELAY_ERROR (write_lisp_line (socket, name));
  RELAY_ERROR (write_lisp_line (socket, value));
  return (APR_SUCCESS);
}
Exemple #5
0
static apr_status_t
read_lisp_line (apr_socket_t * socket, char * s, unsigned int len)
{
  input_buffer_t * buffer;
  char * scan_output = s;
  char * end_output = (scan_output + (len - 1));
  unsigned int n_pending_returns = 0;
  
  RELAY_ERROR (get_input_buffer (socket, (&buffer)));
  while (1)
    {
      if ((buffer->start) == (buffer->end))
	RELAY_ERROR (fill_input_buffer (socket));
      
      if ((buffer->start) > (buffer->end))
	{
	  if (scan_output == s)
	    return (APR_EOF);
	  goto done;
	}

      while (((buffer->start) < (buffer->end)) && (scan_output < end_output))
	{
	  char c = (*(buffer->start)++);
	  if (c == '\n')
	    {
	      if (n_pending_returns > 0)
		n_pending_returns -= 1;
	      goto done;
	    }
	  if (c == '\r')
	    n_pending_returns += 1;
	  else
	    {
	      while ((n_pending_returns > 0) && (scan_output < end_output))
		{
		  (*scan_output++) = '\r';
		  n_pending_returns -= 1;
		}
	      if (scan_output == end_output)
		goto done;
	      (*scan_output++) = c;
	    }
	}
    }
 done:
  while ((n_pending_returns > 0) && (scan_output < end_output))
    {
      (*scan_output++) = '\r';
      n_pending_returns -= 1;
    }
  (*scan_output) = '\0';
  return (APR_SUCCESS);
}
Exemple #6
0
int picc_decode_apdu(const char *inbuf, size_t inlen,
        unsigned char **outbuf, size_t *outlen)
{
    size_t pos, length;
    char *end;
    unsigned char *p;
    unsigned long int b;

    if (!outbuf || !outlen) {
        return 0;
    }
    if (inbuf == NULL || inlen == 0 || inbuf[0] == '\0') {
        /* Ignore empty and 'RESET' lines */
        *outlen = 0;
        return 1;
    }

    length = strtoul(inbuf, &end, 16);

    /* check for ':' right behind the length */
    if (inbuf+inlen < end+1 || end[0] != ':') {
        *outlen = 0;
        return 1;
    }
    end++;

    p = realloc(*outbuf, length);
    if (!p) {
        RELAY_ERROR("Error allocating memory for decoded C-APDU\n");
        return 0;
    }
    *outbuf = p;

    pos = 0;
    while(inbuf+inlen > end && length > pos) {
        b = strtoul(end, &end, 16);
        if (b > 0xff) {
            RELAY_ERROR("Error decoding C-APDU\n");
            return 0;
        }

        p[pos++] = b;
    }

    *outlen = length;

    return 1;
}
/**
\brief	Loads a new key frame.

\author	dcofer
\date	3/24/2011

\param [in,out]	oXml	The xml of the keyframe to load. 

\return	Pointer to the new keyframe.
**/
KeyFrame *SimulationRecorder::LoadKeyFrame(CStdXml &oXml)
{
	KeyFrame *lpFrame = NULL;
	std::string strModuleName, strType;

try
{
	oXml.IntoElem(); //Into KeyFrame Element
	strModuleName = oXml.GetChildString("ModuleName", "");
	strType = oXml.GetChildString("Type");
	oXml.OutOfElem(); //OutOf KeyFrame Element

	lpFrame = dynamic_cast<KeyFrame *>(m_lpSim->CreateObject(strModuleName, "KeyFrame", strType));
	if(!lpFrame)
		THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "KeyFrame");

	lpFrame->SetSystemPointers(m_lpSim, NULL, NULL, NULL, true);
	lpFrame->Load(oXml);

	Add(lpFrame);
	return lpFrame;
}
catch(CStdErrorInfo oError)
{
	if(lpFrame) delete lpFrame;
	RELAY_ERROR(oError);
	return NULL;
}
catch(...)
{
	if(lpFrame) delete lpFrame;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
/**
\brief	Loads a simulation window.

\author	dcofer
\date	3/25/2011

\param [in,out]	oXml	The xml for the window to load. 

\return	Pointer to the new simulation window.
**/
SimulationWindow *SimulationWindowMgr::LoadSimulationWindow(CStdXml &oXml)
{
	SimulationWindow *lpWin=NULL;
	std::string strModuleName, strType;

try
{
	oXml.IntoElem();  //Into Column Element
	strModuleName = oXml.GetChildString("ModuleName", "");
	strType = oXml.GetChildString("Type");
	oXml.OutOfElem();  //OutOf Column Element

	lpWin = dynamic_cast<SimulationWindow *>(m_lpSim->CreateObject(strModuleName, "SimulationWindow", strType));
	if(!lpWin)
		THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "SimulationWindow");

	lpWin->SetSystemPointers(m_lpSim, NULL, NULL, NULL, true);
	lpWin->Load(oXml);

	return lpWin;
}
catch(CStdErrorInfo oError)
{
	if(lpWin) delete lpWin;
	RELAY_ERROR(oError);
	return NULL;
}
catch(...)
{
	if(lpWin) delete lpWin;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
bool PhysicsNeuralModule::AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError, bool bDoNotInit)
{
    std::string strType = Std_CheckString(strItemType);

    if(strType == "ADAPTER")
    {
        try
        {
            AddAdapter(strXml, bDoNotInit);
            return true;
        }
        catch(CStdErrorInfo oError)
        {
            if(bThrowError)
                RELAY_ERROR(oError);
        }
    }


    //If it was not one of those above then we have a problem.
    if(bThrowError)
        THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);

    return false;
}
//
// compress() is the public function used to compress
// a single file.  It has to take care of opening the
// input and output files and setting up the buffers for
// Zlib.  It then calls deflate() repeatedly until all
// input and output processing has been done, and finally
// closes the files and cleans up the Zlib structures.
//
void CStdCompress::CompressFile( const char *input,
                                 const char *output,
                                 int level )
{

try
{
    err = Z_OK;
    avail_in = 0;
    avail_out = output_length;
    next_out = output_buffer;
    m_AbortFlag = 0;

    fin  = fopen( input, "rb" );
    fout = fopen( output, "wb" );
    length = filelength( fileno( fin ) );
    deflateInit( this, level );
    for ( ; ; ) {
        if ( m_AbortFlag )
            break;
        if ( !load_input() )
            break;
        err = deflate( this, Z_NO_FLUSH );
        flush_output();
        if ( err != Z_OK )
            break;
        progress( percent() );
    }
    for ( ; ; ) {
        if ( m_AbortFlag )
            break;
        err = deflate( this, Z_FINISH );
        if ( !flush_output() )
            break;
        if ( err != Z_OK )
            break;
    }
    progress( percent() );
    deflateEnd( this );
    if ( m_AbortFlag )
        status( "User Abort" );
    else if ( err != Z_OK && err != Z_STREAM_END )
        status( "Zlib Error" );
    else {
        status( "Success" );
        err = Z_OK;
    }
    fclose( fin );
    fclose( fout );
    fin = 0;
    fout = 0;

	if(err != Z_OK && !m_AbortFlag)
		THROW_ERROR(Std_Err_ZLIB_lCompress, Std_Err_ZLIB_strCompress);
}
catch(CStdErrorInfo oError)
{RELAY_ERROR(oError);}
catch(...)
{THROW_ERROR(Std_Err_ZLIB_lUnspecifiedError, Std_Err_ZLIB_strUnspecifiedError);}
}
ConstraintFriction *RbClassFactory::CreateConstraintFriction(std::string strType, bool bThrowError)
{
	ConstraintFriction *lpFriction=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "CONSTRAINTRELAXATION" || strType == "DEFAULT")
	{
		lpFriction = new RbConstraintFriction;
	}
	else
	{
		lpFriction = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType, "Friction", strType);
	}

	return lpFriction;
}
catch(CStdErrorInfo oError)
{
	if(lpFriction) delete lpFriction;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpFriction) delete lpFriction;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
ExternalStimulus *ClassFactory::CreateExternalStimulus(string strType, BOOL bThrowError)
{
	ExternalStimulus *lpStimulus=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "POSTURECONTROL")
		lpStimulus = new ExternalStimuli::PostureControlStimulus;
	else if(strType == "SYNERGYFITNESS")
		lpStimulus = new ExternalStimuli::SynergyFitnessEval;
	else
	{
		lpStimulus = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Nl_Err_lInvalidExternalStimulusType, Nl_Err_strInvalidExternalStimulusType, "ExternalStimulusType", strType);
	}

	return lpStimulus;
}
catch(CStdErrorInfo oError)
{
	if(lpStimulus) delete lpStimulus;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpStimulus) delete lpStimulus;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
IonChannel *ClassFactory::CreateIonChannel(std::string strType, bool bThrowError)
{
	IonChannel *lpChannel=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "IONCHANNEL")
		lpChannel = new IonChannel;
	else
	{
		lpChannel = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Rn_Err_lInvalidIonChannelType, Rn_Err_strInvalidIonChannelType, "IonChannel", strType);
	}

	return lpChannel;
}
catch(CStdErrorInfo oError)
{
	if(lpChannel) delete lpChannel;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpChannel) delete lpChannel;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
DataColumn *RbClassFactory::CreateDataColumn(std::string strType, bool bThrowError)
{
	DataColumn *lpColumn=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "DATACOLUMN")
		lpColumn = new DataColumn;
	else
	{
		lpColumn = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidDataColumnType, Al_Err_strInvalidDataColumnType, "DataColumnType", strType);
	}

	return lpColumn;
}
catch(CStdErrorInfo oError)
{
	if(lpColumn) delete lpColumn;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpColumn) delete lpColumn;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Exemple #15
0
int picc_encode_rapdu(const unsigned char *inbuf, size_t inlen,
        char **outbuf, size_t *outlen)
{
    char *p;
    const unsigned char *next;
    size_t length;

    if (!inbuf || inlen > 0xffff || !outbuf)
        return 0;

    /* length with ':' + for each byte ' ' with hex + '\0' */
    length = 5+inlen*3+1;
    p = realloc(*outbuf, length);
    if (!p) {
        RELAY_ERROR("Error allocating memory for encoded R-APDU\n");
        return 0;
    }
    *outbuf = p;
    *outlen = length;

    /* write length of R-APDU */
    sprintf(p, "%0lX:", inlen);

    /* next points to the next byte to encode */
    next = inbuf;
    /* let p point behind ':' to write hex encoded bytes */
    p += 5;
    while (inbuf+inlen > next) {
        sprintf(p, " %02X", *next);
        next++;
        p += 3;
    }

    return 1;
}
Simulator *RbClassFactory::CreateSimulator(std::string strType, bool bThrowError)
{
	Simulator *lpSimulator=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "ROBOTICSSIMULATOR")
		lpSimulator = new RbSimulator;
	else if(strType == "")
		lpSimulator = new RbSimulator;
	else
	{
		lpSimulator = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidSimulatorType, Al_Err_strInvalidSimulatorType, "SimulatorType", strType);
	}

	return lpSimulator;
}
catch(CStdErrorInfo oError)
{
	if(lpSimulator) delete lpSimulator;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpSimulator) delete lpSimulator;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
// ************* KeyFrame Type Conversion functions ******************************
KeyFrame *RbClassFactory::CreateKeyFrame(std::string strType, bool bThrowError)
{
	KeyFrame *lpFrame=NULL;

try
{
//	strType = Std_ToUpper(Std_Trim(strType));
//
//	if(strType == "VIDEO")
//		lpFrame = new VsVideoKeyFrame;
//	else if(strType == "SNAPSHOT")
//		lpFrame = new VsSnapshotKeyFrame;
//	else
//	{
//		lpFrame = NULL;
//		if(bThrowError)
//			THROW_PARAM_ERROR(Al_Err_lInvalidKeyFrameType, Al_Err_strInvalidKeyFrameType, "KeyFrameType", strType);
//	}

	return lpFrame;
}
catch(CStdErrorInfo oError)
{
	if(lpFrame) delete lpFrame;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpFrame) delete lpFrame;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
ExternalStimulus *ClassFactory::CreateExternalStimulus(std::string strType, bool bThrowError)
{
	ExternalStimulus *lpStimulus=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "CURRENT")
		lpStimulus = new AnimatSim::ExternalStimuli::CurrentStimulus;
	else if(strType == "VOLTAGECLAMP")
		lpStimulus = new AnimatSim::ExternalStimuli::VoltageClamp;
	else
	{
		lpStimulus = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidExternalStimulusType, Al_Err_strInvalidExternalStimulusType, "ExternalStimulusType", strType);
	}

	return lpStimulus;
}
catch(CStdErrorInfo oError)
{
	if(lpStimulus) delete lpStimulus;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpStimulus) delete lpStimulus;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
NeuralModule *ClassFactory::CreateNeuralModule(std::string strType, bool bThrowError)
{
	NeuralModule *lpModule=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "INTEGRATEFIRESIMMODULE")
		lpModule = new IntegrateFireNeuralModule;
	else
	{
		lpModule = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType, "NeuralModule", strType);
	}

	return lpModule;
}
catch(CStdErrorInfo oError)
{
	if(lpModule) delete lpModule;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpModule) delete lpModule;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
DataColumn *DataChart::LoadDataColumn(Simulator *lpSim, CStdXml &oXml)
{
	DataColumn *lpColumn=NULL;
	string strModuleName, strType;

try
{
	oXml.IntoElem();  //Into Column Element
	strModuleName = oXml.GetChildString("ModuleName", "");
	strType = oXml.GetChildString("Type");
	oXml.OutOfElem();  //OutOf Column Element

	lpColumn = dynamic_cast<DataColumn *>(lpSim->CreateObject(strModuleName, "DataColumn", strType));
	if(!lpColumn)
		THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "DataColumn");

	lpColumn->Load(lpSim, oXml);

	AddColumn(lpColumn);

	return lpColumn;
}
catch(CStdErrorInfo oError)
{
	if(lpColumn) delete lpColumn;
	RELAY_ERROR(oError);
	return NULL;
}
catch(...)
{
	if(lpColumn) delete lpColumn;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
/**
\brief	Adds a new keyframe type.

\author	dcofer
\date	3/24/2011

\param	strType	the keyframe Type to add. 
\param	lStart 	The start time of the keyframe. 
\param	lEnd   	The end time of the keyframe. 

\return	Pointer to the new keyframe.
**/
KeyFrame *SimulationRecorder::Add(std::string strType, long lStart, long lEnd)
{
	KeyFrame *lpFrame = NULL;

try
{
	lpFrame = dynamic_cast<KeyFrame *>(m_lpSim->CreateObject("AnimatLab", "KeyFrame", strType));
	if(!lpFrame)
		THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "KeyFrame");

	lpFrame->EndSlice(lEnd);
	lpFrame->StartSlice(lStart);
	lpFrame->GenerateID();

	Add(lpFrame);

	lpFrame->Initialize();

	return lpFrame;
}
catch(CStdErrorInfo oError)
{
	if(lpFrame) delete lpFrame;
	RELAY_ERROR(oError);
	return NULL;
}
catch(...)
{
	if(lpFrame) delete lpFrame;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Connexion *ClassFactory::CreateSynapse(std::string strType, bool bThrowError)
{
	Connexion *lpSynapse=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "SYNAPSE")
		lpSynapse = new Connexion;
	else
	{
		lpSynapse = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Rn_Err_lInvalidSynapseType, Rn_Err_strInvalidSynapseType, "SynapseType", strType);
	}

	return lpSynapse;
}
catch(CStdErrorInfo oError)
{
	if(lpSynapse) delete lpSynapse;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpSynapse) delete lpSynapse;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
/**
\brief	Loads a synapse.

\author	dcofer
\date	3/29/2011

\param [in,out]	oXml	The xml to load. 

\return	Pointer to the created synapse.
**/
Synapse *Neuron::LoadSynapse(CStdXml &oXml)
{
	std::string strType;
	Synapse *lpSynapse=NULL;

try
{
	oXml.IntoElem();  //Into Synapse Element
	strType = oXml.GetChildString("Type");
	oXml.OutOfElem(); //OutOf Synapse Element

	lpSynapse = dynamic_cast<Synapse *>(m_lpSim->CreateObject(Nl_NeuralModuleName(), "Synapse", strType));
	if(!lpSynapse)
		THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "Synapse");

	lpSynapse->SetSystemPointers(m_lpSim, m_lpStructure, m_lpFRModule, this, true);
	lpSynapse->Load(oXml);
	AddSynapse(lpSynapse);

	return lpSynapse;
}
catch(CStdErrorInfo oError)
{
	if(lpSynapse) delete lpSynapse;
	RELAY_ERROR(oError);
	return NULL;
}
catch(...)
{
	if(lpSynapse) delete lpSynapse;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Light *RbClassFactory::CreateLight(std::string strType, bool bThrowError)
{
	Light *lpItem=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	lpItem = NULL;
	if(bThrowError)
		THROW_PARAM_ERROR(Rb_Err_lInvalidLightType, Rb_Err_strInvalidLightType, "Light Type", strType);

	return lpItem;
}
catch(CStdErrorInfo oError)
{
	if(lpItem) delete lpItem;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpItem) delete lpItem;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Exemple #25
0
static int picc_connect(driver_data_t **driver_data)
{
    struct picc_data *data;

    if (!driver_data)
        return 0;


    data = realloc(*driver_data, sizeof *data);
    if (!data)
        return 0;
    *driver_data = data;

    data->e_rapdu = NULL;
    data->line = NULL;
    data->linemax = 0;

    data->fd = fopen(PICCDEV, "a+"); /*O_NOCTTY ?*/
    if (!data->fd) {
        RELAY_ERROR("Error opening %s: %s\n", PICCDEV, strerror(errno));
        return 0;
    }
    un_braindead_ify_device(fileno(data->fd));


    PRINTF("Connected to %s\n", PICCDEV);

    return 1;
}
NeuralModule *RbClassFactory::CreateNeuralModule(std::string strType, bool bThrowError)
{
	NeuralModule *lpModule=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "PHYSICSNEURALMODULE")
	{
		lpModule = new AnimatSim::Behavior::PhysicsNeuralModule;
		lpModule->ClassFactory(new RbClassFactory());
	}
	else
	{
		lpModule = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType, "NeuralModule", strType);
	}

	return lpModule;
}
catch(CStdErrorInfo oError)
{
	if(lpModule) delete lpModule;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpModule) delete lpModule;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Hud *RbClassFactory::CreateHud(std::string strType, bool bThrowError)
{
	Hud *lpHud=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	lpHud = NULL;
	if(bThrowError)
		THROW_PARAM_ERROR(Rb_Err_lInvalidHudItemType, Rb_Err_strInvalidHudItemType, "Hud", strType);

	return lpHud;
}
catch(CStdErrorInfo oError)
{
	if(lpHud) delete lpHud;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpHud) delete lpHud;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
ScriptProcessor *PyClassFactory::CreateScriptProcessor(std::string strType, bool bThrowError)
{
	ScriptProcessor *lpScript=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "SCRIPTPROCESSORPY")
		lpScript = new ScriptProcessorPy();
	else
	{
		lpScript = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Al_Err_lInvalidPartType, Al_Err_strInvalidPartType, "PartType", strType);
	}
	
	return lpScript;
}
catch(CStdErrorInfo oError)
{
	if(lpScript) delete lpScript;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpScript) delete lpScript;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
MaterialType *RbClassFactory::CreateMaterialItem(std::string strType, bool bThrowError)
{
	MaterialType *lpItem=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "BASIC" || strType == "DEFAULT" || strType == "BULLET")
		lpItem = new RbMaterialType;
	else
	{
		lpItem = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Rb_Err_lInvalidMaterialItemType, Rb_Err_strInvalidMaterialItemType, "Material Pair", strType);
	}

	return lpItem;
}
catch(CStdErrorInfo oError)
{
	if(lpItem) delete lpItem;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpItem) delete lpItem;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}
Neuron *ClassFactory::CreateNeuron(std::string strType, bool bThrowError)
{
	Neuron *lpNeuron=NULL;

try
{
	strType = Std_ToUpper(Std_Trim(strType));

	if(strType == "NEURON")
		lpNeuron = new Neuron;
	else 
	{
		lpNeuron = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Rn_Err_lInvalidNeuronType, Rn_Err_strInvalidNeuronType, "NeuronType", strType);
	}

	return lpNeuron;
}
catch(CStdErrorInfo oError)
{
	if(lpNeuron) delete lpNeuron;
	RELAY_ERROR(oError); 
	return NULL;
}
catch(...)
{
	if(lpNeuron) delete lpNeuron;
	THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
	return NULL;
}
}