예제 #1
0
bool check_var_value(const char* var, const char * value) {
    std::string var_str(getenv(var));
    if (var_str == value) {
        return true;
    }
    return false;
}
예제 #2
0
TEST(PackUnpack, Basic)
{
	nbase::PackBuffer pbuffer;
	nbase::Pack test_pack(pbuffer);

	EXPECT_EQ(0, test_pack.size());

	test_pack.push_uint8(8);
	test_pack.push_uint16(16);
	test_pack.push_uint32(32);
	test_pack.push_uint64(64);

	std::string input1 = "test input string 1";
	std::string input2 = "test input string 2";
	std::string input3 = "test input string 3";
	std::string input4 = "test input string 4";
	std::string input5 = "test input string 5";
	nbase::Varstr var_str(input1.data(), input1.size());
	test_pack.push_varstr(var_str);
	test_pack.push_varstr(input2.c_str());
	test_pack.push_varstr(input3);
	test_pack.push_varstr(input4.data(), input4.size());
	test_pack.push_varstr32(input5.data(), input5.size());

	nbase::Unpack test_unpack(pbuffer.data(), pbuffer.size());
	EXPECT_EQ(8, test_unpack.pop_uint8());
	EXPECT_EQ(16, test_unpack.pop_uint16());
	EXPECT_EQ(32, test_unpack.pop_uint32());
	EXPECT_EQ(64, test_unpack.pop_uint64());
	nbase::Varstr var_output1 = test_unpack.pop_varstr_ptr();
	std::string output1(var_output1.data(), var_output1.size()); 
	EXPECT_EQ(input1, output1);
	nbase::Varstr var_output2 = test_unpack.pop_varstr_ptr();
	std::string output2(var_output2.data(), var_output2.size()); 
	EXPECT_EQ(input2, output2);
	nbase::Varstr var_output3 = test_unpack.pop_varstr_ptr();
	std::string output3(var_output3.data(), var_output3.size()); 
	EXPECT_EQ(input3, output3);
	nbase::Varstr var_output4 = test_unpack.pop_varstr_ptr();
	std::string output4(var_output4.data(), var_output4.size()); 
	EXPECT_EQ(input4, output4);
	nbase::Varstr var_output5 = test_unpack.pop_varstr32_ptr();
	std::string output5(var_output5.data(), var_output5.size()); 
	EXPECT_EQ(input5, output5);	
}
예제 #3
0
파일: lcd.c 프로젝트: sde1000/fvcontroller
/* Draw the "idle" display */
void lcd_home_screen(const char *status)
{
  char buf[16];
  struct storage s;
  int32_t s_hi,s_lo;
  float tf,slf,shf;
  lcd_cmd(LCD_DISPCTL(1,0,0)); /* No cursor */
  lcd_cmd(LCD_DDADDR(ROW1));
  /* Top left is station name, up to 8 characters */
  reg_read_string(&ident,buf,9);
  var_str(buf);
  lcd_data(' ');
  /* Now current set range */
  s=reg_storage(&set_lo);
  eeprom_read_block(&s_lo,(void *)s.loc.eeprom.start,4);
  slf=s_lo/10000.0;
  s=reg_storage(&set_hi);
  eeprom_read_block(&s_hi,(void *)s.loc.eeprom.start,4);
  shf=s_hi/10000.0;
  snprintf_P(buf,16,PSTR("%0.1f-%0.1f"),(double)slf,(double)shf);
  var_str(buf);
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  /* Next line */
  lcd_cmd(LCD_DDADDR(ROW2));
  if (status) {
    strncpy_P(buf,status,16);
    fixed_str(buf,16);
  } else {
    /* Bottom left is current temp, up to 5 characters */
    if (t0_temp==BAD_TEMP) {
      sprintf_P(buf,PSTR("XXXXX"));
    } else {
      tf=t0_temp/10000.0;
      snprintf_P(buf,9,PSTR("%0.1f"),(double)tf);
    }
    fixed_str(buf,5);
    lcd_data(' ');
    
    /* Current mode */
    reg_read_string(&mode,buf,9);
    fixed_str(buf,8);
    lcd_data(' ');
    /* Bottom right is valve state as 1 character */
    switch (get_valve_state()) {
    case VALVE_CLOSED:
      buf[0]='-';
      break;
    case VALVE_OPENING:
      buf[0]='O';
      break;
    case VALVE_OPEN:
      buf[0]='|';
      break;
    case VALVE_CLOSING:
      buf[0]='C';
      break;
    case VALVE_ERROR:
      buf[0]='E';
      break;
    default:
      buf[0]='?';
      break;
    }
    fixed_str(buf,1);
  }
}