Device-LabJack

 view release on metacpan or  search on metacpan

LabJack.xs  view on Meta::CPAN

            || ((numgains = av_len((AV *)SvRV(gains))) < 0))
        {
            XSRETURN_UNDEF;
        }

        // Make sure there's a gain for every channel
        if(numgains<numchannels) {
            XSRETURN_UNDEF;
        }

    PPCODE:

        // Extract the channels we got from perl...
        for (n = 0; n <= numchannels; n++) {
                lchannels[n]= SvNV(*av_fetch((AV *)SvRV(channels), n, 0));
        }
        // Extract the gains we got from perl...
        for (n = 0; n <= numgains; n++) {
                lgains[n]= SvNV(*av_fetch((AV *)SvRV(gains), n, 0));
        }
        numCh=numchannels+1;

LabJack.xs  view on Meta::CPAN

        float analogOut0
        float analogOut1

    INIT:
        unsigned count=0;
        long errorcode=0;
//        int lstateD=0;
//        int lstateIO=0;


    PPCODE:

        // Run the command
        // errorcode = AISample (&idnum,demo,&stateIO,updateIO,ledOn,numCh,lchannels,lgains,disableCal,&ov,voltages);

        errorcode = AOUpdate (&idnum,demo,trisD,trisIO,&stateD,&stateIO,updateDigital,resetCounter,&count,analogOut0,analogOut1);

        // Return the results to perl in a big array
        if(errorcode) {
          char errorString[51];
          GetErrorString ( errorcode, errorString );

LabJack.xs  view on Meta::CPAN

        {
            XSRETURN_UNDEF;
        }

        // Make sure there's a gain for every channel
        if(numgains<numchannels) {
            XSRETURN_UNDEF;
        }


    PPCODE:

        // Extract the channels we got from perl...
        for (n = 0; n <= numchannels; n++) {
                lchannels[n]= SvNV(*av_fetch((AV *)SvRV(channels), n, 0));
        }
        // Extract the gains we got from perl...
        for (n = 0; n <= numgains; n++) {
                lgains[n]= SvNV(*av_fetch((AV *)SvRV(gains), n, 0));
        }
        numCh=numchannels+1;

LabJack.xs  view on Meta::CPAN

EAnalogIn(idnum, demo, channel, gain)
        long  idnum
        long  demo
        long  channel
        long  gain
  INIT:
        long  overVoltage;
        float voltage;
        long  errcode;

  PPCODE:
        errcode = EAnalogIn(&idnum, demo, channel, gain, &overVoltage, &voltage);

        // Return the results to perl in a big array
        if(errcode) {                                   // RETVAL
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        }

LabJack.xs  view on Meta::CPAN

#// ###########################################################################
long
EAnalogOut(idnum, demo, analogOut0, analogOut1)
        long   idnum
        long   demo
        float  analogOut0
        float  analogOut1
  INIT:
        long errcode;

  PPCODE:
        errcode = EAnalogOut(&idnum, demo, analogOut0, analogOut1);

        // Return the results to perl in a big array
        if(errcode) {                                   // RETVAL
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        }

LabJack.xs  view on Meta::CPAN

long
ECount(idnum, demo, resetCounter)
        long   idnum
        long   demo
        long   resetCounter

  INIT:
        long   errcode;
        double count;
        double ms;
  PPCODE:
        errcode = ECount(&idnum, demo, resetCounter, &count, &ms);


        // Return the results to perl in a big array
        if(errcode) {                                   // RETVAL
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));

LabJack.xs  view on Meta::CPAN

long
EDigitalIn(idnum, channel, readD)
        long  idnum
        long  channel
        long  readD
  INIT:
        long *i, *j, *k;
        long  errcode;
        long  state;

  PPCODE:
        errcode = EDigitalIn(&idnum, 0, channel, readD, &state);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        }

LabJack.xs  view on Meta::CPAN

float
BitsToVolts(chnum, chgain, bits)
    long    chnum
    long    chgain
    long    bits

  INIT:
    long errcode;
    float volts;

  PPCODE:
    errcode = BitsToVolts(chnum, chgain, bits, &volts);

    // Return the results to perl in a big array
    if(errcode) {
        char errorString[51];
        GetErrorString ( errcode, errorString );
        XPUSHs(sv_2mortal(newSVpv(errorString,0)));
    } else {
        XPUSHs(sv_2mortal(newSVnv(errcode)));
    }

LabJack.xs  view on Meta::CPAN

int
VoltsToBits(chnum, chgain, volts)
    long   chnum
    long   chgain
    float  volts

 INIT:
    long errcode;

    long   bits;
  PPCODE:
    errcode = VoltsToBits(chnum, chgain, volts, &bits);

    // Return the results to perl in a big array
    if(errcode) {
        char errorString[51];
        GetErrorString ( errcode, errorString );
        XPUSHs(sv_2mortal(newSVpv(errorString,0)));
    } else {
        XPUSHs(sv_2mortal(newSVnv(errcode)));
    }

LabJack.xs  view on Meta::CPAN

    unsigned long  count

   INIT:
//    long *j, *k, x;
    long errcode;
//    int  nstateD;
//    unsigned long *mycount;

    // Check that they passed an array of channels, and count the elements

    PPCODE:
        // Run the command
        errcode = Counter(&idnum, demo, &stateD, &stateIO, resetCounter, enableSTB, &enableSTB);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));

LabJack.xs  view on Meta::CPAN

	long  *i, *j, *k, *l, *m;
	long   errcode;	
	long   outputD;

	i = &idnum;
	j = &trisD;
	k = &stateD;
	l = &stateIO;
	m = &outputD;

  PPCODE:
	errcode = DigitalIO(i, demo, j, trisIO, k, l, updateDigital, m);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        }

LabJack.xs  view on Meta::CPAN

//----------------------------------------------------------------------
void _stdcall GetErrorString	(long errorcode,
				 char *errorString);
=cut
#// ###########################################################################
void
GetErrorString(errn);
	long  errn
  INIT:
	char str[255];
  PPCODE:
	GetErrorString ( errn, str );
	XPUSHs(sv_2mortal(newSVpv(str,0)));

#// ###########################################################################
=head
//======================================================================
//GetWinVersion:  Uses a Windows API function to get the OS version.
//
//	Returns:	LabJack errorcodes or 0 for no error (I32).
//	Inputs:		none

LabJack.xs  view on Meta::CPAN

			    unsigned long *platformID,
			    unsigned long *servicePackMajor,
			    unsigned long *servicePackMinor);
=cut
#// ###########################################################################
long
GetWinVersion()
  INIT:
	unsigned long maj, min, build, platform, Packmaj, Packmin;
	long errcode;
  PPCODE:
	errcode = GetWinVersion(&maj, &min, &build, &platform, &Packmaj, &Packmin);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));

LabJack.xs  view on Meta::CPAN

	long msDelay
	long husDelay
	long controlCS
	long csLine
	long csState
	long configD
	long numWriteRead
	long data
  INIT:
	long i, errcode;
  PPCODE:
	errcode = Synch(&idnum, demo, mode, msDelay, husDelay, controlCS, csLine, csState, configD, numWriteRead, &data);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));

LabJack.xs  view on Meta::CPAN

=cut
#// ###########################################################################
long
ReadMem(idnum,address)
	long idnum
	long address
  INIT:
	long errcode;
	long d0, d1, d2, d3;

  PPCODE:
	errcode = ReadMem(&idnum, address, &d3, &d2, &d1, &d0);

        // Return the results to perl in a big array
        if(errcode) {
          char errorString[51];
          GetErrorString ( errcode, errorString );
          XPUSHs(sv_2mortal(newSVpv(errorString,0)));
          XPUSHs(sv_2mortal(newSVnv(errcode)));
        } else {
          XPUSHs(sv_2mortal(newSVnv(errcode)));

const-xs.inc  view on Meta::CPAN

	dTARGET;
#endif
	STRLEN		len;
        int		type;
	/* IV		iv;	Uncomment this if you need to return IVs */
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
    INPUT:
	SV *		sv;
        const char *	s = SvPV(sv, len);
    PPCODE:
	type = constant(aTHX_ s, len);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv = sv_2mortal(newSVpvf("%s is not a valid Device::LabJack macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(



( run in 0.702 second using v1.01-cache-2.11-cpan-5511b514fd6 )