EXTIO_HERMES_API bool __stdcall InitHW(char *name, char *model, int & extio_type)
{
	LOG_OPEN ("hermes");
	LOG (("opened in InitHW(): %d\n", GetInstanceNumber() )) ;

	static bool first = true;
	EXTIO_BASE_TYPE extio_type_;
	Ethernet::Device *pDev = 0;

	extio_type = extio_type_.value;

	if (first) {
		if ( GetInstanceNumber() == 1 ) {
			first = false;
			ExtioCallback = NULL;

			pGui = new Gui (EXTIO_DEFAULT_SAMPLE_RATE);
			if (pHermesEth == 0) {
				// placement new used, in order to share it among all instances
				pHermes = new (bufHR) ExtioHermesRadio < EXTIO_BASE_TYPE > (EXTIO_NS);

				if (pHermes != 0) {
					pGui->setRadio (pHermes);
					pHermes->setSampleRate (EXTIO_DEFAULT_SAMPLE_RATE);
				}
				Flow *pFlow = new Flow (pHermes);
				pHermesEth = new HermesEthernet (pGui, pFlow);
			}
			Ethernet::scan_devices ();
	
			pDev = pHermesEth->found();
			//rc = HermesInit (DEFAULT_SAMPLE_RATE, pHermes);
			//	TextModeEthernet *pEth = new TextModeEthernet (pFlow);
			if (pDev != 0) {
				LOG (("HARDWARE FOUND !\n"));
				pGui->HermesSetHwAddressGUI (pDev);
			} else {
				LOG (("HARDWARE NOT FOUND !\n"));
				pGui->HermesSetHwAddressGUI (0);
			}
		} else {
			pHermesEth = (HermesEthernet *) bufHE;
			pDev = pHermesEth->found();
			// point local hermes radio object pointer to shared buffer
			pHermes = (ExtioHermesRadio < EXTIO_BASE_TYPE > *) bufHR;
		}
	}
	if (pDev != 0) {
		LOG(("Radio in use: %s %s %1.1f\n", pDev->ip_address, pDev->mac_address, ((float)pDev->code_version)/10.0f ));
		strcpy(name, "HPSDR");
		strcpy(model, "Hermes");
	} else {
		strcpy(name, "HARDWARE NOT OPERATING !!!");
		strcpy(model, "N/A");
	}
	LOG (("INSTANCE: %d Name: [%s] Model: [%s]\n", GetInstanceNumber(), name, model));
	return (pDev != 0);
}
EXTIO_HERMES_API int __stdcall StartHW(long LOfrequency)
{
	LOG (("StartHW() called with LOfreq: %d\n", LOfrequency));

	if ( GetInstanceNumber() == 1 ) {
		
		if (!pHermesEth->found()) return 0;

		int act_sr;
		pHermes->getSampleRate(act_sr);
		LOG (("StartHW() before starting receive: SAMPLE RATE; %d #rx: %d\n", act_sr, pGui->getRecNumber()));

		pHermes->setNumberOfRx (pGui->getRecNumber());

		pHermesEth->startReceive (pHermesEth->found());

		pHermes->setFrequency ( LOfrequency ) ;

		// not anymore necessary, already done in InitHW
		// pGui->HermesSetHwAddressGUI ( pHermesEth->found() );
	}
	
	//
	// all instances, even the first one, have to prepare to receive data from the main one
	//
	rxIQ = new IdllComm < EXTIO_BASE_TYPE, EXTIO_NS > (GetInstanceNumber() - 1, &ExtioCallback);

	if (rxIQ) {
		rxIQ->startReceive ();
	} else {
		LOG (("FATAL: rxIQ not created !\n"));
	}

	if ( GetInstanceNumber() == 1 ) {
		// in first instance setup the internal data sender
		pHermes->setIdllComm (new IntraComm());
	} else {
		//
		// needed in order to set callback !!!
		//
		//pHermes->setSampleRate (EXTIO_DEFAULT_SAMPLE_RATE);
	}

	// signal to the main instance that we have to increase the number of active receivers
	//pHermes->setNumberOfRx ( GetInstanceNumber() );
	
	return EXTIO_NS; // # of samples returned by callback
}
Example #3
0
NTSTATUS CUsbDkFilterDevice::Create(PWDFDEVICE_INIT DevInit)
{
    CUsbDkFilterDeviceInit DeviceInit(DevInit);

    TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Entry");

    auto status = DeviceInit.Configure(GetInstanceNumber());
    if (!NT_SUCCESS(status))
    {
        TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device init");
        return status;
    }

    WDF_OBJECT_ATTRIBUTES attr;
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, USBDK_FILTER_DEVICE_EXTENSION);
    attr.EvtCleanupCallback = CUsbDkFilterDevice::ContextCleanup;

    status = CWdfDevice::Create(DeviceInit, attr);
    if (!NT_SUCCESS(status))
    {
        TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device");
        return status;
    }

    auto deviceContext = UsbDkFilterGetContext(m_Device);
    deviceContext->UsbDkFilter = this;

    return STATUS_SUCCESS;
}
EXTIO_HERMES_API void __stdcall CloseHW()
{
	LOG (("CloseHW() called\n"));
	if ( GetInstanceNumber() == 1 ) delete pGui;
	LOG_CLOSE;
	return;
}
EXTIO_HERMES_API long __stdcall GetHWLO()
{
	long LOfreq;
	pHermes->getFrequency (LOfreq, GetInstanceNumber() - 1 );
	LOG (("GetHWLO() called: return LOfreq: %d\n", LOfreq));

	return LOfreq;
}
EXTIO_HERMES_API void __stdcall HideGUI()
{
	LOG(("HideGUI() called\n"));
	
	if ( GetInstanceNumber() == 1 ) {
		pGui->Hide ();
	}
	return;
}
EXTIO_HERMES_API void __stdcall ShowGUI()
{
	LOG(("ShowGUI() called\n"));

	if ( GetInstanceNumber() == 1 ) {
		pGui->Show ();
	}
	return;
}
EXTIO_HERMES_API int __stdcall SetHWLO(long freq)
{
	LOG (("SetHWLO() called with freq: %d\n", freq));
	
	if (freq < 10000) return -10000;
	if (freq > 60000000) return 60000000;
	pHermes->setFrequency ( freq, GetInstanceNumber() - 1 ) ;
	return 0;
}
EXTIO_HERMES_API void __stdcall StopHW()
{
	LOG (("StopHW() called\n"));
	if ( GetInstanceNumber() == 1 ) {
		pGui->AppendMessage (_strdup("Hardware stopped by user request.\n"));
		pHermesEth->stopReceive ();
	}
	return;
}
Example #10
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : char const
//-----------------------------------------------------------------------------
const char *CPredictableId::Describe( void ) const
{
	static char desc[ 128 ];

	Q_snprintf( desc, sizeof( desc ), "pl(%i) cmd(%i) hash(%i) inst(%i) ack(%s)",
		GetPlayer(),
		GetCommandNumber(),
		GetHash(),
		GetInstanceNumber() ,
		GetAcknowledged() ? "true" : "false" );

	return desc;
}
Example #11
0
//-----------------------------------------------------------------------------
// Purpose: Determine if one id is == another, ignores Acknowledged state
// Input  : other - 
// Output : bool CPredictableId::operator
//-----------------------------------------------------------------------------
bool CPredictableId::operator ==( const CPredictableId& other ) const
{
	if ( this == &other )
		return true;

	if ( GetPlayer() != other.GetPlayer() )
		return false;
	if ( GetCommandNumber() != other.GetCommandNumber() )
		return false;
	if ( GetHash() != other.GetHash() )
		return false;
	if ( GetInstanceNumber() != other.GetInstanceNumber() )
		return false;
	return true;
}
Example #12
0
EXTIO_HERMES_API bool __stdcall OpenHW()
{
	LOG (("OpenHW() called: #%d\n", GetInstanceNumber()));
	if ( GetInstanceNumber() == 1 ) pGui->Show ();
	return true;
}