Beispiel #1
0
    */ 	void WaspRFID::ON(uint8_t socket)
	{	
	  delay(1);
      pinMode(MUX_PW, OUTPUT);     
      pinMode(MUX_USB_XBEE, OUTPUT);
      digitalWrite(MUX_PW, HIGH);  
      digitalWrite(MUX_USB_XBEE, LOW);
      delay(1); 
	  
			if (socket == 1) {			
				//USB.begin();
				beginSerial(RFID_RATE, 1);
			    pinMode(DIGITAL6, OUTPUT);
				digitalWrite(DIGITAL6, HIGH);
				Utils.setMuxSocket1();
				_uart = 1;
			
			} else {
			
				beginSerial(RFID_RATE, 0);
				pinMode(XBEE_PW,OUTPUT);
				digitalWrite(XBEE_PW,HIGH);
				_uart = 0;
			}

			delay(100);
			getFirmware();
			configureSAM();
	}
Beispiel #2
0
void setup()
{
	//Start serial port 115200 bps:
	Serial.begin(115200);
	delay(100);
	fprintf(stderr,"RFID/NFC @ 13.56 MHz module started\n");
	delay(1000);
	//!It is needed to launch a simple command to sycnchronize
	getFirmware();
	configureSAM();
}
bool CDVAPController::open()
{
	bool res = m_serial.open();
	if (!res)
		return false;

	res = getName();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = getFirmware();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = getSerial();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = setModulation();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = setMode();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = setSquelch();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = setPower();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = setFrequency();
	if (!res) {
		m_serial.close();
		return false;
	}

	res = start();
	if (!res) {
		m_serial.close();
		return false;
	}

	Create();
	SetPriority(100U);
	Run();

	return true;
}
Beispiel #4
0
/** Constructor for mythen driver; most parameters are simply passed to ADDriver::ADDriver.
  * After calling the base class constructor this method creates a thread to collect the detector data, 
  * and sets reasonable default values for the parameters defined in this class, asynNDArrayDriver, and ADDriver.
  * \param[in] portName The name of the asyn port driver to be created.
  * \param[in] IPPortName The asyn network port connection to the Mythen
  * \param[in] maxBuffers The maximum number of NDArray buffers that the NDArrayPool for this driver is 
  *            allowed to allocate. Set this to -1 to allow an unlimited number of buffers.
  * \param[in] maxMemory The maximum amount of memory that the NDArrayPool for this driver is 
  *            allowed to allocate. Set this to -1 to allow an unlimited amount of memory.
  * \param[in] priority The thread priority for the asyn port driver thread if ASYN_CANBLOCK is set in asynFlags.
  * \param[in] stackSize The stack size for the asyn port driver thread if ASYN_CANBLOCK is set in asynFlags.
  */
mythen::mythen(const char *portName, const char *IPPortName,
                                int maxBuffers, size_t maxMemory,
                                int priority, int stackSize)

               : ADDriver(portName, 1, NUM_SD_PARAMS, maxBuffers, maxMemory,
               0, 0,             /* No interfaces beyond those set in ADDriver.cpp */
               ASYN_CANBLOCK | ASYN_MULTIDEVICE, 1, /* ASYN_CANBLOCK=1, ASYN_MULTIDEVICE=1, autoConnect=1 */
               priority, stackSize)
         // , pDetector(NULL)

{
    int status = asynSuccess;
    // NDArray *pData; 
    const char *functionName = "mythen";

    IPPortName_ = epicsStrDup(IPPortName);
    
    isBigEndian_ = EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG;

    /* Create the epicsEvents for signaling to the mythen task when acquisition starts and stops */
    this->startEventId_ = epicsEventCreate(epicsEventEmpty);
    if (!this->startEventId_) {
        printf("%s:%s epicsEventCreate failure for start event\n", 
            driverName, functionName);
        return;
    }

    // Connect to the server
    status = pasynOctetSyncIO->connect(IPPortName, 0, &pasynUserMeter_, NULL);
    if (status) {
        printf("%s:%s: error calling pasynOctetSyncIO->connect, status=%d, error=%s\n",
               driverName, functionName, status, pasynUserMeter_->errorMessage);
        return;
    }

    createParam(SDSettingString,          asynParamInt32,   &SDSetting); 
    createParam(SDDelayTimeString,        asynParamFloat64, &SDDelayTime); 
    createParam(SDThresholdString,        asynParamFloat64, &SDThreshold); 
    createParam(SDEnergyString,           asynParamFloat64, &SDEnergy); 
    createParam(SDUseFlatFieldString,     asynParamInt32,   &SDUseFlatField); 
    createParam(SDUseCountRateString,     asynParamInt32,   &SDUseCountRate); 
    createParam(SDUseBadChanIntrplString, asynParamInt32,   &SDUseBadChanIntrpl);
    createParam(SDBitDepthString,         asynParamInt32,   &SDBitDepth); 
    createParam(SDUseGatesString,         asynParamInt32,   &SDUseGates); 
    createParam(SDNumGatesString,         asynParamInt32,   &SDNumGates); 
    createParam(SDNumFramesString,        asynParamInt32,   &SDNumFrames); 
    createParam(SDTriggerString,          asynParamInt32,   &SDTrigger);
    createParam(SDResetString,            asynParamInt32,   &SDReset);
    createParam(SDTauString,              asynParamFloat64, &SDTau); 
    createParam(SDNModulesString,         asynParamInt32,   &SDNModules); 
    createParam(SDFirmwareVersionString,  asynParamOctet,   &SDFirmwareVersion);
    createParam(SDReadModeString,         asynParamInt32,   &SDReadMode);

    status =  setStringParam (ADManufacturer, "Dectris");
    status |= setStringParam (ADModel,        "Mythen");
    
    status |= getFirmware();
    status |= setStringParam (SDFirmwareVersion, firmwareVersion_);
    
    int sensorSizeX = MAX_DIMS;
    int  sensorSizeY = 1;
    status |= setIntegerParam(ADMaxSizeX, sensorSizeX);
    status |= setIntegerParam(ADMaxSizeY, sensorSizeY);

    int minX,  minY, sizeX, sizeY; 
    minX = 1; minY = 1; sizeX = MAX_DIMS; sizeY = 1; 
    status |= setIntegerParam(ADMinX,  minX);
    status |= setIntegerParam(ADMinY,  minY);
    status |= setIntegerParam(ADSizeX, sizeX);
    status |= setIntegerParam(ADSizeY, sizeY);

    status |= setIntegerParam(NDArraySize, 0);
    status |= setIntegerParam(NDDataType,  NDInt32);

    status |= setIntegerParam(ADImageMode, ADImageSingle);

    /* NOTE: these char type waveform record could not be initialized in iocInit 
     * Instead use autosave to restore their values.
     * It is left here only for references.
     * */
    status |= setIntegerParam(ADStatus, getStatus());
    
    //Get Firmware version
    
    
    // Read the current settings from the device.  This will set parameters in the parameter library.
    getSettings();

    int aux;
    //get nmodules and check for errors
    strcpy(outString_, "-get nmodules");
    status |= writeReadMeter();
    aux = stringToInt32(this->inString_);
    if (aux < 0) {
      asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
        "%s:%s: error, outString=%s, inString=%s\n",
        driverName, functionName, outString_, inString_);
      return;
    }
    this->nmodules=aux;
    status |= setIntegerParam(SDNModules, aux);
    detArray_ = (epicsInt32*) calloc(this->nmodules*1280, sizeof(epicsInt32));
    tmpArray_ = (epicsUInt32*) calloc(this->nmodules*1280, sizeof(epicsInt32));

    callParamCallbacks();

    if (status) {
        printf("%s: unable to read camera parameters\n", functionName);
        return;
    }

    /* Register the shutdown function for epicsAtExit */
    // epicsAtExit(c_shutdown, (void*)this); 

    /* Create the thread that runs acquisition */
    status = (epicsThreadCreate("acquisitionTask",
                                epicsThreadPriorityMedium,
                                epicsThreadGetStackSize(epicsThreadStackMedium),
                                (EPICSTHREADFUNC)acquisitionTaskC,
                                this) == NULL);

    /* Create the thread that polls status */
    //    status = (epicsThreadCreate("pollTask",
    //                                epicsThreadPriorityMedium,
    //                                epicsThreadGetStackSize(epicsThreadStackMedium),
    //                                (EPICSTHREADFUNC)pollTaskC,
    //                                this) == NULL);
}