Пример #1
0
int receive(int socket)
{
	int msgLen = 0;
	char buffer[BUFFER_SIZE];

	memset (buffer,'\0', BUFFER_SIZE);

	if ((msgLen = recv(socket, buffer, BUFFER_SIZE, 0)) == -1)
	{
		printf("Error handling incoming request");
		return -1;
	}

	int request = getRequestType(buffer);

	if ( request == 1 )				// GET
	{
		handleHttpGET(buffer);
	}
	else if ( request == 2 )		// HEAD
	{
		// SendHeader();
	}
	else if ( request == 0 )		// POST
	{
		sendString("501 Not Implemented\n", connecting_socket);
	}
	else							// GARBAGE
	{
		sendString("400 Bad Request\n", connecting_socket);
	}

	return 1;
}
Пример #2
0
    void ClientThread::recvFile(const QString &filename){

        SOCKET conn = openDataConnection();
        if (conn == INVALID_SOCKET)
        {
            sendString(FTPProtocol::getInstance()->getResponse(425));
            return;
        }
        char buff[1024];
        int bytesReaded;
        QFile f(filename);
        if (!f.open(QIODevice::WriteOnly))
        {
            sendString(FTPProtocol::getInstance()->getResponse(550,"Can't open file"));
            return;
        }
        while( (bytesReaded = recv(conn, buff, 1024,0)) && (bytesReaded != -1))
        {
             f.write(buff, bytesReaded);
        }
        f.close();
        shutdown(conn,SD_BOTH);
        closesocket(conn);
        sendString(FTPProtocol::getInstance()->getResponse(226));
    }
Пример #3
0
void initialize()		///Works with current delays
{
	int result;
	result = enterCommandMode();
	sendString(GET_WLAN_STRING, 6);
	Delay10KTCYx(0);
	sendString(SET_SSID, 18);
	Delay10KTCYx(0);
	sendString(SET_PASSPHRASE, 29);
	Delay10KTCYx(0);
	sendString(SET_CHANNEL, 10);
	Delay10KTCYx(0);
	sendString(SET_AUTH, 10);
	Delay10KTCYx(0);
	sendString(SET_JOIN, 10);
	Delay10KTCYx(0);	
	sendString(SET_DHCP, 10);
	Delay10KTCYx(0);
	sendString(SET_COMM_OPEN, 10);
	Delay10KTCYx(0); 
	sendString(SET_COMM_REMOTE, 10);
	Delay10KTCYx(0);
	autoConnect();
	sendString(SAVE, 5);
	Delay10KTCYx(0);
	result = rebootModule();
	longDelay();
}
Пример #4
0
/**
 * Sends a debug event to BinNavi.
 *
 * @param dbg The debug event to be sent.
 *
 * @return A NaviError code that describes whether the operation was successful
 * or not.
 **/
NaviError BaseConnection::sendDebugEvent(const DBGEVT *dbg) const {
  if (!dbg) {
    msglog->log(LOG_VERBOSE, "Error: Invalid debug event passed to function");
    return NaviErrors::INVALID_DEBUG_EVENT;
  }
  if (dbg->type == dbgevt_bp_hit || dbg->type == dbgevt_bpe_hit ||
      dbg->type == dbgevt_bps_hit) {
    return sendBreakpointEvent(dbg);
  } else if (dbg->type == dbgevt_bpe_rem) {
    return sendAddressReply(resp_bpe_rem_succ, 0, dbg->bp.addr);
  } else if (dbg->type == dbgevt_process_closed) {
    return sendProcessClosedEvent(dbg);
  } else if (dbg->type == dbgevt_thread_created) {
    return sendIntegerIntegerReply(resp_thread_created, 0, dbg->tid,
                                   dbg->extra);
  } else if (dbg->type == dbgevt_thread_closed) {
    return sendIntegerReply(resp_thread_closed, 0, dbg->tid);
  } else if (dbg->type == dbgevt_exception) {
    return sendString(resp_exception_occured, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_module_loaded) {
    return sendString(resp_module_loaded, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_module_unloaded) {
    return sendString(resp_module_unloaded, 0, dbg->registerString);
  } else if (dbg->type == dbgevt_process_start) {
    return sendString(resp_process_start, 0, dbg->registerString);
  }
  msglog->log(LOG_ALWAYS, "Error: Unknown debug event");
  return NaviErrors::UNKNOWN_DEBUG_EVENT;
}
Пример #5
0
bool IRC::connect(const std::string &serverName, int serverPort, const std::string &nick)
{
	disconnect();
	
	IPaddress ip;
	socketSet = SDLNet_AllocSocketSet(1);
	if (SDLNet_ResolveHost(&ip, (char *)serverName.c_str(), serverPort)==-1)
	{
		fprintf(stderr, "YOG : ResolveHost: %s\n", SDLNet_GetError());
		return false;
	}

	socket = SDLNet_TCP_Open(&ip);
	if (!socket)
	{
		fprintf(stderr, "YOG : TCP_Open: %s\n", SDLNet_GetError());
		return false;
	}

	SDLNet_TCP_AddSocket(socketSet, socket);
	
	// Here we change the nick on yog for the IRC
	// changing from nick = "nick" to YOGnick = "YOGnick"
	this->nick = "[YOG]" + nick;

	sendString("USER " + this->nick + " undef undef " + PACKAGE_TARNAME + "-" + PACKAGE_VERSION);
	sendString("NICK " + this->nick);

	return true;
}
Пример #6
0
int joinNetwork(){			///More Testing
	int retries;
	int offset;
	int result;
	if(inCommandMode == -1){
		result = enterCommandMode();
		if(result == -1)
			return -1;
		else
		inCommandMode = 1;
	}
	for(retries = 0; retries < RETRY_ATTEMPTS; retries++){
		sendString(JOIN_BOONDOCKS, 15);
		longDelay();
		sendString(SHOW_CONNECTION, 7);
		longDelay();		
		if(Txdata[0] != NULL){
			if(Txdata[2] == '3'){
				result = exitCommandMode();
				while(result != 1){
					result = exitCommandMode();
				}	
				return 1;
			}		
		}
	}
	result = exitCommandMode();
	return -1;
}	
Пример #7
0
int main(void){
	//int x=0;
	
	init_IO();
	init_Uart();
	startup_flashes_text();
	
	init_Timer2and3();
	init_OC2();
	
	
	while(1){
		PORTBbits.RB3=1;
		if(PORTBbits.RB0==1 && dutyCycle<1065){
			PORTBbits.RB3=0;
			sendString("increased duty cycle to ");
			dutyCycle+=5;
			OC2RS=dutyCycle;
			sendNum(dutyCycle);
			sendString(" \t(counterclockwise)\n\r");
			delay(10);
		}
		if(PORTBbits.RB1==1 && dutyCycle>110){
			PORTBbits.RB3=0;
			sendString(" decreased duty cycle to ");
			dutyCycle-=5;
			OC2RS=dutyCycle;
			sendNum(dutyCycle);
			sendString("\t(clockwise)\n\r");
			delay(10);
		}
	}
}
Пример #8
0
    void send(zmq::socket_t& socket, const Message& message)
    {
      // Remember we're using the vector as a stack, so iterate through the
      // address in reverse.
      for (auto it = message.address.rbegin(); it != message.address.rend(); ++it)
      {
        sendStringPart(socket, *it);
      }

      // Send delimiter
      sendStringPart(socket, "");

      // Send subject, then data if there is any
      auto subjectString = detail::serialise<std::uint32_t>(message.subject);
      uint dataSize = message.data.size();
      if (dataSize > 0)
      {
        // The subject
        sendStringPart(socket, subjectString);

        // The data -- multipart
        for (auto it = message.data.begin(); it != std::prev(message.data.end()); ++it)
        {
          sendStringPart(socket, *it);
        }

        // final or only part
        sendString(socket, message.data.back());
      }
      else
      {
        // The subject
        sendString(socket, subjectString);
      }
    }
Пример #9
0
void MainWindow::on_pushButton_clicked()
{   fname = QFileDialog::getOpenFileName(this, tr("Open File"),0,0);
    ui->label_3->setText("Calculating...");
    QThread *thread = new QThread;  // создаём поток... вначале он создаётся остановленным

    MyClass *job = new MyClass; // создаём экземпляр нашего класса
    job->moveToThread(thread);

    if(ui->rb_MD5->isChecked()){

        connect(thread,SIGNAL(started()),job,SLOT(MyCalcMD5())); // когда поток стартует, то начать выполнение работы нашего класса
        connect(job,SIGNAL(sendString(QString)),ui->lineEdit_2,SLOT(setText(QString)));
    }
    if(ui->rb_G2012->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(GOST2012()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit,SLOT(setText(QString)));
    }
    if(ui->rbSha256->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(MyCalcSha256()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit_3,SLOT(setText(QString)));
    }
    connect(job,SIGNAL(finished()),thread,SLOT(quit())); // когда работа будет завершена, завершить поток
            connect(job,SIGNAL(finished()),job,SLOT(deleteLater())); // когда работа будет завершена, удалить наш экземпляр класса
            connect(thread,SIGNAL(finished()),thread,SLOT(deleteLater())); // когда поток остановится, удалить его
thread->start();
connect(job,SIGNAL(change_value(int)),ui->progressBar_2,SLOT(setValue(int)));
connect(job,SIGNAL(set_max(int)),ui->progressBar_2,SLOT(setMaximum(int)));
connect(job,SIGNAL(sendStringDone(QString)),ui->label_3,SLOT(setText(QString)));
connect(job,SIGNAL(sendStringFileName(QString)),ui->label_2,SLOT(setText(QString)));

}
Пример #10
0
int parse_ctc(char s[])
{
	char ctc[11];
	unsigned char i = 3, j = 0;

	while( (s[i] != '\0') && (j <= 11) ) 
	{
	
		if( (s[i] >= '0') && (s[i] <= '9') )
		{
			ctc[j++] = s[i++];
		}
		else
		{
			sendString("Error - Parse_ctc received a non integer: ");
			sendChar(s[i]);
			sendChar('\r');
			return 0;
		}
	}
	
	ctc[j] = '\0';
	
	if(j>4)// must be < 256
	{
		sendString("Error - Parse_ctc number too large");
		return 0;
	}
	else
	{
		set_ctc(atoi(ctc));
	}
		
	return 1;
}
Пример #11
0
/**
 * Sends the given matrix in plain text through the given socket.
 * Rows are delimited by newlines, columns by spaces.
 * \return zero on success; a non-zero error code on failure
 */
int sendMatrix(int sd, struct Matrix *mat)
{
    int i, j;
    char numBuf[50];
    int len;
    int err;

    for (i = 0; i < mat->height; ++i)
    {
        for (j = 0; j < mat->width; ++j)
        {
            /* snprintf() requires -std=c99 or later, so I can't
               use it.  So this isn't as safe as it should be. */
            len = sprintf(numBuf, "%d", mat->rows[i][j]);
            if (len < 0 || len == 50)
            {
                fprintf(stderr, "Buffer overflow converting %d to a string!\n",
                    mat->rows[i][j]);
                return ERANGE;
            }

            if ((err = sendString(sd, numBuf, len)))
                return err;
            if ((err = sendString(sd, " ", 1)))
                return err;
        }

        if ((err = sendString(sd, "\n", 1)))
            return err;
    }

    return 0;
}
Пример #12
0
void homeScreen(void) {

	int choice;
	
	const char *message = "\r\n\tWelcome to Light'o'matic 2000. Prepare for the most gripping PWM\r\n\texperience of your life.Prepare to have your mind blown.\r\n\r\n\tA\tChoose brightness\r\n\tB\tChoose animation\r\n\t\r\n\t";
	
	resetEmulator();

	sendNL();
	sendString(message);
	choice = waitForCharInput();
	
	resetEmulator();

	switch(choice) {
	 	case 'a':
		case 'A':
			menu_chooseBrightness();
		break;
		case 'b':
		case 'B':
			menu_chooseAnimation();
		break;
	}

	sendString("\r\n\t\r\n\t");

}
Пример #13
0
//Get control gains
void procCmd6() {
    //Make sure we aren't running
    running = 0;
    //Tell PC we are ready to get control gains
    sendString("CONTROL\n");
    //Get control gains from PC
    //goes proportional (1/2/3), derivative (1/2/3), then integral (1/2/3)
    double gains[15];
    getDoublePacket(gains,15);
    kp1 = gains[0]; kp2 = gains[1]; kp3 = gains[2];
    kd1 = gains[3]; kd2 = gains[4]; kd3 = gains[5];
    ki1 = gains[6]; ki2 = gains[7]; ki3 = gains[8];
    INNER_K1_14 = gains[9]; INNER_K2_14 = gains[10];
    INNER_K1_11 = gains[11]; INNER_K2_11 = gains[12];
    INNER_K1_8  = gains[13]; INNER_K2_8  = gains[14];
    /* readDouble(&kp1); readDouble(&kp2); readDouble(&kp3); */
    /* readDouble(&kd1); readDouble(&kd2); readDouble(&kd3); */
    /* readDouble(&ki1); readDouble(&ki2); readDouble(&ki3); */
    /* readDouble(&INNER_K1_14); readDouble(&INNER_K2_14); */
    /* readDouble(&INNER_K1_11); readDouble(&INNER_K2_11); */
    /* readDouble(&INNER_K1_8); readDouble(&INNER_K2_8); */
//    readDouble(&kp1curr); readDouble(&kp2curr); readDouble(&kp3curr);
//    readDouble(&kd1curr); readDouble(&kd2curr); readDouble(&kd3curr);
    //Tell PC we are done with control gains
    sendString("GAINSUPDATED\n");
}
Пример #14
0
void setColour(char foreground, char background){
	ASC0_vSendData(27);
	sendString("[3");
	ASC0_vSendData(foreground);
	ASC0_vSendData(27);
	sendString("[4");
	ASC0_vSendData(background);

}
Пример #15
0
int main(void)
{
	SREG = 0x80;	/*ENABLE GLOBAL INTERRUPTS*/
	init_oscillator();
	init_usart();
	init_twi();
 //TWI_MASTER_t twi;
 //PMIC_CTRL= //interrupt
 
	PORTC.DIR |= PIN6_bm;
	
	if(( TWIC_MASTER_STATUS & TWI_MASTER_BUSSTATE_gm) == TWI_MASTER_BUSSTATE_IDLE_gc)
{	
	//TWIC_MASTER_ADDR =0x00; 
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	//TWIC_MASTER_CTRLC = TWI_MASTER_CMD_NOACT_gc;   //read data
	TWIC_MASTER_ADDR = 0xEC;  // R/W bit low to write the reg number from where we want to read
	TWIC_MASTER_ADDR = 0xA0;
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	TWIC_MASTER_ADDR = 0xED; // R/W bit high indicating a read operation 
    TWIC_MASTER_CTRLC = TWI_MASTER_CMD_STOP_gc;
	 int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
	sendString(buffer);
	sendString("\n");
	
}

		//while(TWIC_MASTER_STATUS & 0x10)  //ack/NACK recieved from slave
 
//    TWIC_MASTER_ADDR =0x00; 
//    _delay_ms(100);
//    TWIC_MASTER_ADDR = 0xE7;
//      TWIC_MASTER_ADDR = 0xE5;
// 	 _delay_ms(100);
// TWIC_MASTER_ADDR = 0xA0;
    while(1)
	//for(int i=1; i<=5 ; i++)
    {
    
	 PORTC.OUT &= ~PIN6_bm;
  //  sendString("Test\n");
	_delay_ms(1000);
	PORTC.OUT |= PIN6_bm;
	_delay_ms(1000);
 
   //TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;

   int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
//	sendString(buffer);
    }
}
Пример #16
0
void defineStateNoTime(int tripod, int tipo, int posicao){
	int i;
	for(i = 0; i<3; i++){
		sendString(servos[tripod][tipo][i]);
		sendString(" ");

		sendString(servoState[tripod][i][tipo][posicao]);
		sendString(" ");
	}
}
Пример #17
0
int barcodez(int socket) {
  char tehfile[41];
  char safe[] = IMG_ROOT;
  char cobracmdr[sizeof(tehfile)+sizeof(safe)+9];
  char data[600];
  char safepath[sizeof(safe)+sizeof(tehfile)];
  int res = 0;

  memset(tehfile, 0x0, sizeof(tehfile));
  memset(cobracmdr, 0x0, sizeof(cobracmdr));
  memset(data, 0x0, sizeof(data));
  memset(safepath, 0x0, sizeof(safepath));

  sendString(socket, "Welcome to the data matrix bar code reader.\n");
  sendString(socket, "Enter the name of file uploaded to decode data.\n> ");

  if ((res = recvUntil(socket, tehfile, sizeof(tehfile) - 1, '\n')) == 0) {
    fprintf(stderr, "No datas!\n");
    close(socket);
    exit(1);
  }

  snprintf(safepath, sizeof(safepath), "%s%s", safe, tehfile);

  if ((res = validPath(safe, safepath)) == -1) {
    sendString(socket, "Hey! You can't look in there.\n");
    fprintf(stderr, "%s is outside the safe path.\n", safepath);
    close(socket);
    exit(1);
  }

  snprintf(cobracmdr, sizeof(cobracmdr), "dmtxread %s", safepath);

  if ((fp = popen(cobracmdr, "r")) == NULL) {
    perror("popen");
    close(socket);
    exit(1);
  }

  fread(data, SIZE, 1, fp);

  if (data[0] == 0x0) {
    sendString(socket, "Looks like you lost your file!\n");
    fprintf(stderr, "Nothing read!\n");
    close(socket);
    exit(1);
  }

  sendString(socket, data);

  fclose(fp);
  unlink(safepath);
  close(socket);
  return 0;
}
Пример #18
0
void printGoodResult(uint32_t result) {
    setPosition(0x28); //40 to pozycja pierwsza na dole
    sendString("Wynik: ");
    char tmp[5];
    int i= 0;
    for(i = 0; i < 5; i++) {
        tmp[i] = 0;
    }
    itoa(expectedResult, tmp, 10);
    sendString(tmp);
}
Пример #19
0
void endGame() { //konczenie gry
	isStarted = 0; //zatrzymujemy gre
	isEnded = 1; //konczymy
	player = 1; //zmieniamy gracza do nastepnej rozgrywki na 1
	updateDisplay(9999);
	if (playerOneTime < playerTwoTime) { //wygral gracz pierwszy
		USART_Transmit_String("Wygrywa Gracz 1! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	} else if(playerOneTime > playerTwoTime) {
		USART_Transmit_String("Wygrywa Gracz 2! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	} else {
		USART_Transmit_String("Remis! Gratulacje!");
		USART_Transmit(10); //nowa linia
		USART_Transmit(13); //powrot karetki
	}
    
	USART_Transmit_String("Czas gracza pierwszego: ");
	char tmp[5];
	int i= 0;
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(playerOneTime, tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
	USART_Transmit_String("Czas gracza drugiego: ");
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(playerTwoTime, tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
	USART_Transmit_String("Roznica: ");
	for(i = 0; i < 5; i++) {
		tmp[i] = 0;
	}
	itoa(calculateDistance(playerOneTime, playerTwoTime), tmp, 10);
	USART_Transmit_String(tmp);
	USART_Transmit(10); //nowa linia
	USART_Transmit(13); //powrot karetki
    
	playerOneTime = 0; //zerujemy czasy obu graczy
	playerTwoTime = 0;
	clearAndSetZeroPosition(); //czyscimy wyswietlacz i wracamy na poczatek
	sendString("Jeszcze raz?");
	setPosition(0x28); //40 to pozycja pierwsza na dole
	sendString("Wcisnij klawisz");
}
Пример #20
0
/**
 * @brief Send a file
 * @param sockfd remote socket to send to
 * @param *file_name Name of the file to send
 * @return send bytes or negative on failure
 */
int sendFile(int sockfd, char *file_name)
{

    int file, length;
    //Pointer to play with
    char * ptr;
    //Backup pointer to ptr
    char * bPtr;

    //Open file and get the filesize
    if((file = open(file_name, O_RDONLY, 0)) == -1)
        return -1;
    length = get_file_size(file);

    //Start sending the HTTP file headers
    int header_length = strlen("Content-Length: ") + 5;
    char length_header[header_length];
    snprintf(length_header, header_length ,"Content-Length: %d\r\n", length);
    sendString(sockfd, length_header);
    //TODO: Different file support
    char filetype_format[] = "Content-Type: %s; charset=UTF-8\r\n";
    char filetype[] = "text/html";
    char * filetype_header =
        object_ninit((strlen(filetype_format) + strlen(filetype) - 1) * sizeof(char));
    sprintf(filetype_header, filetype_format, filetype);

    sendString(sockfd, filetype_header);
    free(filetype_header);

    sendString(sockfd, "\r\n");

    if((ptr = malloc(length * sizeof(char))) == NULL)
        return -1;
    bPtr = ptr;
    if(read(file, ptr, length) == -1)
        return -1;

    int send_bytes = 0;
    int bytes_to_send = length;

    while(bytes_to_send > 0){
        send_bytes = send(sockfd, ptr, bytes_to_send, 0);
        if(send_bytes == -1)
            return -1;
        bytes_to_send -= send_bytes;
        ptr += send_bytes;
    }
    //Free the original ptr
    free(bPtr);
    //Return the send_bytes 
    return send_bytes;

}
Пример #21
0
void set_ctc(int count)
{
	char ctc[11];

	sendString("Setting the Compare Timer Count to: ");
	itoa(count,ctc,10);	
	sendString(ctc);
	sendChar('\r');
	
	MilliSec_init(count);

}
Пример #22
0
void createHostMap(HostTraffic *host) {
  HostTraffic *el;
  int num_hosts = 0;

  sendString((char*)map_head);
  //sendString(googleMapsKey);
  sendString((char*)map_head2);
  sendString((char*)map_head4);
  
  for(el=getFirstHost(myGlobals.actualReportDeviceId);
      el != NULL; el = getNextHost(myGlobals.actualReportDeviceId, el)) {

    if((el->l2Host == host->l2Host) && (el->hostIpAddress.hostFamily == host->hostIpAddress.hostFamily)) {
      if((CM_PointEst(host->sent_to_matrix, el->serialHostIndex) > 0)
	 || (CM_PointEst(host->recv_from_matrix, el->serialHostIndex) > 0)) {
	if(el->geo_ip) {
	  char buf[512];
#if 0
	  char buf1[256] = { 0 };
	  int showSymIp;

	  if((el->hostResolvedName[0] != '\0')
	     && strcmp(el->hostResolvedName, el->hostNumIpAddress)
	     && (!privateIPAddress(el)))
	    showSymIp = 1;
	  else
	    showSymIp = 0;
#endif

	  safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf),
			"createMarker(new google.maps.LatLng(%.2f, %.2f), \""
#if 0
			"%s%s"
#endif
			"<A HREF=/%s.html>%s</A><br>%s<br>%s\");\n", 
			el->geo_ip->latitude, el->geo_ip->longitude,
#if 0
			showSymIp ? escape_string(el->hostResolvedName, buf1, sizeof(buf1)) : "", 
			showSymIp ? "<br>" : "",
#endif
			el->hostNumIpAddress, el->hostNumIpAddress,
			el->geo_ip->city ? el->geo_ip->city : "", 
			el->geo_ip->country_name ? el->geo_ip->country_name : "");
	  sendString(buf);
	  num_hosts++;
	  if(num_hosts > MAX_NUM_MAP_HOSTS) break; /* Too many hosts */
	}
      }
    }
  }

  sendString((char*)map_tail2);
}
Пример #23
0
void resetEmulator(void) {
	sendString("\r\n\t\r\n\t");
	while(ASC0_cReadyToTransmit() == -1){}
	ASC0_vSendData(27);
	sendString("[2J");
	while(ASC0_cReadyToTransmit() == -1){}
	ASC0_vSendData(27);
	sendString("[H");

	/*sendNL();
	sendString("---------------");
	sendNL();*/
}
Пример #24
0
void procCmd13() {
    //Tell PC we are ready to get control gains
    sendString("LQRGAINS\n");
    //Get control gains from PC
    //goes proportional (1/2/3), derivative (1/2/3), then integral (1/2/3)
    int i;
    double gains[6];
    int bytesRec = getDoublePacket(K_lqr,24);
    bytesRec = getDoublePacket(gains,6);
    INNER_K1_14 = gains[0]; INNER_K2_14 = gains[1];
    INNER_K1_11 = gains[2]; INNER_K2_11 = gains[3];
    INNER_K1_8  = gains[4]; INNER_K2_8  = gains[5];
    sendString("LQRUPDATED\n");
}
Пример #25
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */


  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  /* For example: for(;;) { } */
  byte c, err;
  for (;;) {
	  do {
		  err = UART_RecvChar(&c);
	  } while(err != ERR_OK);
	  sendString("Press R, G or B to toggle the red, green or blue LEDs.\r\nPress ESC to close.\r\n");
	  do {
		  do {
			  err = UART_RecvChar(&c);
		  } while(err != ERR_OK);
		  if (c == 0x52 || c == 0x72) {
			  Red_NegVal();
			  sendString("Toggle red.\r\n");
		  } else if (c == 0x47 || c == 0x67) {
			  Green_NegVal();
			  sendString("Toggle green.\r\n");
		  } else if (c == 0x42 || c == 0x62) {
			  Blue_NegVal();
			  sendString("Toggle blue.\r\n");
		  }
	  } while(c != 0x1B);
	  sendString("Press any key to start.\r\n");
	  Red_SetVal();
	  Green_SetVal();
	  Blue_SetVal();
  }

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Пример #26
0
void initGame() { //inicjalizacja gry
	time = 0;
	tries = 0;
	failedTries = 0;
	isEnded = 0;
	updateDisplay(time);
	clearAndSetZeroPosition();
	if(player == 1) {
		sendString("Gracz 1");
	} else {
		sendString("Gracz 2");
	}
	setPosition(0x28); //40 to pozycja pierwsza na dole
	sendString("Wcisnij klawisz");
}
Пример #27
0
/**
 *  This function registers the user with there server.  It sends the nick and tue user name.
 *  When an irc client connects to the server within a certain period of time the client must
 *  register the user with the server.  This involves sending the NICK message to submit the nick
 *
 *  @param nick the nickname to use on the irc server
 *  @param uname the user name
 *  @param rname the users real name
 *
 *  @returns CONNECT_SUCCESS on success or NICK_COLLISION
 */
int ircInterface::registerUser(std::string nick, std::string uname, std::string rname){

	_nick = nick;
	_uname = uname;
	_rname = rname;

	std::string msg = NICK + " " + nick+ "\r\n";
	sendString(msg);
	msg = "USER " + uname + " 0 * :" + rname + "\r\n";
	sendString(msg);
	_serverConnection->sleep(SLEEP_INTRV);
	
	return _connStatus->waitOnConnect();

}
Пример #28
0
void menu_chooseBrightness(void) {
	unsigned char brightness = 0, loop_break = 0;
	int direction = 0;
	/*sendString("BRIGHTNESS SELECT");
	brightness = (waitForCharInput()-48)*10;

	sendString("\r\n\t\r\n\tYou chose ");
	//sendString(brightness);
	GPT1_setBrightness(brightness);*/
	
	resetEmulator();
	//setColour(6, 7);

	sendNL();
	sendString("BRIGHTNESS SELECT:");

	sendNL();
	sendString("Use the arrow keys to select the brightness you want.");

	sendNL();
	sendString("Press enter when you're done.");
	
	sendNL();
	sendNL();

	while(loop_break==0){
		drawBrightnessScreen();
		direction = waitForDirectionInput();
		switch(direction) {
			case 'C':
			case 'c':
				loop_break = 0;
				if(GPT1_getBrightness()+5 <= BRIGHTNESS_MAX)
					GPT1_setBrightness(GPT1_getBrightness()+BRIGHTNESS_INCREMENT);
			break;
			case 'D':
			case 'd':
				loop_break = 0;
				if(GPT1_getBrightness() >= BRIGHTNESS_INCREMENT)
					GPT1_setBrightness(GPT1_getBrightness() - BRIGHTNESS_INCREMENT);
			break;
			default:
				loop_break = -1;
				return;
			break;
		}
	}
}
Пример #29
0
void main(void) {
    /* stop the watchdog timer */
    WDTCTL = WDTPW + WDTHOLD;

    /* For debouncing: set the auxilliary clock to use very low-power
     * oscillator.  Later, we'll have the Watchdog timer use the
     * auxilliary clock for debouncing the button.
     */
    BCSCTL3 |= LFXT1S_2;

    /* LEDs off, but later we'll blink them as we send bits */
    P1DIR |= RED_LED+GRN_LED;
    P1OUT &= ~ (RED_LED + GRN_LED );

    initUart();

    /* We'll use the button to let the chip know we're ready to communicate.
     * Direction is receive, clear interrupt flag, and
     * interrupts are enabled.
     */
    P1DIR &= ~BUTTON;
    P1IFG &= ~BUTTON;
    P1IE |= BUTTON;

    for( ; ; ) {
        /* go to sleep until button press */
        __bis_SR_register( LPM3_bits + GIE );
        sendString( "Hello, world!\r\n" );
    }
}
Пример #30
0
void TSocket::readClient()
{
        qDebug() << "Client connected";

        QFile file("C:\\tt.txt");
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            return;

        QTextStream in(&file);

        while( !in.atEnd() )
        {
            QString str = in.readLine();
            sendString( str );
        }

        file.close();

        QDataStream out( this );
        out << qint64( 0xFFFF );

        close();
        //disconnectFromHost();
        //waitForDisconnected();
}