/* -------------------------------------------------------------------- */
void stmSendTrajectory(float elevatorTrajectory[5], float aileronTrajectory[5]) {
	
	char crc = 0;
	
	sendChar(usart_buffer_stm, 'a', &crc);		// this character initiates the transmission
	
	sendChar(usart_buffer_stm, 1 + 5*4 + 5*4, &crc);	// this will be the size of the message
	sendChar(usart_buffer_stm, 't', &crc);		// id of the message
	
	int i;
	
	// send the elevator trajectory
	for (i = 0; i < 5; i++) {
		
		sendFloat(usart_buffer_stm, elevatorTrajectory[i], &crc);	
	}
	
	// send the aileron trajectory
	for (i = 0; i < 5; i++) {
		
		sendFloat(usart_buffer_stm, aileronTrajectory[i], &crc);
	}
	
	// at last send the crc, ends the transmission
	sendChar(usart_buffer_stm, crc, &crc);	
}
示例#2
0
void muckle_over(int awardQP) {
    CharData *i;
    int reward = 0;

    for(i = character_list; i; i = i->next) {
        sendChar(i, "The quest is over.\r\n");
        REMOVE_BIT_AR(PRF_FLAGS(i), PRF_QUEST);

        if(!awardQP)
            break;

        reward = i->muckleTime/60 + (i->muckleTime % 60 > 0 ? 1:0);
        if(i->muckleTime == muckle_duration * 60)
            reward += 2;

        if(!IS_NPC(i) && reward) {
            sendChar(i, "You have been awarded %d quest points for your effort.\r\n", reward);
            GET_QP(i) += reward;
            mudlog(BRF, LVL_IMMORT, TRUE, "%s has received %d quest points for %s efforts in muckle.",
                    GET_NAME(i), reward, HSHR(i));
        }
        
        i->muckleTime = 0;
    }

    CONFIG_QUEST_ACTIVE = 0;
}
示例#3
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;
}
示例#4
0
bool InterfaceAvr::sendString(QString string, QString callingClassName)
{
//	QString debugstring;

//	emit message(">>> sendString");

	// send starter
	if (sendChar(starter, callingClassName) == true)
	{
		// send 'content' of string
//		debugstring = "*";
		for (int i=0; i<string.length(); i++)
		{
			// char by char
			if (sendChar(string.at(i).toAscii(), callingClassName) == false)
			{
				return false;
			}
//			debugstring.append(string.at(i));
		}

		// send terminator
		if (sendChar(terminator, callingClassName) == true)
		{
			// success
//			debugstring.append("#");
//			emit message(debugstring);
			return true;
		}
	}

	return false;
}
示例#5
0
//======================================================================
//	Get a header record.  If its not an empty one, open the output
//	file.
//======================================================================
static int
header(SerialPort& port)
{
    // Get a header sector (sector 0)
    sendChar(port, NAK);
    int block = getBlock(port, blockBuf);
    if (block == ERROR)
        return ERROR;
    if (block != 0) {
        exitCode = 3;
	return ERROR;
    }
    sendChar(port, ACK);

    // If its a empty header, just return
    if (blockBuf[0] == 0)
	return OK;

    // Get the number of bytes in the file
    bytesLeft = 2000000000L;
    char* ptr = blockBuf + 1 + strlen(blockBuf);
    if (*ptr)
	sscanf(ptr, "%ld", &bytesLeft);

    // Try to open the filename
    outputFile = fopen(blockBuf, "w");
    if (outputFile == NULL) {
        exitCode = 4;
	return ERROR;
    }

    printf("Receiving %s (%ld)\n", blockBuf, bytesLeft);

    return OK;
}
示例#6
0
void TxUART::sendNumber(unsigned int sendMe){
	sendChar(((sendMe / 10000)%10)+48);
	sendChar(((sendMe / 1000)%10)+48);
	sendChar(((sendMe / 100)%10)+48);
	sendChar(((sendMe / 10)%10)+48);
	sendChar(((sendMe)%10)+48);
}
示例#7
0
void ansi_me(void)
{
	// ANSI turn off all attribute: me=\E[0m
	sendChar(27);
	sendChar('[');
	sendChar('0');
	sendChar('m');
}
示例#8
0
文件: tiBasicEditor.cpp 项目: 2mac/ti
void TiBasicEditor::sendKey(SDL_keysym k1)
{
    SDLKey k=k1.sym;
    if (keyParser::isChar(k1))
    {
        sendChar(keyParser::getChar(k1));
        return;
    }

    if (_isInSpecialCommandsMenu)
    {
        switch (k)
        {
        case SDLK_RETURN:
           sendChar( _specialsCommandsMenu->getSelectedString()[0]);
            _isInSpecialCommandsMenu=false;
            reDisplay();
            return;
        case SDLK_DELETE:
            _isInSpecialCommandsMenu=false;
            reDisplay();
            return;
        default:
            _specialsCommandsMenu->sendKey(k1);
        }
    }
    else
    {
        switch (k)
        {
        case SDLK_DELETE:
            rmChar();
            break;
        case SDLK_UP:
            changeLine(true);
            break;
        case SDLK_DOWN:
            changeLine(false);
            break;
        case SDLK_LEFT:
            changeCursorPos(true);
            break;
        case SDLK_RIGHT:
            changeCursorPos(false);
            break;
        case SDLK_RETURN:
            addLine();
            break;
        case SDLK_LALT:
            _isInSpecialCommandsMenu=true;
            _specialsCommandsMenu->reDisplay();
            break;
        }
    }
}
示例#9
0
文件: demo.c 项目: HoboJ/avr
void menu ( void )
{
    sendChar ( '\r' );
    sendString ( "Menu\r" );
    sendString ( "a. Add\r" );
    sendString ( "b. Sub\r" );
    sendString ( "c. Mult\r" );
    sendString ( "d. Integer division\r" );
    sendString ( "e. Decimal division\r" );
    sendChar ( '\r' );
}
示例#10
0
//======================================================================
//	Get a whole block.  Handles checksums, ...
//======================================================================
static int
getBlock(SerialPort& port, char* block)
{
    int checksum;
    int ch;
    int blockNum;

    for (int errorCnt = 0; errorCnt < RETRY_MAX; errorCnt++) {
	ch = recvChar(port, 2);
	if (ch == EOT) {
	    sendChar(port, ACK);
	    return GOT_EOT;
	}

	if (ch == CAN) {
	    exitCode = 7;
	    return ERROR;
	}

	if (ch == SOH || ch == STX) {
	    if (ch == SOH)
	        blockLen = 128;
	    else
	        blockLen = 1024;

	    blockNum = recvChar(port, 2);
	    ch = recvChar(port, 2);
	    if (blockNum + ch == 0377) {
		checksum = 0;
		char* p = block;
		for (int cnt = 0; cnt < blockLen; cnt++) {
		    ch = recvChar(port, 2);
		    checksum += (*p++ = ch);
		}

		ch = recvChar(port, 2);
		if (((checksum - ch) & 0377) == 0)
		    return blockNum;
		exitCode = 8;
	    }
	}

	if (ch == TIMEOUT)
	    exitCode = 9;

	flushInput(port);
	sendChar(port, NAK);
    }

    return ERROR;
}
示例#11
0
void TxUART::rxInt(){
	char input = UDR;
	if (mode == 'i'){
		if (input == 'L'){
			bool temp = myTrans->getLockStatus();
			if (temp)
				sendChar('U');
			else
    			sendChar('L');
		}
		else if (input == 'N'){
			mode = 'r'; //put in receiving mode
			myTrans->newScen();
		}
		else if (input == 'S'){
			myTrans->stopAll();
		}
		else if (input == '1'){
			myTrans->turnOn1();
		}
		else if (input == '2'){
			myTrans->turnOff1();
		}
		else if (input == '3'){
			myTrans->dim1();
		}
		else if (input == '4'){
			myTrans->turnOn2();
		}
		else if (input == '5'){
			myTrans->turnOff2();
		}
		else if (input == '6'){
			myTrans->dim2();
		}
		else if (input == 0){
			myTrans->stopAll();
		}
	}
	else if (mode == 'r'){
		if (charNo <= 100){
			PORTC = charNo; //Debugging
			myTrans->scenData(input);
			charNo++;
		}
		if (charNo == 100){ //end of data
			charNo = 0; //reset counter
			mode = 'i'; //put in idle mode
		}
	}
}
/* -------------------------------------------------------------------- */
void stmSetKalmanPosition(float elevatorPos, float aileronPos) {
	
	char crc = 0;
	
	sendChar(usart_buffer_stm, 'a', &crc);		// this character initiates the transmission
	sendChar(usart_buffer_stm, 1 + 2*4, &crc);		// this will be the size of the message
	
	sendChar(usart_buffer_stm, '3', &crc);		// id of the message
	
	sendFloat(usart_buffer_stm, elevatorPos, &crc);
	sendFloat(usart_buffer_stm, aileronPos, &crc);

	// at last send the crc, ends the transmission
	sendChar(usart_buffer_stm, crc, &crc);
}
/* -------------------------------------------------------------------- */
void stmResetKalman(float initElevator, float initAileron) {
	
	char crc = 0;
	
	sendChar(usart_buffer_stm, 'a', &crc);		// this character initiates the transmission
	sendChar(usart_buffer_stm, 1 + 2*4, &crc);		// this will be the size of the message
				
	sendChar(usart_buffer_stm, '2', &crc);		// id of the message
	
	sendFloat(usart_buffer_stm, initElevator, &crc);
	sendFloat(usart_buffer_stm, initAileron, &crc);

	// at last send the crc, ends the transmission
	sendChar(usart_buffer_stm, crc, &crc);
}
示例#14
0
/*****************************************************************************
	DISCRIPTION	: 文字列送信
	ARGUMENT	: pConsReg	= コンソールバッファ
				  pcStr		= 送信文字列
				  iLen		= 送信する文字列の長さ
	RETURN		: -
	NOTE		: 割込処理とスレッドから呼ばれるが送信バッファを操作しており
				  再入不可のため、スレッドから呼び出す場合は排他のため
				  割込禁止状態で呼ぶこと。
	UPDATED		: 2014-06-22
*****************************************************************************/
static void sendString(CONS_DRV_REG* pConsReg, char* pcStr, int iLen)
{
	int	i;
	
	for(i = 0; i < iLen; i++){
		pConsReg->pcSendBuf[pConsReg->iSendLen] = pcStr[i];
		pConsReg->iSendLen++;
	}
	
	/*
		送信割込無効ならば、送信開始されていないので送信開始する。
		送信割込有効ならば、送信開始されており、送信割込の延長で
		送信バッファ内のデータが順次送信されるので、何もしなくて良い。
	*/
	if(pConsReg->iSendLen != 0){	/* 送信サイズが0でない */
		/* 割込無効である */
		if(srlIntrIsSendEnable(pConsReg->iIdx) == FALSE){
			srlIntrSetSendEnable(pConsReg->iIdx);
			/*
				送信割込を有効化して先頭の1文字を出力する。
				後続の文字は、送信完了後に送信割込の延長で
				送信される。
			*/
			sendChar(pConsReg);
		}
	}
	
	return;
}
示例#15
0
void TarryTown::p_sendText(QScriptValue target,QString text) {
    int i;
    for (i = 0; i < text.length(); i++) {
        QChar c = text.at(i);
        sendChar(c.toAscii());
    }
}
示例#16
0
task main()
{
  // Setup the two UART ports

  //configureSerialPort(uartOne, uartUserControl);
  //configureSerialPort(uartTwo, uartUserControl);
  setBaudRate(uartOne, baudRate115200);
  setBaudRate(uartTwo, baudRate115200);

  while (getChar(uartTwo) != -1) // Purge existing chars from buffer
  {}

  StartTask(UARTReceive);

  while (true)
  {
    // Loop forever transmitting the characters 0, 1, 2, ..., 255, 0, 1, 2, ....

    for (int i = 0; i < 20; ++i)
    {
      ++nTotalXmitChars;
	    xmitChar = nTotalXmitChars % 256;
	    sendChar(uartOne, xmitChar);
	  }

    while (!bXmitComplete(uartOne))
    {
      wait1Msec(1);
    }
  }
}
void LCD1602::sendString (const char str[])
{
	uint8_t i;

	for(i = 0; str[i] != '\0'; i++)
		sendChar(str[i]);
}
/* -------------------------------------------------------------------- */
void stmSendSetpoint(float elevatorSetpoint, float aileronSetpoint) {
	
	char crc = 0;
	
	sendChar(usart_buffer_stm, 'a', &crc);		// this character initiates the transmission
	
	sendChar(usart_buffer_stm, 1 + 2*4, &crc);		// this will be the size of the message
	sendChar(usart_buffer_stm, 's', &crc);		// id of the message
	
	// sends the payload
	sendFloat(usart_buffer_stm, elevatorSetpoint, &crc);
	sendFloat(usart_buffer_stm, aileronSetpoint, &crc);
	
	// at last send the crc, ends the transmission
	sendChar(usart_buffer_stm, crc, &crc);
}
示例#19
0
void sendString(char* string, u8 len)
{
  u8 i;
  for (i=0;i<len;i++)
    sendChar(string[i]);

}
示例#20
0
文件: LCD5110.cpp 项目: a-dma/LCD5110
/**
 * Clear the display and print the character c at (0,0)
 * @param c Character to be printed
 */
void LCD5110::printChar(byte c){

  clearScreen();
  setOrigin();
  sendChar(c);

}
示例#21
0
文件: main.c 项目: owdee/neo2-llkh
bool handleLayer1SpecialCases(KBDLLHOOKSTRUCT keyInfo)
{
	switch(keyInfo.scanCode) {
		case 13:
			sendChar(L'`', keyInfo);
			keybd_event(VK_SPACE, 0, 0, 0); 
			return true;
		case 27:
			sendChar(L'´', keyInfo);
			keybd_event(VK_SPACE, 0, 0, 0); 
			return true;
		default:
			return false;
	}	

}
示例#22
0
void Sim900::send(const char *str) {
    for(int i=0; str[i]; i++) {
        if (sendChar) {
            sendChar(str[i]);
        }
    }
}
/* Diese Funktion dient zum senden eines Strings über die serielle Schnittstele                             */
void sendString(char* s)
{
	while(*s)																	//die SChleife läuft so lange, bis alle Zeichen des Strings gesendet sind
	{
		sendChar(*s++);															//senden eines Zeichens
	}
}
示例#24
0
void Serial::sendString(char *text)
{
	while(*text)
	{
		sendChar(*text++);
	}
}
示例#25
0
/*
** doPoison
*/
void
doPoison(CharData* vict)
{
    int poisonDamage = aff_level(vict, AFF_POISON) + number(1,10);

    if (affected_by_spell(vict, SPELL_RESIST_POISON)) {
        switch (number(1,10)) {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                poisonDamage = 1;
                break;
            case 6:
                if (affected_by_spell(vict, SPELL_POISON)) {
                    sendChar(vict, "You fight off the poison and recover.\r\n");
                    affect_from_char(vict, SPELL_POISON);
                    return;
                }
                break;
            case 7:
            case 8:
            case 9:
            case 10:
                break;
        }
    }
    damage(vict, vict, poisonDamage/3, SPELL_POISON);
}
示例#26
0
int main(void)
{
	// Setup
	// Set pin directions & initial state
	DDRB = 0xFF;
	txoff();
	PORTB &= ~(1<<DATA_PIN);
	
	// Create message
	char *message = "w3vc";
	int message_len = 4;
	int index = 0;
		
    while(1)
    {
        // Send message
		txon();
		_delay_ms(KEY_UP_DELAY_MS);
		for(index = 0; index < message_len; index++){
			sendChar(message[index]);
		}
		_delay_ms(TX_HOLD_MS);
		txoff();
		_delay_ms(TX_OFF_DELAY_MS);
					
    }
}
示例#27
0
void mod_comms_service()
{
	char		data;

	switch(mc_comm_mode)
	{
		case MC_IDLE:
			if(isChar())
			{
				data = recvChar();
				// parse command
				switch(data)
				{
					case 'B':
						triggerBeepTone(2);
						break;
						
					case 'C':
						if(mc_count > 9) {
							mc_count = 0;
						}
						sendChar('@');
						sendChar(mc_count + '0');
						sendChar(13);		// CR
						sendChar(10);		// LF
						++mc_count;
						break;
						
					case 'G':
						mod_io_setBlink(100, IO_GREEN_LED);
						break;

					case 'R':
						mod_io_setBlink(100, IO_RED_LED);
						break;
						
					default:
						break;
				}
			}
			break;

		default:
			mc_comm_mode = MC_IDLE;
			break;
	}
}
示例#28
0
/* nb, also mess up anyone affected by AFF_POISON */
void pulse_heal(void)
{
    CharData *ch;
    int gain = number(18,24);

    for (ch = character_list; ch; ch = ch->next) {
        if(ch->in_room == NOWHERE)
            continue;

        if(!(pvpFactor() > 1)) {
            if( GET_POS(ch) == POS_INCAP )      damage(ch, ch, 1, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_MORTALLYW )  damage(ch, ch, 2, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_DEAD) {
                if(IN_ARENA(ch) || IN_QUEST_FIELD(ch) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG))
                    // If they're dying in the arena, they eventually get better (or killed by someone)
                {
                    GET_HIT(ch) = number(GET_HIT(ch), 1);
                    sendChar(ch, "You slowly recover.\r\n");
                    update_pos(ch);
                }
                else {
                    raw_kill(ch, NULL);
                    continue;
                }
            }
        }

        if (IS_AFFECTED(ch, AFF_PULSE_HIT))
            if (GET_HIT(ch) < GET_MAX_HIT(ch)) GET_HIT(ch) += gain;
        if (IS_AFFECTED(ch, AFF_PULSE_MANA))
            if (GET_MANA(ch) < GET_MAX_MANA(ch)) GET_MANA(ch) += gain;
        if (IS_AFFECTED(ch, AFF_POISON)) doPoison(ch);
        if (IS_AFFECTED(ch, AFF_DISEASE)) doDisease(ch);
	if (affected_by_spell(ch, SKILL_INVIGORATE)) doInvigorate(ch);
        if (IS_BOUNTY_HUNTER(ch) && GET_ADVANCE_LEVEL(ch) >= 1 && IS_AFFECTED(ch, AFF_HIDE)) GET_MOVE(ch) = MIN(GET_MOVE(ch) + 3*gain, GET_MAX_MOVE(ch));
        if (IS_PRESTIDIGITATOR(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + GET_ADVANCE_LEVEL(ch) * 2, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SPELL_HIPPOCRATIC_OATH)) GET_MANA(ch) = MIN(GET_MANA(ch) + 25, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SKILL_PET_MEND)) GET_HIT(ch) = MIN(GET_HIT(ch) * 115 / 100, GET_MAX_HIT(ch));
        if (IS_HOLY_PRIEST(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + 10 + 2*GET_ADVANCE_LEVEL(ch), GET_MAX_MANA(ch));

        /* The room might be poisoned! (Or later, otherwise dangerous) */
        if (ch->in_room != NOWHERE) {
            if (ROOM_FLAGGED(ch->in_room, ROOM_POISONED)) {
                if (!mag_savingthrow(ch, SAVING_SPELL)) {
                    act("$n chokes and gags!", TRUE, ch, 0, 0, TO_ROOM);
                    act("You choke and gag!", TRUE, ch, 0, 0, TO_CHAR);
                    add_affect( ch, ch, SPELL_POISON, 30, APPLY_NONE, 0, 5 TICKS,
                            AFF_POISON, FALSE, FALSE, FALSE, FALSE);
                }
            }
        }

        if(IS_DEFENDER(ch) && !affected_by_spell(ch, SKILL_DEFENDER_HEALTH))
            add_affect(ch, ch, SKILL_DEFENDER_HEALTH, GET_LEVEL(ch), APPLY_HIT, GET_ADVANCE_LEVEL(ch)*5, -1, FALSE, FALSE, FALSE, FALSE, FALSE);

    }
}
示例#29
0
void sendString(char *text)
{
	
	while(*text)
	{
		sendChar(*text++);
	}
}
示例#30
-1
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
		{
			sendFString(ERROR_NONINT);
			sendChar(s[i]);
			sendChar('\r');
			return 0;
		}
	}
	
	ctc[j] = '\0';
	
	if(j>4)// must be < 256
	{
		sendFString(ERROR_NUMTOLARGE);
		return 0;
	}
	else
	{
		set_ctc(atoi(ctc));
	}
		
	return 1;
}