Exemplo n.º 1
0
void TICC1100::setup(int32_t userID, int32_t groupID)
{
	try
	{
		_out.printDebug("Debug: CC1100: Setting device permissions");
		setDevicePermission(userID, groupID);
		_out.printDebug("Debug: CC1100: Exporting GPIO");
		exportGPIO(1);
		if(gpioDefined(2)) exportGPIO(2);
		_out.printDebug("Debug: CC1100: Setting GPIO permissions");
		setGPIOPermission(1, userID, groupID, false);
		if(gpioDefined(2)) setGPIOPermission(2, userID, groupID, false);
		if(gpioDefined(2)) setGPIODirection(2, GPIODirection::OUT);
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemplo n.º 2
0
void TICC1100::initDevice()
{
	try
	{
		openDevice();
		if(!_fileDescriptor || _fileDescriptor->descriptor == -1) return;

		initChip();
		_out.printDebug("Debug: CC1100: Setting GPIO direction");
		setGPIODirection(1, GPIODirection::IN);
		_out.printDebug("Debug: CC1100: Setting GPIO edge");
		setGPIOEdge(1, GPIOEdge::BOTH);
		openGPIO(1, true);
		if(!_gpioDescriptors[1] || _gpioDescriptors[1]->descriptor == -1) throw(BaseLib::Exception("Couldn't listen to rf device, because the gpio pointer is not valid: " + _settings->device));
		if(gpioDefined(2)) //Enable high gain mode
		{
			openGPIO(2, false);
			if(!getGPIO(2)) setGPIO(2, true);
			closeGPIO(2);
		}
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemplo n.º 3
0
void COC::startListening()
{
	try
	{
		_socket = GD::bl->serialDeviceManager.get(_settings->device);
		if(!_socket) _socket = GD::bl->serialDeviceManager.create(_settings->device, 38400, O_RDWR | O_NOCTTY | O_NDELAY, true, 45);
		if(!_socket) return;
		_socket->addEventHandler(this);
		_socket->openDevice();
		if(gpioDefined(2))
		{
			openGPIO(2, false);
			if(!getGPIO(2)) setGPIO(2, true);
			closeGPIO(2);
		}
		if(gpioDefined(1))
		{
			openGPIO(1, false);
			if(!getGPIO(1))
			{
				setGPIO(1, false);
				std::this_thread::sleep_for(std::chrono::milliseconds(1000));
				setGPIO(1, true);
				std::this_thread::sleep_for(std::chrono::milliseconds(2000));
			}
			closeGPIO(1);
		}
		writeToDevice(stackPrefix + "X21\n" + stackPrefix + "Zr\n");
		std::this_thread::sleep_for(std::chrono::milliseconds(1000));
		IPhysicalInterface::startListening();
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemplo n.º 4
0
TICC1100::TICC1100(std::shared_ptr<BaseLib::Systems::PhysicalInterfaceSettings> settings) : IPhysicalInterface(GD::bl, GD::family->getFamily(), settings)
{
	try
	{
		_out.init(GD::bl);
		_out.setPrefix(GD::out.getPrefix() + "TI CC110X \"" + settings->id + "\": ");

		if(settings->listenThreadPriority == -1)
		{
			settings->listenThreadPriority = 45;
			settings->listenThreadPolicy = SCHED_FIFO;
		}
		if(settings->oscillatorFrequency < 0) settings->oscillatorFrequency = 26000000;
		if(settings->txPowerSetting < 0) settings->txPowerSetting = (gpioDefined(2)) ? 0x27 : 0xC0;
		_out.printDebug("Debug: PATABLE will be set to 0x" + BaseLib::HelperFunctions::getHexString(settings->txPowerSetting, 2));
		if(settings->interruptPin != 0 && settings->interruptPin != 2)
		{
			if(settings->interruptPin > 0) _out.printWarning("Warning: Setting for interruptPin for device CC1100 in max.conf is invalid.");
			settings->interruptPin = 2;
		}

		_transfer =  { (uint64_t)0, (uint64_t)0, (uint32_t)0, (uint32_t)4000000, (uint16_t)0, (uint8_t)8, (uint8_t)0, (uint32_t)0 };

		setConfig();
	}
    catch(const std::exception& ex)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}