Esempio n. 1
0
/**
 * Specify the size of the output buffer.
 * 
 * Specify the amount of data that can be stored before being
 * transmitted to the device.
 * 
 * @param size The write buffer size.
 */
void SerialPort::SetWriteBufferSize(UINT32 size)
{
	if (!m_consoleModeEnabled)
	{
		ViStatus status = viSetBuf(m_portHandle, VI_WRITE_BUF, size);
		wpi_assertCleanStatus(status);
	}
}
Esempio n. 2
0
/**
 * Specify the size of the output buffer.
 * 
 * Specify the amount of data that can be stored before being
 * transmitted to the device.
 * 
 * @param size The write buffer size.
 */
void SerialPort::SetWriteBufferSize(UINT32 size)
{
    if (!m_consoleModeEnabled)
    {
        ViStatus localStatus = viSetBuf(m_portHandle, VI_WRITE_BUF, size);
        wpi_setError(localStatus);
    }
}
Esempio n. 3
0
/**
 * Specify the size of the input buffer.
 * 
 * Specify the amount of data that can be stored before data
 * from the device is returned to Read or Scanf.  If you want
 * data that is recieved to be returned immediately, set this to 1.
 * 
 * It the buffer is not filled before the read timeout expires, all
 * data that has been received so far will be returned.
 * 
 * @param size The read buffer size.
 */
void SerialPort::SetReadBufferSize(uint32_t size)
{
	if (!m_consoleModeEnabled)
	{
		ViStatus localStatus = viSetBuf(m_portHandle, VI_READ_BUF, size);
		wpi_setError(localStatus);
	}
}
Esempio n. 4
0
void serialSetWriteBufferSize(uint8_t port, uint32_t size, int32_t *status) {
	*status = viSetBuf(m_portHandle[port], VI_WRITE_BUF, size);
	if(*status > 0)
		*status = 0;
}
Esempio n. 5
0
void serialSetReadBufferSize(uint8_t port, uint32_t size, int32_t *status) {
	*status = viSetBuf(m_portHandle[port], VI_READ_BUF, size);
	if(*status > 0)
		*status = 0;
}
Esempio n. 6
0
// ================================================================================================
// FUNCTION  : mexFunction
// ------------------------------------------------------------------------------------------------
// Purpose   : Entry point for calls from MATLAB
// Parameters: nlhs -- Number of passed left-hand-side parameters
//             plhs -- Pointer to the left-hand-side parameter list
//             nrhs -- Number of passed right-hand-side arguments
//             prhs -- Pointer to the right-hand-side argument list
// ================================================================================================
void __cdecl mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    char *cmd;  // passed command parameter

    // --------------
    // Check for Init
    // --------------
    if( !mexVISA_IsInitialized ) mexVISA_Init();

    // ------------------
    // Dummy library call
    // ------------------
    if( !nrhs && !nlhs ) 
    {
        mexPrintf("\n");
        mexPrintf("   MATLAB VISA/GPIB Toolbox (%s %s)\n",__DATE__,__TIME__);
        mexPrintf("   Copyright 2007 DSP Group, Inc. All Rights Reserved.\n");
        mexPrintf("\n");
        return;
    }
    // ----------------------
    // Get the command string
    // ----------------------
    if( nrhs<1 ) mexErrMsgTxt("A string argument must be given as the first parameter.");
    cmd = ViMexUtil_GetStringValue(prhs[0],0);

    // ******************************************
    // *****                                *****
    // *****   COMMAND LOOKUP-AND-EXECUTE   *****
    // *****                                *****
    // ******************************************

    //----- mexVISA_*() Functions ----------------
    //--------------------------------------------
    if(strstr(cmd, "vi"))
    {
        if(!mexVISA(nlhs, plhs, nrhs, prhs))
            return;
    }
    //----- mexVISA_DisplaySessionList() ---------
    //--------------------------------------------
    if(!strcmp(cmd, "mexVISA_DisplaySessionList()"))
    {
        mexVISA_DisplaySessionList();
        return;
    }
    //----- EnableResourceChecking ---------------
    //--------------------------------------------
    if(!strcmp(cmd, "EnableResourceChecking"))
    {
        ResourceChecking = VI_TRUE;
        return;
    }
    //----- DisableResourceChecking --------------
    //--------------------------------------------
    if(!strcmp(cmd, "DisableResourceChecking"))
    {
        ResourceChecking = VI_FALSE;
        return;
    }
    //----- EnableSharedSession ------------------
    //--------------------------------------------
    if(!strcmp(cmd, "EnableSharedSessions"))
    {
        AllowSharedSessions = VI_TRUE;
        return;
    }
    //----- DisableSharedSession -----------------
    //--------------------------------------------
    if(!strcmp(cmd, "DisableSharedSessions"))
    {
        AllowSharedSessions = VI_FALSE;
        return;
    }
    //----- CloseAllSessions ---------------------
    //--------------------------------------------
    if(!strcmp(cmd, "CloseAllSessions"))
    {
        if(!ResourceChecking) 
            mexErrMsgTxt("CloseAllSessions requires ResourceChecking to be enabled.");

        while( pSessionList )
        {
            if(pSessionList->Prev) free(pSessionList->Prev);
            mexPrintf(" mexVISA: closing 0x%08X \"%s\"\n",pSessionList->Session,pSessionList->Resource);
            viClose(pSessionList->Session);
            pSessionList = pSessionList->Next;
        }         
        return;
    }
    //----- mexVISA_ReadLeCroyWaveform() ---------
    //--------------------------------------------
    if(!strcmp(cmd,"mexVISA_ReadLeCroyWaveform()"))
    {
        ViSession rmSession, Session;
        int       i, pts, cnt, MaxLength = 16000000;
        char     *buf, *resource, *trace, readbuf[64];
        double   *y, ygain, yofs, dt, t0;

        //- Get input parameters ------------------------------------------------
        ViMexUtil_CheckParameters(nlhs,nrhs,3,3);
        resource = ViMexUtil_GetStringValue(prhs[1], NULL);
        trace    = ViMexUtil_GetStringValue(prhs[2], NULL);

        //- Open instrument session ---------------------------------------------
        mexVISA_GetViRM(&rmSession);
        VICHK( viOpen(rmSession, resource, VI_NULL, VI_NULL, &Session) );

        //- Configure VISA Formatted I/O ----------------------------------------
        VICHK( viSetAttribute(Session, VI_ATTR_TMO_VALUE, 1000) );
        VICHK( viSetBuf      (Session, VI_READ_BUF|VI_WRITE_BUF, 4000) );
        VICHK( viSetAttribute(Session, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS) );
        VICHK( viSetAttribute(Session, VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS) );
        VICHK( viSetAttribute(Session, VI_ATTR_TERMCHAR_EN, VI_FALSE) );

        VICHK( viPrintf(Session,"COMM_ORDER HI\n") );
        VICHK( viPrintf(Session,"COMM_FORMAT DEF9,BYTE,BIN\n") );
        VICHK( viPrintf(Session,"WFSU SP,1,NP,%d,FP,0,SN,0\n",MaxLength) );
        
        MXERR(LeCroyInspectReal(Session, trace, "HORIZ_INTERVAL",  &dt   ) );
        MXERR(LeCroyInspectReal(Session, trace, "HORIZ_OFFSET",    &t0   ) );
        MXERR(LeCroyInspectReal(Session, trace, "VERTICAL_GAIN",   &ygain) );
        MXERR(LeCroyInspectReal(Session, trace, "VERTICAL_OFFSET", &yofs ) );
        MXERR(LeCroyInspectInt (Session, trace, "WAVE_ARRAY_COUNT",&pts  ) );

        if(pts > MaxLength) pts = MaxLength;
        if(!pts) 
        {
            viClose(Session); mxFree(resource); mxFree(trace);
            mexErrMsgTxt("Trace contains no data.");
        }
        buf = (char *)mxCalloc(pts+16, sizeof(char));
        if(!buf) mexErrMsgTxt("Memory allocation failed.");

        VICHK( viSetAttribute(Session, VI_ATTR_TMO_VALUE, 30000) );
        VICHK( viPrintf(Session, "CFMT IND0,BYTE,BIN;CHDR OFF;CORD LO\n") );
        VICHK( viPrintf(Session, "%s:WF? DAT1\n",trace) );
        VICHK( viRead  (Session, readbuf, 7, NULL) );
        VICHK( viRead  (Session, buf, pts, &cnt) );

        y = (double *)mxCalloc(pts, sizeof(double));
        if(!y) mexErrMsgTxt("Memory allocation failed.");

        // ------------------------------
        // Convert Sample Values to Volts
        // ------------------------------
        for(i=0; i<pts; i++)   
        {
            y[i] = ygain * (double)buf[i] - yofs;
        }
        mxFree(buf);
        ViMexUtil_PutRealArray(pts, y, plhs+0);
        ViMexUtil_PutRealValue(dt, plhs+1);
        ViMexUtil_PutRealValue(t0, plhs+2);
        mxFree(trace); mxFree(resource);
        viClose(Session);
        return;
    }
    // ******************************************************************
    // --------------------------------------------
    // No Command Found...Generate an Error Message
    // --------------------------------------------
    mexErrMsgTxt("mexLab: Unrecognized command in the first argument.");
}
Esempio n. 7
0
void HAL_SetSerialWriteBufferSize(int32_t port, int32_t size, int32_t* status) {
  *status = viSetBuf(m_portHandle[port], VI_WRITE_BUF, size);
  if (*status > 0) *status = 0;
}
Esempio n. 8
0
void HAL_SetSerialReadBufferSize(int32_t port, int32_t size, int32_t* status) {
  *status = viSetBuf(m_portHandle[port], VI_READ_BUF, size);
  if (*status > 0) *status = 0;
}