コード例 #1
0
ファイル: termnetd.c プロジェクト: carlos-jenkins/termnetd
void handleNewSubOptData(int iVal, void *pArg1, void *pArg2)
{
   char buff[80];

   if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():New SubOpt = %d", iVal);
   strcpy(buff, "");
   switch (iVal)
   {
      case TELOPT_BAUDRATE:
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Setting baudrate to %s",
                                     (const char *)pArg1);
         setBaudStr(pDevc, pArg1);
         setModem(pDevc->mfd, pDevc);
         strcpy(buff, pDevc->baud);
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Baudrate set to %s",
                                     pDevc->baud);
         break;

      case TELOPT_PORTSET:
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Setting port settings to %s",
                                     (const char *)pArg1);
         setPortStr(pDevc, pArg1);
         setModem(pDevc->mfd, pDevc);
         strcpy(buff, pDevc->port);
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Port Settings set to %s",
                                     pDevc->port);
         break;

      case TELOPT_DEVICE:
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Have Device request for %s",
                                     (const char *)pArg1);
         strcpy(buff, pDevc->devc);
         if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Port Settings set to %s",
                                     pDevc->port);
         break;
   }
   if (strlen(buff) > 0)
   {
      if (dbg) syslog(LOG_DEBUG, "handleNewSubOptData():Sending %s back", buff);
      tnlSendSubOption(iVal, buff);
   }
}
コード例 #2
0
// Config reset ----------------------------------------------------------
void RadioSi446x::reset(void) 
{
  digitalWrite(VCXO_ENABLE_PIN,HIGH);
//  Serial.println("VCXO is enabled"); 
  delay(200);
  
  

  digitalWrite(RADIO_SDN_PIN, HIGH);  // active high shutdown = reset
  delay(200);
  digitalWrite(RADIO_SDN_PIN, LOW);   // booting
//  Serial.println("Radio is powered up"); 

  // Start talking to the Si446X radio chip

  const char PART_INFO_command[] = {0x01}; // Part Info
  SendCmdReceiveAnswer(1, 9, PART_INFO_command);
//  Serial.println("Part info was checked");

//divide VCXO_FREQ into its bytes; MSB first  
  unsigned int x3 = VCXO_FREQ / 0x1000000;
  unsigned int x2 = (VCXO_FREQ - x3 * 0x1000000) / 0x10000;
  unsigned int x1 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000) / 0x100;
  unsigned int x0 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000 - x1 * 0x100); 

//POWER_UP
  const char init_command[] = {0x02, 0x01, 0x01, x3, x2, x1, x0};// no patch, boot main app. img, FREQ_VCXO, return 1 byte
  SendCmdReceiveAnswer(7, 1 ,init_command); 

//  Serial.println("Radio booted"); 

  const char get_int_status_command[] = {0x20, 0x00, 0x00, 0x00}; //  Clear all pending interrupts and get the interrupt status back
  SendCmdReceiveAnswer(4, 9, get_int_status_command);


//  Serial.println("Radio ready");
 
  const char gpio_pin_cfg_command[] = {0x13, 0x02, 0x02, 0x02, 0x02, 0x08, 0x11, 0x00}; //  Set all GPIOs LOW; Link NIRQ to CTS; Link SDO to MISO; Max drive strength
  SendCmdReceiveAnswer(8, 8, gpio_pin_cfg_command);

//  Serial.println("LEDs should be switched off at this point");
  
  setFrequency(active_freq);
//  Serial.println("Frequency set");  
 
  setModem(); 
//  Serial.println("CW mode set");  
  
  tune_tx();
//  Serial.println("TX tune");  



}
コード例 #3
0
void CDVRPTRRepeaterApp::createThread()
{
	wxString callsign, gateway;
	DSTAR_MODE mode;
	ACK_TYPE ack;
	bool restriction, rpt1Validation;
	getCallsign(callsign, gateway, mode, ack, restriction, rpt1Validation);

	IDVRPTRRepeaterThread* thread = NULL;
	switch (mode) {
		case MODE_RXONLY:
			thread = new CDVRPTRRepeaterRXThread;
			break;
		case MODE_TXONLY:
			thread = new CDVRPTRRepeaterTXThread;
			break;
		case MODE_TXANDRX:
			thread = new CDVRPTRRepeaterTXRXThread;
			break;
		default:
			thread = new CDVRPTRRepeaterTRXThread;
			break;
	}

	thread->setCallsign(callsign, gateway, mode, ack, restriction, rpt1Validation);
	wxLogInfo(wxT("Callsign set to \"%s\", gateway set to \"%s\", mode: %d, ack: %d, restriction: %d, RPT1 validation: %d"), callsign.c_str(), gateway.c_str(), int(mode), int(ack), restriction, rpt1Validation);

	wxString gatewayAddress, localAddress;
	unsigned int gatewayPort, localPort;
	getNetwork(gatewayAddress, gatewayPort, localAddress, localPort);
	wxLogInfo(wxT("Gateway set to %s:%u, local set to %s:%u"), gatewayAddress.c_str(), gatewayPort, localAddress.c_str(), localPort);

	if (!gatewayAddress.IsEmpty()) {
		CRepeaterProtocolHandler* handler = new CRepeaterProtocolHandler(gatewayAddress, gatewayPort, localAddress, localPort);

		bool res = handler->open();
		if (!res)
			wxLogError(wxT("Cannot open the protocol handler"));
		else
			thread->setProtocolHandler(handler);
	}

	unsigned int timeout, ackTime;
	getTimes(timeout, ackTime);
	thread->setTimes(timeout, ackTime);
	wxLogInfo(wxT("Timeout set to %u secs, ack time set to %u ms"), timeout, ackTime);

	unsigned int beaconTime;
	wxString beaconText;
	bool beaconVoice;
	TEXT_LANG language;
	getBeacon(beaconTime, beaconText, beaconVoice, language);
	if (mode == MODE_GATEWAY)
		beaconTime = 0U;
	thread->setBeacon(beaconTime, beaconText, beaconVoice, language);
	wxLogInfo(wxT("Beacon set to %u mins, text set to \"%s\", voice set to %d, language set to %d"), beaconTime / 60U, beaconText.c_str(), int(beaconVoice), int(language));

	DVRPTR_VERSION modemVersion;
	CONNECTION_TYPE modemType;
	wxString modemUSBPort, modemAddress, modemUSBPath;
	bool rxInvert, txInvert, channel;
	unsigned int modemPort, modLevel, txDelay;
	getModem(modemVersion, modemType, modemUSBPort, modemAddress, modemPort, rxInvert, txInvert, channel, modLevel, txDelay);
	wxLogInfo(wxT("DV-RPTR modem: version: %d, type: %d, USB port: %s, address: %s:%u, RX invert: %d, TX invert: %d, channel: %s, mod level: %u%%, TX delay: %u ms"), int(modemVersion), int(modemType), modemUSBPort.c_str(), modemAddress.c_str(), modemPort, int(rxInvert), int(txInvert), channel ? wxT("B") : wxT("A"), modLevel, txDelay);

	if (modemType == CT_USB) {
		if (!modemUSBPort.IsEmpty()) {
			getModem(modemUSBPath);
			if (!modemUSBPath.IsEmpty())
				wxLogInfo(wxT("DV-RPTR modem: path: %s"), modemUSBPath.c_str());

			IDVRPTRController* controller = NULL;
			switch (modemVersion) {
				case DVRPTR_V1:
					controller = new CDVRPTRControllerV1(modemUSBPort, modemUSBPath, rxInvert, txInvert, channel, modLevel, txDelay);
					break;
				case DVRPTR_V2:
					controller = new CDVRPTRControllerV2(modemUSBPort, modemUSBPath, txInvert, modLevel, mode == MODE_DUPLEX || mode == MODE_TXANDRX, callsign);
					break;
				default:
					wxLogError(wxT("Unknown DV-RPTR modem version - %d"), int(modemVersion));
					break;
			}

			if (controller != NULL) {
				bool res = controller->open();
				if (!res) {
					wxLogError(wxT("Cannot open the DV-RPTR modem"));
				} else {
					thread->setModem(controller);
					setModem(controller->getPath());
				}
			}
		}
	} else if (modemType == CT_NETWORK) {
		if (!modemAddress.IsEmpty()) {
			CDVRPTRControllerV2* controller = new CDVRPTRControllerV2(modemAddress, modemPort, txInvert, modLevel, mode == MODE_DUPLEX || mode == MODE_TXANDRX, callsign);
			bool res = controller->open();
			if (!res)
				wxLogError(wxT("Cannot open the DV-RPTR modem"));
			else
				thread->setModem(controller);
		}
	}

	wxString controllerType;
	unsigned int activeHangTime;
	getController(controllerType, activeHangTime);
	wxLogInfo(wxT("Controller set to %s, active hang time: %u ms"), controllerType.c_str(), activeHangTime);

	CExternalController* controller = NULL;

	wxString port;
	if (controllerType.StartsWith(wxT("Velleman K8055 - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CK8055Controller(num), false, false);
	} else if (controllerType.IsSameAs(wxT("Raspberry Pi"))) {
		controller = new CExternalController(new CRaspberryController, false, false);
	} else {
		controller = new CExternalController(new CDummyController, false, false);
	}

	bool res = controller->open();
	if (!res)
		wxLogError(wxT("Cannot open the hardware interface - %s"), controllerType.c_str());
	else
		thread->setController(controller, activeHangTime);

	bool out1, out2, out3, out4;
	getOutputs(out1, out2, out3, out4);
	thread->setOutputs(out1, out2, out3, out4);
	m_frame->setOutputs(out1, out2, out3, out4);
	wxLogInfo(wxT("Output 1 = %d, output 2 = %d, output 3 = %d, output 4 = %d"), out1, out2, out3, out4);

	bool enabled;
	wxString rpt1Callsign, rpt2Callsign;
	wxString shutdown, startup;
	wxString status1, status2, status3, status4, status5;
	wxString command1, command1Line, command2, command2Line;
	wxString command3, command3Line, command4, command4Line;
	wxString output1, output2, output3, output4;
	getControl(enabled, rpt1Callsign, rpt2Callsign, shutdown, startup, status1, status2, status3, status4, status5, command1, command1Line, command2, command2Line, command3, command3Line, command4, command4Line, output1, output2, output3, output4);
	thread->setControl(enabled, rpt1Callsign, rpt2Callsign, shutdown, startup, status1, status2, status3, status4, status5, command1, command1Line, command2, command2Line, command3, command3Line, command4, command4Line, output1, output2, output3, output4);
	wxLogInfo(wxT("Control: enabled: %d, RPT1: %s, RPT2: %s, shutdown: %s, startup: %s, status1: %s, status2: %s, status3: %s, status4: %s, status5: %s, command1: %s = %s, command2: %s = %s, command3: %s = %s, command4: %s = %s, output1: %s, output2: %s, output3: %s, output4: %s"), enabled, rpt1Callsign.c_str(), rpt2Callsign.c_str(), shutdown.c_str(), startup.c_str(), status1.c_str(), status2.c_str(), status3.c_str(), status4.c_str(), status5.c_str(), command1.c_str(), command1Line.c_str(), command2.c_str(), command2Line.c_str(), command3.c_str(), command3Line.c_str(), command4.c_str(), command4Line.c_str(), output1.c_str(), output2.c_str(), output3.c_str(), output4.c_str());

	bool logging;
	getLogging(logging);
	thread->setLogging(logging, m_audioDir);
	m_frame->setLogging(logging);
	wxLogInfo(wxT("Frame logging set to %d, in %s"), int(logging), m_audioDir.c_str());

	wxFileName wlFilename(wxFileName::GetHomeDir(), WHITELIST_FILE_NAME);
	bool exists = wlFilename.FileExists();
	if (exists) {
		CCallsignList* list = new CCallsignList(wlFilename.GetFullPath());
		bool res = list->load();
		if (!res) {
			wxLogError(wxT("Unable to open white list file - %s"), wlFilename.GetFullPath().c_str());
			delete list;
		} else {
			wxLogInfo(wxT("%u callsigns loaded into the white list"), list->getCount());
			thread->setWhiteList(list);
		}
	}

	wxFileName blFilename(wxFileName::GetHomeDir(), BLACKLIST_FILE_NAME);
	exists = blFilename.FileExists();
	if (exists) {
		CCallsignList* list = new CCallsignList(blFilename.GetFullPath());
		bool res = list->load();
		if (!res) {
			wxLogError(wxT("Unable to open black list file - %s"), blFilename.GetFullPath().c_str());
			delete list;
		} else {
			wxLogInfo(wxT("%u callsigns loaded into the black list"), list->getCount());
			thread->setBlackList(list);
		}
	}

	// Convert the worker class into a thread
	m_thread = new CDVRPTRRepeaterThreadHelper(thread);
	m_thread->start();
}
コード例 #4
0
ファイル: radio_si446x.cpp プロジェクト: kd2eat/UrsusMinimus1
// Config reset ----------------------------------------------------------
void RadioSi446x::reset(void) 
{
  digitalWrite(VCXO_ENABLE_PIN,HIGH);
//  Serial.println("VCXO is enabled"); 
  delay(200);
  
  

  digitalWrite(RADIO_SDN_PIN, HIGH);  // active high shutdown = reset
  delay(200);
  digitalWrite(RADIO_SDN_PIN, LOW);   // booting
//  Serial.println("Radio is powered up"); 

  // Start talking to the Si446X radio chip

  const char PART_INFO_command[] = {0x01}; // Part Info
  SendCmdReceiveAnswer(1, 9, PART_INFO_command);
//  Serial.println("Part info was checked");

//W2CXM - Suggested that we add this delay by aadmson
  delay(15);

//divide VCXO_FREQ into its bytes; MSB first  
  unsigned int x3 = VCXO_FREQ / 0x1000000;
  unsigned int x2 = (VCXO_FREQ - x3 * 0x1000000) / 0x10000;
  unsigned int x1 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000) / 0x100;
  unsigned int x0 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000 - x1 * 0x100); 

//POWER_UP
  const char init_command[] = {0x02, 0x01, 0x01, x3, x2, x1, x0};// no patch, boot main app. img, FREQ_VCXO, return 1 byte
  SendCmdReceiveAnswer(7, 1 ,init_command); 

//  Serial.println("Radio booted"); 

  const char get_int_status_command[] = {0x20, 0x00, 0x00, 0x00}; //  Clear all pending interrupts and get the interrupt status back
  SendCmdReceiveAnswer(4, 9, get_int_status_command);


//  Serial.println("Radio ready");
 
  const char gpio_pin_cfg_command[] = {0x13, 0x02, 0x02, 0x02, 0x02, 0x08, 0x0b, 0x00}; //  Set all GPIOs LOW; Link NIRQ to CTS; Link SDO to MISO; Max drive strength
  SendCmdReceiveAnswer(8, 8, gpio_pin_cfg_command);

// W2CXM - Added two more initializations per aadamson
  const char set_global_config1[] = {0x11, 0x00, 0x01, 0x03, 0x60};
  SendCmdReceiveAnswer(5, 1, set_global_config1);
  // cliPrint("Setting special global Config 1 changes (see WDS)\n");

  const char set_global_xo_tune_command[] = {0x11, 0x00, 0x01, 0x00, 0x00};
  SendCmdReceiveAnswer(5, 1, set_global_xo_tune_command);
  // cliPrint("Setting no additional capacitance on VXCO\n");
// W2CXM ^^^^^^^^^

//  Serial.println("LEDs should be switched off at this point");
  
  setFrequency(active_freq);
//  Serial.println("Frequency set");  
 
  setModem(); 
//  Serial.println("CW mode set");  
  
  tune_tx();
//  Serial.println("TX tune");  



}