Example #1
0
void cNPC::save()
{
	if ( changed_ )
	{
		QSqlQuery * q;
		if ( isPersistent )
			q = cNPC::getUpdateQuery();
		else
			q = cNPC::getInsertQuery();

		q->addBindValue( serial() );
		q->addBindValue( summonTime_ ? summonTime_ - Server::instance()->time() : 0 );
		q->addBindValue( additionalFlags_ );
		q->addBindValue( owner_ ? owner_->serial() : INVALID_SERIAL );
		q->addBindValue( stablemasterSerial_ );
		q->addBindValue( aiid_ );
		q->addBindValue( ( quint8 ) wanderType() );
		q->addBindValue( wanderX1() );
		q->addBindValue( wanderX2() );
		q->addBindValue( wanderY1() );
		q->addBindValue( wanderY2() );
		q->addBindValue( wanderRadius() );
		if ( isPersistent )
			q->addBindValue( serial() );

		if ( !q->exec() )
			Console::instance()->log( LOG_ERROR, tr("Error saving NPC id %1, with server error: %2").arg( serial() ).arg( q->lastError().text() ) );
	}

	cBaseChar::save();
}
Example #2
0
void TellStick::aquireTellStick() {
	char *tempSerial = new char[serial().size()+1];
#ifdef _WINDOWS
	strcpy_s(tempSerial, serial().size()+1, serial().toLocal8Bit());
#else
	strcpy(tempSerial, serial().toLocal8Bit());
	int pid = 0x0C30;
	if (type() == 2) {
		pid = 0x0C31;
	}
	FT_SetVIDPID(0x1781, pid);
#endif
	FT_STATUS ftStatus = FT_OpenEx(tempSerial, FT_OPEN_BY_SERIAL_NUMBER, &d->ftHandle);
	delete tempSerial;
	if (ftStatus != FT_OK) {
		return;
	}
	//open = true;

	if (type() == 2) {
		FT_SetBaudRate(d->ftHandle, 115200);
	} else {
		FT_SetBaudRate(d->ftHandle, 9600);
	}
	FT_SetFlowControl(d->ftHandle, FT_FLOW_NONE, 0, 0);
	FT_SetTimeouts(d->ftHandle,1000,0);

	setUpgradeStep(2);
	QTimer::singleShot(0, this, SLOT(enterBootloader()));
}
Example #3
0
void cNPC::save()
{
	if ( changed_ )
	{
		initSave;
		setTable( "npcs" );

		addField( "serial", serial() );
		addField( "summontime", summonTime_ ? summonTime_ - Server::instance()->time() : 0 );
		addField( "additionalflags", additionalFlags_ );
		addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL );
		addField( "stablemaster", stablemasterSerial_ );
		addStrField( "ai", aiid_ );
		addField( "wandertype", ( Q_UINT8 ) wanderType() );
		addField( "wanderx1", wanderX1() );
		addField( "wanderx2", wanderX2() );
		addField( "wandery1", wanderY1() );
		addField( "wandery2", wanderY2() );
		addField( "wanderradius", wanderRadius() );

		addCondition( "serial", serial() );
		saveFields;
	}

	cBaseChar::save();
}
Example #4
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // This is a hack to prevent some OS to pause executing the program when the window is not visible
    a.setQuitOnLastWindowClosed(false);

    // The settings window allows the user to control the program
    SettingsWindow window;
    window.show();

    // The Screen Analyzer class outputs a single color based on the image displayed on the screen
    ScreenAnalyzer analyzer;

    // LEDOS Talker communicates color from the Screen Analyzer to LEDOS
    LEDOSTalker talker;

    // Whenever the user "starts" the program, start the analysis thread
    QObject::connect( &window, SIGNAL(start()), &analyzer, SLOT(start()) );

    // And stop it when the user doesn't need it anymore
    QObject::connect( &window, SIGNAL(stop()), &analyzer, SLOT(stop()) );

    // Close the program when the window is closed
    QObject::connect( &window, SIGNAL(quit()), &a, SLOT(quit()) );

    // When a serial port is selected, update it in the LEDOS Talker instance
    QObject::connect( &window, SIGNAL(serial(QString)), &talker, SLOT(serial(QString)) );

    // Every time a color is ready to be sent pass it to the LEDOS Talker
    QObject::connect( &analyzer, SIGNAL(color(QColor)), &talker, SLOT(color(QColor)) );

    return a.exec();
}
Example #5
0
void cPlayer::save()
{
	if ( changed_ )
	{
		QSqlQuery * q;
		if ( isPersistent )
			q = cPlayer::getUpdateQuery();
		else
			q = cPlayer::getInsertQuery();

		q->addBindValue( serial() );

		if ( account_ )
		{
			q->addBindValue( account_->login() );
		}
		else
		{
			q->addBindValue( QString() );
		}

		q->addBindValue( additionalFlags_ );
		q->addBindValue( visualRange_ );
		q->addBindValue( profile_ );
		q->addBindValue( fixedLightLevel_ );
		q->addBindValue( strengthLock_ );
		q->addBindValue( dexterityLock_ );
		q->addBindValue( intelligenceLock_ );
		q->addBindValue( maxControlSlots_ );
		if ( isPersistent )
			q->addBindValue( serial() );
		q->exec();
	}
	cBaseChar::save();
}
Example #6
0
void cPlayer::save()
{
	if ( changed_ )
	{
		initSave;
		setTable( "players" );

		addField( "serial", serial() );

		if ( account_ )
		{
			addStrField( "account", account_->login() );
		}
		else
		{
			addStrField( "account", QString::null );
		}

		addField( "additionalflags", additionalFlags_ );
		addField( "visualrange", visualRange_ );
		addStrField( "profile", profile_ );
		addField( "fixedlight", fixedLightLevel_ );
		addField( "strlock", strengthLock_ );
		addField( "dexlock", dexterityLock_ );
		addField( "intlock", intelligenceLock_ );
		addField( "maxcontrolslots", maxControlSlots_ );

		addCondition( "serial", serial() );
		saveFields;
	}
	cBaseChar::save();
}
Example #7
0
void cNPC::save()
{
	if ( changed_ )
	{
		initSave;
		setTable( "npcs" );

		addField( "serial", serial() );
		addField( "mindamage", minDamage_);
		addField( "maxdamage", maxDamage_);
		addField( "tamingminskill", tamingMinSkill_);
		addField( "summontime", summonTime_ ? summonTime_ - uiCurrentTime : 0 );
		addField( "additionalflags", additionalFlags_ );
		addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL );
		addStrField( "carve", carve_);
		addStrField( "spawnregion", spawnregion_);
		addField( "stablemaster", stablemasterSerial_ );
		addStrField( "lootlist", lootList_);
		addStrField( "ai", aiid_ );
		addField( "wandertype", (UINT8)wanderType() );
		addField( "wanderx1", wanderX1() );
		addField( "wanderx2", wanderX2() );
		addField( "wandery1", wanderY1() );
		addField( "wandery2", wanderY2() );
		addField( "wanderradius", wanderRadius() );
		addField( "fleeat", criticalHealth() );
		addField( "spellslow", spellsLow_ );
		addField( "spellshigh", spellsHigh_ );
		addField( "controlslots", controlSlots_ );

		addCondition( "serial", serial() );
		saveFields;
	}
	cBaseChar::save();
}
Example #8
0
/*
 * serialBit (inherited from IStream)
 */
void CMemStream::serialBit(bool &bit)
{
	uint8 u;
	if ( isReading() )
	{
		serial( u );
		bit = (u!=0);
	}
	else
	{
		u = (uint8)bit;
		serial( u );
	}
}
Example #9
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void EdgeGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable)
{
  m_ProgressCounter = 0;
  int64_t numEdges = getNumberOfEdges();

  if (observable)
  {
    connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)),
            observable, SLOT(broadcastPipelineMessage(const PipelineMessage&)));
  }

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  tbb::task_scheduler_init init;
  bool doParallel = true;
#endif

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  if (doParallel == true)
  {
    tbb::parallel_for(tbb::blocked_range<int64_t>(0, numEdges),
                      FindEdgeDerivativesImpl(this, field, derivatives), tbb::auto_partitioner());
  }
  else
#endif
  {
    FindEdgeDerivativesImpl serial(this, field, derivatives);
    serial.compute(0, numEdges);
  }
}
Example #10
0
asmlinkage int solaris_sysinfo(int cmd, u32 buf, s32 count)
{
	char *p, *q, *r;
	char buffer[256];
	int len;
	
	/* Again, we cheat :)) */
	switch (cmd) {
	case SI_SYSNAME: r = "SunOS"; break;
	case SI_HOSTNAME:
		r = buffer + 256;
		for (p = system_utsname.nodename, q = buffer; 
		     q < r && *p && *p != '.'; *q++ = *p++);
		*q = 0;
		r = buffer;
		break;
	case SI_RELEASE: r = "5.6"; break;
	case SI_MACHINE: r = machine(); break;
	case SI_ARCHITECTURE: r = "sparc"; break;
	case SI_HW_PROVIDER: r = "Sun_Microsystems"; break;
	case SI_HW_SERIAL: r = serial(buffer); break;
	case SI_PLATFORM: r = platform(buffer); break;
	case SI_SRPC_DOMAIN: r = ""; break;
	case SI_VERSION: r = "Generic"; break;
	default: return -EINVAL;
	}
	len = strlen(r) + 1;
	if (count < len) {
		copy_to_user_ret((char *)A(buf), r, count - 1, -EFAULT);
		__put_user_ret(0, (char *)A(buf) + count - 1, -EFAULT);
	} else
		copy_to_user_ret((char *)A(buf), r, len, -EFAULT);
	return len;
}
Example #11
0
PSMoveAPI::PSMoveAPI(EventReceiver *receiver, void *user_data)
    : receiver(receiver)
    , user_data(user_data)
    , controllers()
{
    std::map<std::string, std::vector<PSMove *>> moves;

    int n = psmove_count_connected();
    for (int i=0; i<n; i++) {
        PSMove *move = psmove_connect_by_id(i);

        char *tmp = psmove_get_serial(move);
        std::string serial(tmp);
        free(tmp);

        moves[serial].emplace_back(move);
    }

    int i = 0;
    for (auto &kv: moves) {
        if (kv.second.size() == 2) {
            // Have two handles for this controller (USB + Bluetooth)
            controllers.emplace_back(new ControllerGlue(i++, kv.first, kv.second[0], kv.second[1]));
        } else if (kv.second.size() == 1) {
            // Have only one handle for this controller
            controllers.emplace_back(new ControllerGlue(i++, kv.first, kv.second[0], nullptr));
        } else {
            // FATAL
        }
    }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FindModulusMismatch::execute()
{
  setErrorCondition(0);
  dataCheckVoxel();
  if(getErrorCondition() < 0) { return; }
  dataCheckSurfaceMesh();
  if(getErrorCondition() < 0) { return; }

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  tbb::task_scheduler_init init;
  bool doParallel = true;
#endif

  int64_t numTriangles = m_SurfaceMeshFaceLabelsPtr.lock()->getNumberOfTuples();


#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  if (doParallel == true)
  {
    tbb::parallel_for(tbb::blocked_range<size_t>(0, numTriangles),
                      FindModulusMismatchImpl(m_SurfaceMeshFaceLabels, m_Moduli, m_SurfaceMeshDeltaModulus), tbb::auto_partitioner());
  }
  else
#endif
  {
    FindModulusMismatchImpl serial(m_SurfaceMeshFaceLabels, m_Moduli, m_SurfaceMeshDeltaModulus);
    serial.generate(0, numTriangles);
  }

  notifyStatusMessage(getHumanLabel(), "Completed");
}
Example #13
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TriangleNormalFilter::execute()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(getSurfaceMeshTriangleNormalsArrayPath().getDataContainerName());

  TriangleGeom::Pointer triangleGeom = sm->getGeometryAs<TriangleGeom>();

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  bool doParallel = true;
#endif

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  if (doParallel == true)
  {
    tbb::parallel_for(tbb::blocked_range<size_t>(0, triangleGeom->getNumberOfTris()),
                      CalculateNormalsImpl(triangleGeom->getVertices(), triangleGeom->getTriangles(), m_SurfaceMeshTriangleNormals), tbb::auto_partitioner());
  }
  else
#endif
  {
    CalculateNormalsImpl serial(triangleGeom->getVertices(), triangleGeom->getTriangles(), m_SurfaceMeshTriangleNormals);
    serial.generate(0, triangleGeom->getNumberOfTris());
  }

  /* Let the GUI know we are done with this filter */
  notifyStatusMessage(getHumanLabel(), "Complete");
}
Example #14
0
TEST(SubscriptionTests, decode_invalidLength_throwException)
{
	SubscriptionManager subscriptionManager;
	String serial("ABC");

	EXPECT_THROW(subscriptionManager.decode(serial), XSubscription);
}
Example #15
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ScaleVolume::updateSurfaceMesh()
{
  setErrorCondition(0);

#ifdef DREAM3D_USE_PARALLEL_ALGORITHMS
  tbb::task_scheduler_init init;
  bool doParallel = true;
#endif

  IGeometry2D::Pointer geom2D = getDataContainerArray()->getDataContainer(getSurfaceDataContainerName())->getGeometryAs<IGeometry2D>();
  float* nodes = geom2D->getVertexPointer(0);

  // First get the min/max coords.

  float min[3] = { std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max() };
  float max[3] = { std::numeric_limits<float>::min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::min() };

  int64_t count = geom2D->getNumberOfVertices();
  for (int64_t i = 0; i < count; i++)
  {
    if (nodes[3 * i] > max[0])
    {
      max[0] = nodes[3 * i];
    }
    if (nodes[3 * i + 1] > max[1])
    {
      max[1] = nodes[3 * i + 1];
    }
    if (nodes[3 * i + 2] > max[2])
    {
      max[2] = nodes[3 * i + 2];
    }

    if (nodes[3 * i] < min[0])
    {
      min[0] = nodes[3 * i];
    }
    if (nodes[3 * i + 1] < min[1])
    {
      min[1] = nodes[3 * i + 1];
    }
    if (nodes[3 * i + 2] < min[2])
    {
      min[2] = nodes[3 * i + 2];
    }
  }

#ifdef DREAM3D_USE_PARALLEL_ALGORITHMS
  if (doParallel == true)
  {
    tbb::parallel_for(tbb::blocked_range<size_t>(0, count),
                      UpdateVerticesImpl(nodes, min, m_ScaleFactor), tbb::auto_partitioner());
  }
  else
#endif
  {
    UpdateVerticesImpl serial(nodes, min, m_ScaleFactor);
    serial.generate(0, count);
  }
}
Example #16
0
void dataMessageRecieved(const telebot::Coord msg) {
     
	std::ostringstream ID;
	std::ostringstream GOAL;	
	std::ostringstream SPD;
	

        for(int i = 0; i < 12; i++){
	ID << static_cast<int>(msg.ID[i]);
	GOAL << static_cast<int>(msg.GOAL_POS[i]);
	SPD << static_cast<int>(msg.SPEED[i]);
	
	
	std::string data = std::string() + '<' + ID.str() + ' ' + GOAL.str() + ' ' + SPD.str() + '>';	
	ROS_INFO_STREAM(data);
        SimpleSerial serial("/dev/ttyUSB0",57600);

        serial.writeString(data);
	ID.str("");
	GOAL.str("");
	SPD.str("");

	ID.clear();
	GOAL.str();
	SPD.str();
	sleepr(50);
	}
	
}
bool CDVAPController::getSerial()
{
	unsigned int count = 0U;
	unsigned int length;
	RESP_TYPE resp;
	do {
		int ret = m_serial.write(DVAP_REQ_SERIAL, DVAP_REQ_SERIAL_LEN);
		if (ret != int(DVAP_REQ_SERIAL_LEN)) {
			m_serial.close();
			return false;
		}

		::wxMilliSleep(50UL);

		resp = getResponse(m_buffer, length);

		if (resp != RT_SERIAL) {
			count++;
			if (count >= MAX_RESPONSES) {
				wxLogError(wxT("The DVAP is not responding with its serial number"));
				return false;
			}
		}
	} while (resp != RT_SERIAL);

	wxString serial((char*)(m_buffer + 4U), wxConvLocal, length - 5U);
	wxLogInfo(wxT("DVAP Serial number: %s"), serial.c_str());

	return true;
}
Example #18
0
TEST(SubscriptionTests, decode_unrecognizedDigit_throwException)
{
	SubscriptionManager subscriptionManager;
	String serial("MOCK");

	EXPECT_THROW(subscriptionManager.decode(serial), XSubscription);
}
Example #19
0
void serialSingle(BitStream& bs, bool write, double& data)
{
	float single;
	if (write) single = float(data);
	serial(bs, write, single);
	if (!write) data = single;
}
Example #20
0
//++ ------------------------------------------------------------------------------------
// Details: This function forms a small management routine, to handle the thread's running.
// Type:    Method.
// Args:    None.
// Return:  None.
// Throws:  None.
//--
void
CMIUtilThreadActiveObjBase::ThreadManage()
{
    bool bAlive = true;

    // Infinite loop
    while (bAlive)
    {
        // Scope the lock while we access m_isDying
        {
            // Lock down access to the interface
            CMIUtilThreadLock serial(m_mutex);

            // Quit the run loop if we are dying
            if (m_references == 0)
                break;
        }
        // Execute the run routine
        if (!ThreadRun(bAlive))
            // Thread's run function failed (MIstatus::failure)
            break;

        // We will die if we have been signaled to die
        bAlive &= !m_bHasBeenKilled;
    }

    // Execute the finish routine just before we die
    // to give the object a chance to clean up
    ThreadFinish();

    m_thread.Finish();
}
Example #21
0
void interruptStep(void) {
	if(interrupt.master && interrupt.enable && interrupt.flags) {
		unsigned char fire = interrupt.enable & interrupt.flags;
		
		if(fire & INTERRUPTS_VBLANK) {
			interrupt.flags &= ~INTERRUPTS_VBLANK;
			vblank();
		}
		
		if(fire & INTERRUPTS_LCDSTAT) {
			interrupt.flags &= ~INTERRUPTS_LCDSTAT;
			lcdStat();
		}
		
		if(fire & INTERRUPTS_TIMER) {
			interrupt.flags &= ~INTERRUPTS_TIMER;
			timer();
		}
		
		if(fire & INTERRUPTS_SERIAL) {
			interrupt.flags &= ~INTERRUPTS_SERIAL;
			serial();
		}
		
		if(fire & INTERRUPTS_JOYPAD) {
			interrupt.flags &= ~INTERRUPTS_JOYPAD;
			joypad();
		}
	}
}
Example #22
0
int main (void) 
{
    // terminal should be set to MBED's defaults: 9600,8,n,1
    pc.printf("CIS541 HW5, Ariel Eizenberg ([email protected]).\r\n");

    UI::instance().signal_display_time();
    InputSerial serial(pc);
    
	int oldval = 0;
	button2.rise(button2_rise);
	button2.fall(button2_fall);
	crossin.rise(crossin_rise);
	crossin.fall(crossin_fall);

    for(;;)
    {
		int val = button1.read();
		if (val != oldval && val == 1)
			led1 = !led1;
		oldval = val;

		wait(0.25);
		led2 = !led2;
    }
     
}
Example #23
0
FlushContext::List
FlushEngine::getTargetList(bool includeFlushingTargets) const
{
    FlushContext::List ret;
    {
        std::lock_guard<std::mutex> guard(_lock);
        for (const auto & it : _handlers) {
            IFlushHandler & handler(*it.second);
            search::SerialNum serial(handler.getCurrentSerialNumber());
            LOG(spam, "Checking FlushHandler '%s' current serial = %ld", handler.getName().c_str(), serial);
            IFlushTarget::List lst = handler.getFlushTargets();
            for (const IFlushTarget::SP & target : lst) {
                LOG(spam, "Checking target '%s' with flushedSerialNum = %ld",
                    target->getName().c_str(), target->getFlushedSerialNum());
                if (!isFlushing(guard, FlushContext::createName(handler, *target)) || includeFlushingTargets) {
                    ret.push_back(std::make_shared<FlushContext>(it.second, std::make_shared<CachedFlushTarget>(target), serial));
                } else {
                    LOG(debug, "Target '%s' with flushedSerialNum = %ld already has a flush going. Local last serial = %ld.",
                        target->getName().c_str(), target->getFlushedSerialNum(), serial);
                }
            }
        }
    }
    return ret;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void GenerateFaceSchuhMisorientationColoring::execute()
{
  int err = 0;
  setErrorCondition(err);
  dataCheckSurfaceMesh();
  if(getErrorCondition() < 0) { return; }

  dataCheckVoxel();
  if(getErrorCondition() < 0) { return; }

  notifyStatusMessage(getMessagePrefix(), getHumanLabel(), "Starting");

  // Run the data check to allocate the memory for the centroid array
  int64_t numTriangles = m_SurfaceMeshFaceLabelsPtr.lock()->getNumberOfTuples();

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  bool doParallel = true;
#endif

#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
  if (doParallel == true)
  {
    tbb::parallel_for(tbb::blocked_range<size_t>(0, numTriangles),
                      CalculateFaceSchuhMisorientationColorsImpl(m_SurfaceMeshFaceLabels, m_FeaturePhases, m_AvgQuats, m_SurfaceMeshFaceSchuhMisorientationColors, m_CrystalStructures), tbb::auto_partitioner());
  }
  else
#endif
  {
    CalculateFaceSchuhMisorientationColorsImpl serial(m_SurfaceMeshFaceLabels, m_FeaturePhases, m_AvgQuats, m_SurfaceMeshFaceSchuhMisorientationColors, m_CrystalStructures);
    serial.generate(0, numTriangles);
  }

  /* Let the GUI know we are done with this filter */
  notifyStatusMessage(getHumanLabel(), "Complete");
}
Example #25
0
void log(const __FlashStringHelper *ifsh, ...) {
#if USE_CURRENT_TIME
	sampleTime();
#endif

	HardwareSerial &ser = serial();
	reset_sbuf();
#if LOG_FULL_TIME
	sprintf(sbuf, ">[%03u-%02u:%02u:%02u,%03u]>", ts.dd, ts.hh, ts.mm, ts.ss, ts.ml);
#endif

#if LOG_SHORT_TIME
	sprintf(sbuf, ">[%02u:%02u,%03u]>", ts.mm, ts.ss, ts.ml);
#endif
	ser.print(sbuf);
	// print the message
	reset_pgbuf();
	reset_sbuf();

	pgmCopy(ifsh);
	va_list va;
	va_start(va, ifsh);
	vsprintf(sbuf, pgbuf, va);
	va_end(va);
	ser.println(sbuf);
}
Example #26
0
void log_setup() {
	serial().begin(SERIAL_SPEED);
	log_cycle();
#if LOG_FREE_RAM
	log(F("LOG ON,RAM:%u"), getFreeRam());
#endif
}
Example #27
0
int main(int argc, char const *argv[])
{
    
    serial_raspi serial("/dev/ttyACM0",115200);
    serial.begin();

    char buf[128];
    int n;

    while(true) {
        printf(">>> ");
        scanf("%s\n",buf);
        printf("\n");
        n = strlen(buf);
        
        serial.send_data(buf,n);
        serial.recv_data(buf,n);

        printf("received: %s\n\n",buf);
    }



    serial.end();
    return 0;
}
float serial_small_systems(float *a, float *b, float *c, float *d, float *x, int system_size, int num_systems)
{

    float time_spent = 0;
 
#ifdef TIMING_INFO 
    struct timeval T1,T2;
	gettimeofday(&T1,0);
    //clock_t t1, t2;
    //t1 = clock();
#endif

    for (int i = 0; i < num_systems; i++)
	{
        serial(&a[i*system_size],&b[i*system_size],&c[i*system_size],&d[i*system_size],&x[i*system_size],system_size);
	}

#ifdef TIMING_INFO 
    gettimeofday(&T2,0);
    time_spent = (float)(T2.tv_sec-T1.tv_sec)*1000+(float)(T2.tv_usec-T1.tv_usec)/1000;
    //t2 = clock();
    //time_spent = float(t2-t1)/float(CLOCKS_PER_SEC);

    printf("time spent: %f milliseconds\n",time_spent);
    //printf("time spent sec: %f seconds\n",(float)(T2.tv_sec-T1.tv_sec));
    //printf("time spent usec: %f microseconds\n",(float)(T2.tv_usec-T1.tv_usec));

 
#endif

    return time_spent;
}
Example #29
0
int main(int argc, char **argv) {
	if(argc != 2) {
		std::cout << "Usage:" << std::endl
				<< argv[0] << " {port name}" << std::endl;
		return -1;
	}
	std::string port = argv[1];

	auto logger = std::make_shared<util::Logger>();
	logger->addLog(std::make_shared<util::LogFile>("ntpc-comm", util::LogSeverity::TRACE, "ntpc-comm.log"));
	logger->addLog(std::make_shared<util::LogStream>("ntpc-comm", util::LogSeverity::ERROR, std::cerr.rdbuf()));

	try {
		comm::SerialComm serial(port);

		std::vector<uint16_t> rdbuf(20);

		serial.read(rdbuf.begin(), rdbuf.end());

	} catch(const util::posix_error_exception &e) {
		logger->logPosixError(e.getErrno(), e.getWhile());
	} catch(const std::exception &e) {
		logger->logException(e);
	} catch(const char *str) {
		logger->logException(str);
	} catch(const std::string &s) {
		logger->logException(s);
	}

	return 0;
}
PluginInterface::SamplingDevices SoapySDRInputPlugin::enumSampleSources()
{
    SamplingDevices result;
    DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
    const std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration();
    qDebug("SoapySDRInputPlugin::enumSampleSources: %lu SoapySDR devices. Enumerate these with Rx channel(s):", devicesEnumeration.size());
    std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>::const_iterator it = devicesEnumeration.begin();

    for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++)
    {
        unsigned int nbRxChannels = it->m_nbRx;

        for (unsigned int ichan = 0; ichan < nbRxChannels; ichan++)
        {
            QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label));
            QString serial(QString("%1-%2").arg(it->m_driverName).arg(it->m_sequence));
            qDebug("SoapySDRInputPlugin::enumSampleSources: device #%d (%s) serial %s channel %u",
                    idev, it->m_label.toStdString().c_str(), serial.toStdString().c_str(), ichan);
            result.append(SamplingDevice(displayedName,
                    m_hardwareID,
                    m_deviceTypeID,
                    serial,
                    idev,
                    PluginInterface::SamplingDevice::PhysicalDevice,
                    true,
                    nbRxChannels,
                    ichan));
        }
    }

    return result;
}