void setJointsCB( const staubliTX60::SetJointsGoalConstPtr &goal ) {
	 //staubli.ResetMotion();
	 ros::Rate rate(10);
	 bool success = true;
	 ROS_INFO("Set Joints Action Cmd received \n");
	 if( staubli.MoveJoints(goal->j,
				goal->params.movementType,
				goal->params.jointVelocity,
				goal->params.jointAcc,
				goal->params.jointDec,
				goal->params.endEffectorMaxTranslationVel, 
				goal->params.endEffectorMaxRotationalVel,
				goal->params.distBlendPrev,
				goal->params.distBlendNext
				) )
	   {
	    ROS_INFO("Cmd received, moving to desired joint angles.");
	    while(true){
	       if (as_.isPreemptRequested() || !ros::ok()) {
		  ROS_INFO("%s: Preempted", action_name_.c_str());
		  // set the action state to preempted
		  staubli.ResetMotion();
		  as_.setPreempted();
		  success = false;
		  break;
	       }
	       if( polling(goal->j) ) break;
	       rate.sleep();
	    }
	    if(success) as_.setSucceeded(result_);
	 }else {
	    as_.setAborted();
	    ROS_ERROR("Cannot move to specified joints' configuration.");
	 }
      }
Exemplo n.º 2
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "Shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "Version")) {
			version();
		} else if (!strcmpigncase(command, "Help")) {
			help();
		} else if (!strcmpigncase(command, "Setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "Getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "Settime")) {
			settime();
		} else if (!strcmpigncase(command, "Gettime")) {
			gettime();
		}
	}
}
Exemplo n.º 3
0
void CPollingThread::doPoll()
{
    //qDebug() << state;
    switch (state) {
    case CSerialPortPrivate::STATE_REQUESTING:
        requesting();
        break;
    case CSerialPortPrivate::STATE_WRITING:
        writing();
        break;
    case CSerialPortPrivate::STATE_POLLING:
        polling();
        break;
    case CSerialPortPrivate::STATE_READING:
        reading();
        break;
    case CSerialPortPrivate::STATE_NOTIFY_DATA:
        notifying();
        break;
    case CSerialPortPrivate::STATE_NOTIFY_TIMEOUT:
        notifyingTimeout();
        break;
    default:
        break;
    }

    usleep(100);
}
Exemplo n.º 4
0
void help()
{
  while(1) {
    serial_println("Which command would you like to know more about?");
    serial_println("Enter CommandList for a list of commands.");
    serial_println("Enter QuitHelp to exit.");
    char *command = polling();
    if (!strcmpigncase(command, "CommandList")) {
	serial_println("Here's a list of available commands:");
	serial_println("Version");
	serial_println("Help");
	serial_println("Setdate");
	serial_println("Getdate");
	serial_println("Settime");
	serial_println("Gettime");
	serial_println("Shutdown");
	serial_println("");
    }
    else if (!strcmpigncase(command, "QuitHelp")) {
      return;
    }
    else if (!strcmpigncase(command, "Version")) {
      serial_println("Version shows the current version of the operating system.");
      return;
    }
    else if (!strcmpigncase(command, "Help")) {
      serial_println("Help gets further help for a prompted command");
      return;
    }
    else if (!strcmpigncase(command, "Setdate")) {
      serial_println("Setdate allows the user to set the date of the operating system.");
      return;
    }
    else if (!strcmpigncase(command, "Getdate")) {
      serial_println("Getdate returns the current date of the operating system.");
      return;
    }
    else if (!strcmpigncase(command, "Settime")) {
      serial_println("Settime allows the user to set the time of the operating system.");
      return;
    }
    else if (!strcmpigncase(command, "Gettime")) {
      serial_println("Gettime returns the current date of the operating system.");
      return;
    }
    else if (!strcmpigncase(command, "Shutdown")) {
      serial_println("Shutdown turns off the operating system.");
      return;
    }
    else {
      serial_print("Unrecognized command: ");
      serial_println(command);
    }
  }    
}
Exemplo n.º 5
0
void setPriority()
{
	serial_print("Please enter the name of the process to alter: ");
	char* name = polling();
	PCB *target = findPCB(name);
	if(target == NULL)
	{
		serial_print("Process not found: \"");
		serial_print(name);
		serial_println("\" is not a valid process name");
	}
	else
	{
		serial_print("What is the new priority? ");
		char* newPriority = polling();
		int priority = atoi(newPriority);
		if(-1 < priority && 10 > priority)
		{
			target->priority = priority;
			int readyIndex = indexByNameReady(name);
			int blockedIndex = indexByNameBlocked(name);
			if (readyIndex >= 0) {
				removePCBAtIndexReady(readyIndex);
			} else {
				removePCBAtIndexBlocked(blockedIndex);
			}
			insertPCB(target);
			serial_print("The process \"");
			serial_print(name);
			serial_println("\" has successfully updated its priority");
		}
		else
		{
			serial_println("Cannot set priority: invalid range");
		}
		sys_free_mem(newPriority);
	}
	sys_free_mem(name);
	sys_free_mem(target);
	serial_println("");
}
Exemplo n.º 6
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				clearAllQueues();
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "version")) {
			version();
		} else if (!strcmpigncase(command, "help")) {
			help();
		} else if (!strcmpigncase(command, "setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "settime")) {
			settime();
		} else if (!strcmpigncase(command, "gettime")) {
			gettime();
		} else if (!strcmpigncase(command, "suspend")) {
			suspendPCB();
		} else if (!strcmpigncase(command, "resume")) {
			resumePCB();
		} else if (!strcmpigncase(command, "setpriority")) {
			setPriority();
		} else if (!strcmpigncase(command, "showPCB")) {
		        showPCB();
		} else if (!strcmpigncase(command, "showReady")) {
		        showReady();
		} else if (!strcmpigncase(command, "showBlocked")) {
		        showBlocked();
		} else if (!strcmpigncase(command, "showAll")) {
		        showAll();
		} else if (!strcmpigncase(command, "yield")) {
		        asm volatile ("int $60");
		        serial_println("");
		} else if (!strcmpigncase(command, "loadr3")) {
		        loadR3();
		} else if (strcmp(command, '\0')) {
			serial_println("Command not recognized. Type help to view commands.");
			serial_println("");
		}
		sys_free_mem(command);
	}
Exemplo n.º 7
0
void settime()
{
	serial_println("What is the current hour?");
    char *response = polling();
    unsigned char portnum = 0x04; //hours port
    writetoRTC(portnum, response);

    serial_println("What is the current minute?");
    response = polling();
    portnum = 0x02; //minutes port
    writetoRTC(portnum, response);

    serial_println("What is the current second?");
    response = polling();
    portnum = 0x00; //seconds port
    writetoRTC(portnum, response);

    serial_print("Time successfully changed to -> ");
    gettime();
    sys_free_mem(response);
}
Exemplo n.º 8
0
void setdate()
{
	serial_println("What day of the week is it?");
    char *response = polling();
  	char *bcdweekday = fromweekday(response);
    unsigned char portnum = 0x06; //weekday port
    writetoRTC(portnum, bcdweekday);

    serial_println("What month is it?");
    response = polling();
  	char *bcdmonth = frommonth(response);
    portnum = 0x08; //month port
  	writetoRTC(portnum, bcdmonth);

    serial_println("What day of the month is it?");
    response = polling();
    portnum = 0x07; //month day port
  	writetoRTC(portnum, response);

    serial_println("What year is it?");
    response = polling();
  	char *bcdyear = sys_alloc_mem(2);
  	if (strlen(response) != 4 || atoi(response) < 2000) {
  		bcdyear[0] = '\0';
  	} else {
  		bcdyear[0] = response[2];
  		bcdyear[1] = response[3];
  	}
    portnum = 0x09;
    writetoRTC(portnum, bcdyear);

    serial_print("Time successfully changed to -> ");
    getdate();
    sys_free_mem(response);
    sys_free_mem(bcdweekday);
    sys_free_mem(bcdmonth);
    sys_free_mem(bcdyear);
}
Exemplo n.º 9
0
void showPCB() {
    serial_print("Please enter the name of the desired PCB to view: ");
    char* pcbName = polling();
    PCB* process = findPCB(pcbName);
    
    if (process == NULL) {
      serial_print(pcbName);
      serial_println(" is not a valid PCB");
      return;
    } 
    PrintPCB(process);
    sys_free_mem(pcbName);
    sys_free_mem(process);
}
Exemplo n.º 10
0
int shutdownConfirmed()
{
	while(1) {
		serial_println("Are you sure you would like to shutdown? (Y/N)");
		char *response = polling();
		if (!strcmpigncase(response, "y") || !strcmpigncase(response, "yes")) {
			sys_free_mem(response);
			return 1;
		} else if (!strcmpigncase(response, "n") || !strcmpigncase(response, "no")) {
			sys_free_mem(response);
			return 0;
		} else {
			sys_free_mem(response);
			serial_println("Entered value not recognized.");
		}
	}
}
Exemplo n.º 11
0
void resumePCB()
{
	serial_print("Please enter the name of the process to resume: ");
	char* name = polling();
	PCB *target = findPCB(name);
	if(target == NULL)
	{
		serial_print("Process not found: \"");
		serial_print(name);
		serial_println("\" is not a valid process name");
	}
	else
	{
		target->suspendedState = 0;
		serial_print("The process \"");
		serial_print(name);
		serial_println("\" has resumed successfully");
	}
	sys_free_mem(name);
	sys_free_mem(target);
	serial_println("");
}
Exemplo n.º 12
0
void deletePCB()
{
	serial_print("Please enter the name of the process to delete: ");
	char* name = polling();
	PCB* target = findPCB(name);
	if(target == NULL)
	{
		if(strlen(name) == 0) {
			serial_print("Process not found: \"");
			serial_print(name);
			serial_println("\" does not appear to exist");
		}
	}
	else
	{
		int readyIndex = indexByNameReady(name);
		int blockedIndex = indexByNameBlocked(name);
		PCB* removedPCB = NULL;
		if (readyIndex >- 0) {
			removedPCB = removePCBAtIndexReady(readyIndex);
		} else {
			removedPCB = removePCBAtIndexBlocked(blockedIndex);
		}
		FreePCB(removedPCB);
		// if (!FreePCB(removedPCB)) {
			serial_print("The process \"");
			serial_print(name);
			serial_print("\" has been deleted successfully");
		// } else {
		//	serial_print("An error occurred while attempting to remove the process \"");
		//	serial_print(name);
		//	serial_println("\"");
		//}
	}
	serial_println("");
}
bool edaMpiWrapperControl::search( edaSolutionList &list )
{ 
  // variables
  int i, j, p, l;
  int command;
  int nidles;
  int idles[nprocs_];
  MPI_Status mpiStat;

  // initialize status variables
  runningJobCount = 0;
  for( i=1; i<nprocs_; i++ ){
    workers_[i].stat_ = EDA_MPI_PROCESSOR_IDLE;
    workers_[i].taskID_ = -1;
  }

  // start the search
  while (!allDone()) {
    vector<int> readyTasks = findReadyTask();
    vector<int>::iterator readyIter;

    // find idle processors
    nidles = 0;
    for( i=1; i<nprocs_; i++ )
      if ( workers_[i].stat_ == EDA_MPI_PROCESSOR_IDLE )
        idles[nidles++] = i;

    // Create the search objects for all ready nodes
    p = 0;
    for (readyIter = readyTasks.begin(); readyIter != readyTasks.end(); readyIter++)
    {
      // task ID on DAG
      int taskID = *readyIter;

      // send computing request to first idle processor
      if ( p < nidles ){
        // send command
        command = EDA_MPI_START_SEARCH;
        MPI_Send( &command, 1, MPI_INT, idles[p], 0, MPI_COMM_WORLD );
       
        // pack search and its parameters
        edaBuffer sa_buf;
        edaSearch *sa = taskDAG[taskID];
        sa->ProcID = idles[p];
        sa->doSerialize( sa_buf, true );

        
        // send buffer for search method
        l = sa_buf.getActualSize();
        MPI_Send( &l, 1, MPI_INT, idles[p],
                  0, MPI_COMM_WORLD );
        MPI_Send( sa_buf.getBuffer(), sa_buf.getActualSize(), 
                  MPI_CHAR, idles[p], 0, MPI_COMM_WORLD );

        // pack solution
        edaBuffer sol_buf;
        edaSolutionList *mysol = NULL;
        mysol = chooseSolution( taskID, list );
        mysol->doSerialize( sol_buf, true );
        
        // send buffer for solution to worker
        l = sol_buf.getActualSize();
        MPI_Send( &l, 1, MPI_INT, idles[p],
                  0, MPI_COMM_WORLD );
        MPI_Send( sol_buf.getBuffer(), l, MPI_CHAR, idles[p],
                  0, MPI_COMM_WORLD );

        // set status of worker to computing
        workers_[idles[p]].stat_ = EDA_MPI_PROCESSOR_COMPUTING;
        workers_[idles[p]].taskID_ = taskID;
        taskStatus[taskID] = STATUS_RUNNING;
        runningJobCount ++;
        p ++;
      } else {
        // no processor idle, then break the loop
        break;
      }
    }
    
    int pollingResult = POLLING_NOCHANGE;
    int nodeFinished;

    // Polling for job finished
    while (true)
    {
      if ( runningJobCount == 0 ){
        // Nothing to poll
        pollingResult = POLLING_NOCHANGE;
        break;
      }

      // poll for any return
      pollingResult = polling( nodeFinished );
      if ( pollingResult == POLLING_FINISHED ){
        break;
      } else if ( pollingResult == POLLING_ERROR ){
        break;
      } else { // NOCHANGE
      }

    }

    // Job finished
    if ( pollingResult == POLLING_FINISHED )
    {
//      printDebug(3, "Job finished: " << workers_[nodeFinished].taskID_);
      taskStatus[workers_[nodeFinished].taskID_] = STATUS_FINISHED;
      runningJobCount--;

      // Get the solution
      edaBuffer result_buf;

      // receive the result status
      MPI_Recv( &l, 1, MPI_INT, nodeFinished, 0, MPI_COMM_WORLD, &mpiStat );
      if ( l == EDA_MPI_SEARCH_FINISHED ) {

        // receive the result into a buffer of characters
        MPI_Recv( &j, 1, MPI_INT, nodeFinished, 0, MPI_COMM_WORLD, &mpiStat );
        char *buf = new char[j];
        MPI_Recv( buf, j, MPI_CHAR, nodeFinished, 0, MPI_COMM_WORLD, &mpiStat );
        result_buf.setBuffer( j, buf );

        edaSolutionList *result = (edaSolutionList*)classGenerateFromBuffer(result_buf);
        taskSolutionList[workers_[nodeFinished].taskID_] = result;
        searchOrder.push_back( workers_[nodeFinished].taskID_ );

        workers_[nodeFinished].stat_ = EDA_MPI_PROCESSOR_IDLE;
      }
      
      checkLoopStatus(workers_[nodeFinished].taskID_);
    }

    // Job error
    if ( pollingResult == POLLING_ERROR )
    {
//      printDebug(3, "Job error while running: " << workers_[nodeFinished].taskID_);
      taskStatus[workers_[nodeFinished].taskID_] = STATUS_ERROR;
      runningJobCount--;
      searchOrder.remove( workers_[nodeFinished].taskID_ );
    }
  }

  if (searchOrder.empty())
  {
    return false;
  }
  
  // TODO: Should return the best result among results
//  printDebug(4, "Last search block is: " << searchOrder.back());
  list = *(taskSolutionList[searchOrder.back()]);

  return true;
}
Exemplo n.º 14
0
static int64_t avalon2_scanhash(struct thr_info *thr)
{
	struct avalon2_pkg send_pkg;
	struct timeval current_stratum;

	struct pool *pool;
	struct cgpu_info *avalon2 = thr->cgpu;
	struct avalon2_info *info = avalon2->device_data;

	int64_t h;
	uint32_t tmp, range, start;
	int i;

	if (thr->work_restart || thr->work_update || !info->first) {
		applog(LOG_DEBUG, "Avalon2: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "Avalon2: Miner Manager have to use stratum pool");
		if (pool->coinbase_len > AVA2_P_COINBASE_SIZE) {
			applog(LOG_ERR, "Avalon2: Miner Manager pool coinbase length have to less then %d", AVA2_P_COINBASE_SIZE);
			return 0;
		}
		if (pool->merkles > AVA2_P_MERKLES_COUNT) {
			applog(LOG_ERR, "Avalon2: Miner Manager merkles have to less then %d", AVA2_P_MERKLES_COUNT);
			return 0;
		}

		cgtime(&info->last_stratum);
		cg_rlock(&pool->data_lock);
		info->pool_no = pool->pool_no;
		copy_pool_stratum(pool);
		avalon2_stratum_pkgs(info->fd, pool, thr);
		cg_runlock(&pool->data_lock);

		/* Configuer the parameter from outside */
		adjust_fan(info);
		info->set_voltage = opt_avalon2_voltage_min;
		info->set_frequency = opt_avalon2_freq_min;

		/* Set the Fan, Voltage and Frequency */
		memset(send_pkg.data, 0, AVA2_P_DATA_LEN);

		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		applog(LOG_ERR, "Avalon2: Temp max: %d, Cut off temp: %d",
		       get_current_temp_max(info), opt_avalon2_overheat);
		if (get_current_temp_max(info) >= opt_avalon2_overheat)
			tmp = encode_voltage(0);
		else
			tmp = encode_voltage(info->set_voltage);
		tmp = be32toh(tmp);
		memcpy(send_pkg.data + 4, &tmp, 4);

		tmp = be32toh(info->set_frequency);
		memcpy(send_pkg.data + 8, &tmp, 4);

		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * avalon2->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 12, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 16, &tmp, 4);

		/* Package the data */
		avalon2_init_pkg(&send_pkg, AVA2_P_SET, 1, 1);
		while (avalon2_send_pkg(info->fd, &send_pkg, thr) != AVA2_SEND_OK)
			;

		if (unlikely(info->first < 2))
			info->first++;
	}

	/* Stop polling the device if there is no stratum in 3 minutes, network is down */
	cgtime(&current_stratum);
	if (tdiff(&current_stratum, &(info->last_stratum)) > (double)(3.0 * 60.0))
		return 0;

	polling(thr);

	h = 0;
	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
		h += info->enable[i] ? (info->local_work[i] - info->hw_work[i]) : 0;
	}
	return h * 0xffffffff;
}
Exemplo n.º 15
0
static void poll_cb()
{
    polling();  
}
Exemplo n.º 16
0
static int64_t hashratio_scanhash(struct thr_info *thr)
{
	struct hashratio_pkg send_pkg;

	struct pool *pool;
	struct cgpu_info *hashratio = thr->cgpu;
	struct hashratio_info *info = hashratio->device_data;
	struct hashratio_ret ret_pkg;
	
	uint32_t tmp, range, start;
	int i;
	
	if (thr->work_restart || thr->work_update || info->first) {
		info->new_stratum = true;
		applog(LOG_DEBUG, "hashratio: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		if (unlikely(info->first))
			info->first = false;

		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "hashratio: Miner Manager have to use stratum pool");
		if (pool->coinbase_len > HRTO_P_COINBASE_SIZE)
			quit(1, "hashratio: Miner Manager pool coinbase length have to less then %d", HRTO_P_COINBASE_SIZE);
		if (pool->merkles > HRTO_P_MERKLES_COUNT)
			quit(1, "hashratio: Miner Manager merkles have to less then %d", HRTO_P_MERKLES_COUNT);

		info->diff = (int)pool->swork.diff - 1;
		info->pool_no = pool->pool_no;

		cg_wlock(&pool->data_lock);
		hashratio_stratum_pkgs(info->fd, pool, thr);
		cg_wunlock(&pool->data_lock);
		
		/* Configuer the parameter from outside */
		memset(send_pkg.data, 0, HRTO_P_DATA_LEN);
		
		// fan
		info->fan_pwm = HRTO_PWM_MAX;
		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		// freq
		tmp = be32toh(info->default_freq);
		memcpy(send_pkg.data + 4, &tmp, 4);
		applog(LOG_DEBUG, "set freq: %d", info->default_freq);
		
		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * hashratio->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 8, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 12, &tmp, 4);

		/* Package the data */
		hashratio_init_pkg(&send_pkg, HRTO_P_SET, 1, 1);
		while (hashratio_send_pkg(info->fd, &send_pkg, thr) != HRTO_SEND_OK)
			;
		
		info->new_stratum = false;
	}

	polling(thr);
	
	return (int64_t)info->local_work * 64 * 0xffffffff;
}
Exemplo n.º 17
0
static int64_t avalon2_scanhash(struct thr_info *thr)
{
	struct avalon2_pkg send_pkg;

	struct pool *pool;
	struct cgpu_info *avalon2 = thr->cgpu;
	struct avalon2_info *info = avalon2->device_data;

	int64_t h;
	uint32_t tmp, range, start;
	int i;

	if (thr->work_restart || thr->work_update ||
	    info->first) {
		info->new_stratum = true;
		applog(LOG_DEBUG, "Avalon2: New stratum: restart: %d, update: %d, first: %d",
		       thr->work_restart, thr->work_update, info->first);
		thr->work_update = false;
		thr->work_restart = false;
		if (unlikely(info->first))
			info->first = false;

		get_work(thr, thr->id); /* Make sure pool is ready */

		pool = current_pool();
		if (!pool->has_stratum)
			quit(1, "Avalon2: Miner Manager have to use stratum pool");
		if (pool->swork.cb_len > AVA2_P_COINBASE_SIZE)
			quit(1, "Avalon2: Miner Manager pool coinbase length have to less then %d", AVA2_P_COINBASE_SIZE);
		if (pool->swork.merkles > AVA2_P_MERKLES_COUNT)
			quit(1, "Avalon2: Miner Manager merkles have to less then %d", AVA2_P_MERKLES_COUNT);

		info->diff = (int)pool->swork.diff - 1;
		info->pool_no = pool->pool_no;

		cg_wlock(&pool->data_lock);
		avalon2_stratum_pkgs(info->fd, pool, thr);
		cg_wunlock(&pool->data_lock);

		/* Configuer the parameter from outside */
		info->fan_pwm = opt_avalon2_fan_min;
		info->set_voltage = opt_avalon2_voltage_min;
		info->set_frequency = opt_avalon2_freq_min;

		/* Set the Fan, Voltage and Frequency */
		memset(send_pkg.data, 0, AVA2_P_DATA_LEN);

		tmp = be32toh(info->fan_pwm);
		memcpy(send_pkg.data, &tmp, 4);

		tmp = encode_voltage(info->set_voltage);
		tmp = be32toh(tmp);
		memcpy(send_pkg.data + 4, &tmp, 4);

		tmp = be32toh(info->set_frequency);
		memcpy(send_pkg.data + 8, &tmp, 4);

		/* Configure the nonce2 offset and range */
		range = 0xffffffff / total_devices;
		start = range * avalon2->device_id;

		tmp = be32toh(start);
		memcpy(send_pkg.data + 12, &tmp, 4);

		tmp = be32toh(range);
		memcpy(send_pkg.data + 16, &tmp, 4);

		/* Package the data */
		avalon2_init_pkg(&send_pkg, AVA2_P_SET, 1, 1);
		while (avalon2_send_pkg(info->fd, &send_pkg, thr) != AVA2_SEND_OK)
			;
		info->new_stratum = false;
	}

	polling(thr);

	h = 0;
	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
		h += info->local_work[i];
	}
	return h * 0xffffffff;
}
Exemplo n.º 18
0
void help()
{
	while(1) {
		serial_println("Which command would you like to know more about?");
		serial_println("Enter \"commands\" for a list of commands.");
		serial_println("Enter \"quit\" to exit.");
		char *command = polling();
		if (!strcmpigncase(command, "commands")) {
			serial_println("Here's a list of available commands:");
			serial_println("Version");
			serial_println("Help");
			serial_println("Setdate");
			serial_println("Getdate");
			serial_println("Settime");
			serial_println("Gettime");
			serial_println("Shutdown");
			serial_println("Suspend");
			serial_println("Resume");
			serial_println("SetPriority");
			serial_println("ShowPCB");
			serial_println("ShowAll");
			serial_println("ShowReady");
			serial_println("ShowBlocked");
			serial_println("Loadr3");
			serial_println("Allocate");
			serial_println("printFree");
			serial_println("printAlloc");
			serial_println("freeMemory");
			serial_println("");
		}
		else if (!strcmpigncase(command, "quit")) {
			break;
		}
		else if (!strcmpigncase(command, "allocate")) {
			serial_println("Allocates the specified amount of memory from the heap.");
			break;
		}
		else if (!strcmpigncase(command, "printfree")) {
			serial_println("Displays a list of all free memory blocks, along with basic information.");
			break;
		}
		else if (!strcmpigncase(command, "printalloc")) {
			serial_println("Displays a list of all allocated memory blocks, along with basic information.");
			break;
		}
		else if (!strcmpigncase(command, "freememory")) {
			serial_println("Frees an allocated memory block with a specified address.");
			break;
		}
		else if (!strcmpigncase(command, "version")) {
			serial_println("Version shows the current version of the operating system, and it's release date.");
			break;
		}
		else if (!strcmpigncase(command, "help")) {
			serial_println("Help gets further help for a prompted command.");
			break;
		}
		else if (!strcmpigncase(command, "setdate")) {
			serial_println("Setdate allows the user to set the date of the operating system through a series of prompts.");
			serial_println("The prompt follows a format of yy mm dd.");
			break;
		}
		else if (!strcmpigncase(command, "getdate")) {
			serial_println("Getdate returns the current date of the operating system.");
			break;
		}
		else if (!strcmpigncase(command, "settime")) {
			serial_println("Settime allows the user to set the time of the operating system through a series of prompts.");
			serial_println("The prompt follows a format of HH MM SS.");
			break;
		}
		else if (!strcmpigncase(command, "gettime")) {
			serial_println("Gettime returns the current date of the operating system.");
			break;
		}
		else if (!strcmpigncase(command, "shutdown")) {
			serial_println("Shutdown presents the user with the option to terminate the system.");
			break;
		}
		else if (!strcmpigncase(command, "suspend"))  {
		  serial_println("Places a PCB in a suspended state and reinserts it into the appropriate queue.");
		  break;
		}

		else if (!strcmpigncase(command, "resume"))  {
		  serial_println("Places a PCB in in the not suspended state and reinserts it into the appropriate queue.");
		  break;
		}

		else if (!strcmpigncase(command, "setpriority"))  {
		  serial_println("Sets a PCB's priority and reinserts the process into the correct place in the correct queue");
		  break;
		}

		else if (!strcmpigncase(command, "showPCB"))  {
		  serial_println("Displays the following information for a PCB:");
		  serial_println("Process Name");
			serial_println("Class");
			serial_println("State");
			serial_println("Suspended Status");
			serial_println("Priority");
			serial_println("");
		  break;
		}

		else if (!strcmpigncase(command, "showall"))  {
		  serial_println("Displays the folling information for each PCB in the ready and blocked queues.");
		  serial_println("Process Name");
			serial_println("Class");
			serial_println("State");
			serial_println("Suspended Status");
			serial_println("Priority");
			serial_println("");
		  break;
		}

		else if (!strcmpigncase(command, "showready"))  {
		  serial_println("Displays the folling information for each PCB in the ready queue.");
		  serial_println("Process Name");
			serial_println("Class");
			serial_println("State");
			serial_println("Suspended Status");
			serial_println("Priority");
			serial_println("");
		  break;
		}

		else if (!strcmpigncase(command, "showblocked"))  {
		  serial_println("Displays the following information for each PCB in the blocked queue.");
		  serial_println("Process Name");
			serial_println("Class");
			serial_println("State");
			serial_println("Suspended Status");
			serial_println("Priority");
			serial_println("");
		  break;
		}

		else if (!strcmpigncase(command, "loadr3")) {
		  serial_println("Loads all r3 processes into memory in a ready blocked state. Used for testing of multiprogramming functionality.");
		  break;
		}

		else {
			serial_print("Unrecognized command: ");
			serial_println(command);
		}
		sys_free_mem(command);
	}
	serial_println("");
}