Beispiel #1
0
void intro(void) {
	FILE *in;
	char ch;
	int i,j;
	int vk;
	
	clearScreen();
	
	in = fopen("intro.txt","r");
	/* 把檔案�堶悸漲r讀取並顯示出來 */
	for(i=0;i<HEIGHT;i++) {
		for(j=0;j<WIDTH*2;j++) {
			while((ch = fgetc(in)) == '\n' || ch == '|' || ch == '-');  
			putASCII2(j + OFFSET_X,i + OFFSET_Y,ch,15,0);
		}
	}
	fclose(in);
	drawCmdWindow();
	
	/* 當使用者按下 Enter 鍵即離開 */
	while(1) {
		if(waitForKeyDown(1)) {
			vk=getKeyEventVirtual();
			if(vk == VK_RETURN)
				break;
		}
		if(i==0)
			putString(46+OFFSET_X,18+OFFSET_Y,"                    ",12,0);
		else
			putString(46+OFFSET_X,18+OFFSET_Y,"想離開請按 Enter ...",12,0);
		drawCmdWindow();
		i= !i;
	}
}
Beispiel #2
0
float UI::getFloatFromCUI(){
    uint8_t c = 0;
    float fnum = 0;
    float dp = 0.1;                 // dp = decimal point (小数点)
    while(1){
        c = getChar();
        if(c == '\r'){              // Enterキー押下
            break;
        }
        if(c == '.' && checkDotFlag() == false){              // ドット押下
            raiseDotFlag();
            dp = 0.1;
            continue;
        }
        if(c < '0' || c > '9'){     // 数字0-9,Enter以外
            putString("\n\r");      // 改行
            fnum = 0;                // num をクリア
            dropDotFlag();
            dp = 0.1;
            continue;
        }
        if( checkDotFlag() == false ){
            fnum = fnum * 10 + c - '0';
        } else if(dp > DP_LIMIT){
            fnum = fnum + (c - '0') * dp;
            dp /= 10;
        } else{
            putString("\b \b");      // BackSpace
        }
    }
    dropDotFlag();
    return (fnum);
}
Beispiel #3
0
int16_t UI::getIntegerFromCUI(){
    uint16_t c = 0;
    uint16_t num = 0;
    bool mflag = false;             // マイナスフラグ
    while(1){
        c = getChar();
        if(c == '\r'){              // Enterキー押下
            break;
        }
        if(c== '-' && num == 0 && mflag == false){  // この条件では、0入力後のマイナス(ex. 0-25etc...)を除外できない
            mflag = true;
            continue;
        }
        if(c < '0' || c > '9'){     // 数字0-9以外
            putString("\n\r");      // 改行
            num = 0;                // num をクリア
            mflag = false;          // マイナスフラグをクリア
            continue;
        }
        num = num * 10 + ( c - '0');
        if( num > 255 || num < -255){
            putString("\n\rBeyond the limit\n\r");  // 範囲外
        }
    }
    if(mflag == false){
        return (num);
    } else{
        return ( -1 * num);
    }
}
Beispiel #4
0
static void putUser(SFLReceiver *receiver, SFLExtended_user *user)
{
  putNet32(receiver, user->src_charset);
  putString(receiver, &user->src_user);
  putNet32(receiver, user->dst_charset);
  putString(receiver, &user->dst_user);
}
Beispiel #5
0
static void testStringTable(void)
{
  int val;
  struct StringTable *st;
  int i;
  for (i = 0; i < 100; i += 1) {
    st = newStringTable();
    rassert(st);
    rassert(findString(st, "dog") == NULL);
    rassert(putString(st, "cat", &val) == 0);
    rassert(findString(st, "cat") == &val);
    rassert(delString(st, "dog") == ERR_NOSTRING);
    rassert(delString(st, "cat") == 0);
    rassert(findString(st, "cat") == NULL);
    rassert(putString(st, "1", &val) == 0);
    rassert(putString(st, "2", &val) == 0);
    rassert(putString(st, "3", &val) == 0);
    allSum = 0;
    allStrings(st, allStringTester, NULL);
    rassert(allSum == 6);
    rassert(delString(st, "1") == 0);
    rassert(delString(st, "3") == 0);
    rassert(delString(st, "2") == 0);
    rassert(putString(st, "memcheck", &val) == 0);
    freeStringTable(st);
    }
}
Beispiel #6
0
int main(int argc, char *argv[])
{
	char stringToPrint[64];

	clearScreen();

	initNetwork();

	sprintf(stringToPrint,"Hallo, dies ist ein Test! !\"$%&/()=?),.-;:_#'`*+~");
	putString(stringToPrint,COLOR_RED);
	
	putString(" :-) :-D ",COLOR_GREEN);
	putString("Einiges noch zu tun!",COLOR_AMBER);

	updateDisplay(client_sock);

	sleep(1);

	while(1)
	{
		shiftLeft();
		updateDisplay(client_sock);
		usleep(20000);
	}


	close(client_sock);

	return 0;
}
Beispiel #7
0
void *runPeriodicTask (void *t){
  TaskInfo           s;      // self reference
  Time               c = 0;  // completion time
  Time               d = 0;  // deadline

  s = periodicTaskTable[*(int *)t];

  while (systemNotCompleted()){

    // Compute the deadline or the next activation
    d=nextActivation(s.period);

    putHeader (s.name);
    putString ("activated");
    newLine();

    // Simulate the execution of this task using
    // computeDuringTimeSpan. Provide the name of the task, its worst
    // case execution time, and the period of the task. ATTENTION :
    // the period parameter in computeDuringTimeSPan is used to
    // compute the execution priority. It returns the completion time
    // that should be used to check whether the task missed its
    // deadline. Use variable c to save this value. See tasks.h.


    //    NYI("compute task for its computation time");
    //********************************************************
      c = computeDuringTimeSpan(s.name, s.computation, s.period);
    
    //    NYI("save the completion time in variable c for later use");
    //********************************************************
    // c = timeAfterTimeSpan(s.computation);
    
    putHeader (s.name);
    putString ("completed");
    newLine();

    // Check that the completion time did not occur after the deadline
    if (d < c) {
      putHeader (s.name);
      putString ("OVERRUN ");
      putTime   (d);
      putString (" < ");
      putTime   (c);
      newLine();
      break;
    };

    // Wait for the next activation. In other words, wait for the deadline.
    // NYI("wait for the next activation");
    //**********************************************************
    delayUntil(d);

    
  }

  return NULL;
}
Beispiel #8
0
void cmain() {
    setSysInt();
    putString("Hello, world!\n");
    while (status) {
        putString("$ > ");
        parseCommand(getString());
    }
    putString("Bye\n");
}
void displayFreq()
{
	command(HOME);
	sprintf(temp,"0:%06u 1:%06u",freqValue[0],freqValue[1]);
	putString(temp);
	putChar(13);
	sprintf(temp,"2:%06u 3:%06u",freqValue[2],freqValue[3]);
	putString(temp);
	putChar(13);
	putChar(13);
	putString("Frequency");
}
void displayTC()
{
	command(HOME);
	sprintf(temp,"FS:%06u RS:%06u",frontSpeed,rearSpeed);
	putString(temp);
	putChar(13);
	sprintf(temp,"SL:%06u ST:%03u",slip,status);
	putString(temp);
	putChar(13);
	putChar(13);
	putString("Traction Control");
}
Beispiel #11
0
int ioHandler::getMenu()
{
	putString("------ 성적관리 프로그램 ------");
	putString("------ 1. 사람 성적 등록 ------");
	putString("------ 2. 사람 성적 삭제 ------");
	putString("------ 3. 사람 성적 출력 ------");
	putString("------ 4. 프로그램 종료  ------");

	int menu = getInteger(" 선택 : ");
	if (menu >= INSERT && menu <= EXIT)
	{
		return menu;
	}
}
void displayAnalogue()
{
	command(HOME);
	sprintf(temp,"0:%04d 1:%04d 2:%04d",adcValues[0],adcValues[1],adcValues[2]);
	putString(temp);
	//putChar(13);
	sprintf(temp,"3:%04d 4:%04d 5:%04d",adcValues[3],adcValues[4],adcValues[5]);
	putString(temp);
	//putChar(13);
	sprintf(temp,"6:%04d 7:%04d",adcValues[6],adcValues[7]);
	putString(temp);
	putChar(13);
	putString("Analogue");
}
Beispiel #13
0
static void exec_Var(void * A)
{
void * C;
struct Var * N;
void (*f) (void);
    N = (struct Var*) A;
    /* printf("executeVar %s %d !!\n",N->l, N->t);*/
    switch(N->t) {
       case VT_B :
          putBool(N->b);
          break;
       case VT_C :
          putString((char*)N->a);
          break;
       case VT_N :
          if (nbOnStack(N->a) > 0) {
             C = duplicateNum(N->a,1);
             N->a = C;
          }
          putVar(N->a);
          break;
       case VT_L :
          f = (PFV)(N->a);
          f();
          break;
       case VT_F :
          execFctV(N->a);
          break;
       default : /* VT_I */
          break;
    }
}
Beispiel #14
0
         //
         // Info::putChunkMIMP
         //
         void Info::putChunkMIMP()
         {
            if(!numChunkMIMP) return;

            Core::Array<IR::Object const *> imps{numChunkMIMP};

            auto itr = imps.begin();
            for(auto const &obj : prog->rangeObject())
            {
               if(!obj.defin && obj.space.base == IR::AddrBase::MapReg)
                  *itr++ = &obj;
            }

            Core::FastU size = numChunkMIMP * 4;
            for(auto const &imp : imps)
               size += lenString(imp->glyph);

            putData("MIMP", 4);
            putWord(size);

            for(auto const &imp : imps)
            {
               putWord(imp->value);
               putString(imp->glyph);
            }
         }
bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) {
	size_t size;

	if (_saving) {
		size = val.size();
		_saveStream->writeUint32LE(size);

		for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) {
			putString((*it).c_str());
		}
	} else {
		val.clear();
		size = _loadStream->readUint32LE();

		for (size_t i = 0; i < size; i++) {
			char *str = getString();
			if (_loadStream->err()) {
				delete[] str;
				return STATUS_FAILED;
			}
			if (str) {
				val.push_back(str);
			}
			delete[] str;
		}
	}

	return STATUS_OK;
}
Beispiel #16
0
void USART::printf_length(const char *str,uint16_t length)
{	
	#if (USE_DMA == 1)
		uint16_t i = 0;
		uint16_t tmp_length;
		tmp_length = length;

		wait_busy();
		while(tmp_length--)
		{
			send_buf[i++] = *str++;
		};

		DMA_DeInit(_DMA1_Channelx);   //将DMA的通道1寄存器重设为缺省值
		_DMA1_Channelx->CPAR = (u32)&_USARTx->DR; //外设地址
    _DMA1_Channelx->CMAR = (u32) send_buf; //mem地址
    _DMA1_Channelx->CNDTR = length ; //传输长度
    _DMA1_Channelx->CCR = (0 << 14) | // 非存储器到存储器模式
            (2 << 12) | // 通道优先级高
            (0 << 11) | // 存储器数据宽度8bit
            (0 << 10) | // 存储器数据宽度8bit
            (0 <<  9) | // 外设数据宽度8bit
            (0 <<  8) | // 外设数据宽度8bit
            (1 <<  7) | // 存储器地址增量模式
            (0 <<  6) | // 外设地址增量模式(不增)
            (0 <<  5) | // 非循环模式
            (1 <<  4) | // 从存储器读
            (1 <<  3) | // 是否允许传输错误中断
            (0 <<  2) | // 是否允许半传输中断
            (0 <<  1) | // 是否允许传输完成中断
            (1);        // 通道开启
	#else
		putString(str,length);
	#endif
}
Beispiel #17
0
void BasePersistenceManager::putDouble(double val) {
    int exponent = 0;
    double significand = frexp(val, &exponent);
    Common::String str = Common::String::format("DS%f", significand);
    putString(str.c_str());
    _saveStream->writeSint32LE(exponent);
}
Beispiel #18
0
void sendStrings(jvmtiEnv *jvmti_env, vector<string> stringsToSend)
{
  vector<string>::iterator it;
  jvmti_env->RawMonitorEnter(monitorSocket);
  for (it = stringsToSend.begin(); it < stringsToSend.end(); it++)
    putString(&socket_inst, *it);
  jvmti_env->RawMonitorExit(monitorSocket);
}
void BasePersistenceManager::putString(const Common::String &val) {
	if (!val.size()) {
		putString("(null)");
	} else {
		_saveStream->writeUint32LE(val.size());
		_saveStream->writeString(val);
	}
}
void TestSerialization::testStringLengthLimits()
{
	std::vector<u8> buf;
	std::string too_long(STRING_MAX_LEN + 1, 'A');
	std::string way_too_large(LONG_STRING_MAX_LEN + 1, 'B');
	std::wstring too_long_wide(WIDE_STRING_MAX_LEN + 1, L'C');

	EXCEPTION_CHECK(SerializationError, putString(&buf, too_long));

	putLongString(&buf, too_long);
	too_long.resize(too_long.size() - 1);
	putString(&buf, too_long);

	EXCEPTION_CHECK(SerializationError, putWideString(&buf, too_long_wide));
	too_long_wide.resize(too_long_wide.size() - 1);
	putWideString(&buf, too_long_wide);
}
Beispiel #21
0
void Parcel::putBinder(const sp<IBinder>& base, const sp<IBinder>& binder) {
    try {
        sp<URI> descriptor = new URI(binder->getInterfaceDescriptor());
        sp<URI> uri = new URI(base->getUri()->getScheme(), binder->getUri()->getAuthority(), String::format("/if=%s", descriptor->getPath()->substring(1)->c_str()), descriptor->getQuery(), nullptr);
        putString(uri->toString());
    } catch (const URISyntaxException& e) {
        throw RemoteException(e);
    }
}
Beispiel #22
0
         //
         // Info::putChunk
         //
         void Info::putChunk(char const *name, Core::Array<Core::String> const &strs, bool junk)
         {
            std::size_t base;
            std::size_t off;

            // Calculate base offset.
            base = strs.size() * 4 + 4;
            if(junk) base += 8;

            // Calculate size of chunk.
            off = base;
            for(auto const &s : strs)
               off += lenString(s);

            // Write chunk header.
            putData(name, 4);
            putWord(off);

            // Write string count.
            if(junk) putWord(0);
            putWord(strs.size());
            if(junk) putWord(0);

            // Write string offsets.
            off = base;
            for(auto const &s : strs)
            {
               putWord(off);
               off += lenString(s);
            }

            // Write strings.
            if(junk && UseChunkSTRE)
            {
               off = base;
               for(auto const &s : strs)
               {
                  putString(s, off * 157135);
                  off += lenString(s);
               }
            }
            else for(auto const &s : strs)
               putString(s);
         }
Beispiel #23
0
void rankList(void)
{
	FILE *in;
	char name[100];
	char toString[100];
	int score;
	int i=1;
	int vk;
	
	clearScreen();
	
	in = fopen("ranklist.slmt","r");
	
	putString(24+OFFSET_X,1+OFFSET_Y,"排     行     榜",11,5);
	
	while(fscanf(in,"%d,%s",&score,name) == 2) {
		
		sprintf(toString,"%d.  %7d",i,score);
		putString(14+OFFSET_X,i*2+1+OFFSET_Y,toString,15,0);
		putString(44+OFFSET_X,i*2+1+OFFSET_Y,name,15,0);
		
		i++;
	}
	
	fclose(in);
	drawCmdWindow();
	
	/* 當使用者按下 Enter 鍵即離開 */
	while(1) {
		if(waitForKeyDown(1)) {
			vk=getKeyEventVirtual();
			if(vk == VK_RETURN)
				break;
		}
		if(i==0)
			putString(46+OFFSET_X,18+OFFSET_Y,"                    ",12,0);
		else
			putString(46+OFFSET_X,18+OFFSET_Y,"想離開請按 Enter ...",12,0);
		drawCmdWindow();
		i= !i;
	}
}
int main() {

    // Setup and enable the secure mode TLB
    // Note: Processor starts out in secure mode
    setupTranslationTable();
    enableTLB();

    printf ("\n*** Writing to uart from Secure Mode\n");
    putString("Hello from secure mode!\n");

    printf ("\n*** Entering Non-Secure Mode\n");
    enterNonSecure();

    // Enable the non-secure TLB (uses same translation table as secure mode)
    enableTLB();

    printf ("\n*** Writing to uart from Non-Secure Mode\n");
    putString("Hello from non-secure mode!\n");

}
Beispiel #25
0
/**
 * コンストラクタ
 */
UI::UI():
    mState(NOP),
    mDotFlag(false)
{
    OpenSerialPort();
    if( isConnected() == true){
        putString("BlueTooth is connected!\n\r");
    } else{
        // mBlueTooth->putString("conect dekite naiyo\n\r");
    }
}
static void
gltrace_putMark(JNIEnv *jni, jclass klass, jstring jstr)
{
    uint64_t bgn = gethrtime();
    const char *str = (*jni)->GetStringUTFChars(jni, jstr, 0);
    putCmd(OPC_MARK);
    putString(str);
    (*jni)->ReleaseStringUTFChars(jni, jstr, str);
    uint64_t end = gethrtime();
    putTime(bgn, end);
}
Beispiel #27
0
static void IF_dupC_i(int i)
{
char * S;
int I;
    I = i_StackC;
    if (I>=i) {
       S = stackC[I-i];
       putString(S);
    } 
    else messErr(19);
}
Beispiel #28
0
static void Get_Date_Time(int x)
{
struct tm * T;
time_t t0;
char b[12];
    t0 = time(NULL);
    T = localtime(&t0);
    if (x) sprintf(b,"%.2d/%.2d/%.4d",T->tm_mday,T->tm_mon+1,T->tm_year+1900);
    else   sprintf(b,"%.2d:%.2d:%.2d",T->tm_hour,T->tm_min,T->tm_sec);
    putString(b);
}
Beispiel #29
0
int main( void )
{
  init();
  putString("Clock up.\n");
  while (1) {
    sleep_cpu();
    if ( (flags & FLAG_PENDING_COMMAND) != 0 ) {
      processCommand();
    }
  }
  return 0;
}
Beispiel #30
0
// 재직 중이거나 재직한 적이 있는 직원의 직원 번호를 입력 받는다. 
string ioHandler::getStaffId(StaffList& s_list, string msg)
{
	string s_id;

	while (1)
	{
		s_id = getString(msg);
		Staff s = s_list.searchStaff(s_id);
		if (s.staff_id != "")	break;		// if valid patient id
		putString("", "Invalid staff id!!, Retry!!");
	}
	return s_id;
}