int main(int argc, char **argv) { void *f; int logout; clock_t S = clock(); clock_t S0 = 0, S1; Prog_Init(argc,argv,"?|h,l",PROG_EXIT_ON_ERROR); logout = Prog_Has_Opt("l"); f = Cfile_Open(Prog_Argument_Dflt(0,"longinteger.txt"),"r"); while ( !Oj_Eof(f) ) __Auto_Release { YOYO_BIGINT *a, *b, *c, *R; char *l = Oj_Read_Line(f); YOYO_ARRAY *q = Str_Split(l,0); if ( !q->count ) continue; a = Bigint_Decode_10(q->at[1]); b = Bigint_Decode_10(q->at[2]); c = Bigint_Decode_10(q->at[3]); R = Bigint_Decode_10(q->at[4]); if ( !strcmp(q->at[0],"*") ) { YOYO_BIGINT *Q = Bigint_Mul(Bigint_Copy(a),b); if (logout) puts(__Format("%s*%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"/") ) { YOYO_BIGINT *Q = Bigint_Div(Bigint_Copy(a),b); if (logout) puts(__Format("%s/%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"+") ) { YOYO_BIGINT *Q = Bigint_Add(Bigint_Copy(a),b); if (logout) puts(__Format("%s+%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"-") ) { YOYO_BIGINT *Q = Bigint_Sub(Bigint_Copy(a),b); if (logout) puts(__Format("%s-%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"%") ) { YOYO_BIGINT *Q = Bigint_Modulo(Bigint_Copy(a),b); if (logout) puts(__Format("%s%%%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"**%") ) { YOYO_BIGINT *Q = Bigint_Expmod(Bigint_Copy(a),b,c); if (logout) puts(__Format("%s**%s%%%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(c), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"*%") ) { YOYO_BIGINT *Q = Bigint_Modmul(Bigint_Copy(a),b,c); if (logout) puts(__Format("%s*%s%%%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(c), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"*/%") ) { YOYO_BIGINT *Q = Bigint_Invmod(Bigint_Copy(a),b); if (logout) puts(__Format("%s/%%%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],"<<") ) { YOYO_BIGINT *Q = Bigint_Lshift(Bigint_Copy(a),b->value[0]); if (logout) puts(__Format("%s<<%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } else if ( !strcmp(q->at[0],">>") ) { YOYO_BIGINT *Q = Bigint_Rshift(Bigint_Copy(a),b->value[0]); if (logout) puts(__Format("%s>>%s=%s (%s)", Bigint_Encode_10(a), Bigint_Encode_10(b), Bigint_Encode_10(Q), Bigint_Encode_10(R))); REQUIRE( Bigint_Equal(Q,R) ); } } S1 = clock(); printf("total time: %.3f\n",(double)(S1-S)/CLOCKS_PER_SEC); return 0; }
int main(void) { char s[] = "1442936700,0,1,4,#2346W,3,#0800O#1900C#0900O#1800C"; // for str_processing test RCC_ClocksTypeDef RCC_Clocks; /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE); RNG_Cmd(ENABLE); /* Initialize the timer for dht11 */ tim_init(TIM2); /* Initialize the SRAM ****************************************************/ PSRAM_Init(); /* Initialize the LCD *****************************************************/ LCD_Init(); LCD_LOG_Init(); LCD_LOG_SetHeader((uint8_t*)" Ethernet test"); LCD_LOG_SetFooter ((uint8_t*)" localtime: "); /* Add your application code here */ /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); schedule_init(&schedule_got,schedule_string); // schedule string store in schedule_string DNS_Init(); //while(!schedule_got); // wait until string got LCD_DisplayStringLine(Line2, (uint8_t*)schedule_string); LCD_DisplayStringLine(Line3, (uint8_t*)"0"); /* Main Loop */ //process ste str form internet Str_Split(s, Init_time); // s is temp string RTC_Config(); Time_Date_Setting(Init_time->year, Init_time->mon, Init_time->day, Init_time->hour +3, Init_time->min, Init_time->sec); while (1) { uint8_t year, mon, day; uint8_t hour, min, sec; RTC_TimeTypeDef RTC_TimeStruct_main; RTC_DateTypeDef RTC_DateStruct_main; RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct_main); RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct_main); year = RTC_DateStruct_main.RTC_Year; mon = RTC_DateStruct_main.RTC_Month; day = RTC_DateStruct_main.RTC_Date; hour = RTC_TimeStruct_main.RTC_Hours; min = RTC_TimeStruct_main.RTC_Minutes; sec = RTC_TimeStruct_main.RTC_Seconds; //detect whether it is time to turn on Motor and LED, then execute it. Soak(day, hour, min ); Water(day, hour, min, sec); Light(mon, day, hour, min); //detect over /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); } }