Exemplo n.º 1
0
bool WPUtils::info_registered()
{
	QDir home = QDir::home();
	QFile file(home.absoluteFilePath(dbName));
	SqlDataAccess sda(home.absoluteFilePath(dbName));//QDir::currentPath() + "/data/wpbb10.db");
	QVariant list = sda.execute("SELECT * FROM userinfo");
	return (list.toList().size() > 0);
}
intrusive_ref_ptr<DevFs> //return value is a pointer to DevFs
#else //WITH_DEVFS
void                     //return value is void
#endif //WITH_DEVFS
basicFilesystemSetup(intrusive_ref_ptr<Device> dev)
{
    bootlog("Mounting MountpointFs as / ... ");
    FilesystemManager& fsm=FilesystemManager::instance();
    intrusive_ref_ptr<FilesystemBase> rootFs(new MountpointFs);
    bootlog(fsm.kmount("/",rootFs)==0 ? "Ok\n" : "Failed\n");
    
    #ifdef WITH_DEVFS
    bootlog("Mounting DevFs as /dev ... ");
    StringPart sp("dev");
    int r1=rootFs->mkdir(sp,0755); 
    intrusive_ref_ptr<DevFs> devfs(new DevFs);
    int r2=fsm.kmount("/dev",devfs);
    bool devFsOk=(r1==0 && r2==0);
    bootlog(devFsOk ? "Ok\n" : "Failed\n");
    if(!devFsOk) return devfs;
    fsm.setDevFs(devfs);
    #endif //WITH_DEVFS
    
    bootlog("Mounting Fat32Fs as /sd ... ");
    bool fat32failed=false;
    intrusive_ref_ptr<FileBase> disk;
    #ifdef WITH_DEVFS
    if(dev) devfs->addDevice("sda",dev);
    StringPart sda("sda");
    if(devfs->open(disk,sda,O_RDWR,0)<0) fat32failed=true;
    #else //WITH_DEVFS
    if(dev && dev->open(disk,intrusive_ref_ptr<FilesystemBase>(0),O_RDWR,0)<0)
        fat32failed=true;
    #endif //WITH_DEVFS
    
    intrusive_ref_ptr<Fat32Fs> fat32;
    if(fat32failed==false)
    {
        fat32=new Fat32Fs(disk);
        if(fat32->mountFailed()) fat32failed=true;
    }
    if(fat32failed==false)
    {
        StringPart sd("sd");
        fat32failed=rootFs->mkdir(sd,0755)!=0;
        fat32failed=fsm.kmount("/sd",fat32)!=0;
    }
    bootlog(fat32failed==0 ? "Ok\n" : "Failed\n");
    
    #ifdef WITH_DEVFS
    return devfs;
    #endif //WITH_DEVFS
}
Exemplo n.º 3
0
Arquivo: i2c.cpp Projeto: 980f/cortexm
void I2C::configurePins(bool withSmb){
  Pin sda(B, pinbase + 1);
  Pin scl(B, pinbase);
  *sda.writer() = 1;
  *scl.writer() = 1;
  if(pinbase == 8) {
    theAfioManager.b->i2c1 = 1;
  }
  sda.FN(50, true); //todo:3 set edge rate by frequency.
  scl.FN(50, true);
  if(withSmb && pinbase == 10) { //only i2c2 supports smb interrupt
    Pin(B, 12).DI('U');
  }
} /* configurePins */
Exemplo n.º 4
0
//==============================================================================
static void ICACHE_FLASH_ATTR spi(uint8_t cd,uint8_t myData)
{
	//os_printf(myData);
char i;
	cs(0);// = 0;
	sclk(0);// = 0;
	sda(cd);// = cd;
	os_delay_us(14);
	sclk(1);// = 1;

for(i=0;i<8;i++){
		sclk(0); //= 0;
			if(myData & 0x80)
				sda(1)// = 1;
			else
				sda(0);// = 0;
			os_delay_us(14);
		
		myData <<= 1;
		sclk(1);// = 1;
		os_delay_us(14);
				}
		cs(1);// = 1;
}
Exemplo n.º 5
0
int main()
{
    DiscoveryBoard board;
    RTOS::Time t(board.Tim7);
    LedAngleDisplay display (board);
    Platform::Gpio scl(board.GpioB[6]);
    Platform::Gpio sda(board.GpioB[7]);
    Platform::I2C bus(scl, sda, Platform::I2C::I2C_1);
    uint8_t target_reg = 0x01;
    uint8_t compass_address = 0b01100000;
    while(1)
    {
        bus.write(compass_address, &target_reg, 1);
        uint8_t data;
        t.msleep(10);
        bus.read(compass_address, &data, 1);
        display.setValue(data);
        t.msleep(100);
    }
}
Exemplo n.º 6
0
void ProcessGraph::establishDirection(){
	for (int i=0; i<this->numNodes; i++){
		ProcessGraphNode *pgn = this->nodes[i];
		/*
		 *	establish direction of streams
		 */
		std::cout<<"----------------------------------------------"<<std::endl;
		clang::CallExpr *e=dyn_cast<clang::CallExpr>(pgn->getExpr());
		clang::DeclRefExpr *fun = getProcessFunction(e->getArg(1));
		clang::FunctionDecl *funD = dyn_cast<clang::FunctionDecl>(fun->getDecl());
		StreamDirectionAnalyzer sda(funD,SM);
		sda.Visit(funD->getBody());
		std::vector<DataStream *> *prstreams = pgn->getStreams();
		std::vector<int> *dirstreams = sda.getDirections();
		std::cout << pgn->getName() <<" ";
		for (int j=0; j<prstreams->size(); j++){
			std::cout << (*dirstreams)[j] << " ";

			if ((*dirstreams)[j]==read_stream && (*prstreams)[j]->getStartProcess()==pgn){
				std::cout<<"\nreversed read "<<(*prstreams)[j]->getStartProcess()->getName()<<","<<
										(*prstreams)[j]->getEndProcess()->getName()<<" "<<
												(*prstreams)[j]->getVarDecl()->getNameAsString()<<"\n";
				(*prstreams)[j]->reverse();
			}else
			if ((*dirstreams)[j]==write_stream && (*prstreams)[j]->getEndProcess()==pgn)
			{
				std::cout<<"\nreversed write "<<(*prstreams)[j]->getStartProcess()->getName()<<","<<
														(*prstreams)[j]->getEndProcess()->getName()<<" "<<
																(*prstreams)[j]->getVarDecl()->getNameAsString()<<"\n";
				(*prstreams)[j]->reverse();

			}

		}
		std::cout<<"\n";
		std::cout<<"----------------------------------------------"<<std::endl;
	}
	std::cout << "Finished orientation of process graph\n";
}
Exemplo n.º 7
0
void WPUtils::init()
{
	QDir home = QDir::home();
	QFile file(home.absoluteFilePath(dbName));
	if (!file.exists() && file.open(QIODevice::ReadWrite) )
	{
		SqlDataAccess sda(home.absoluteFilePath(dbName));
		sda.execute("CREATE TABLE userinfo(blogid TEXT, id INTEGER PRIMARY KEY, username TEXT, password BLOB, xmlrpc BLOB);");
	}
	/*
	 * load crypt/decrypt stuff
	 */
	QSettings settings;
	if (!settings.contains("key")) {
		settings.setValue("key",generate());
	}
	if (!settings.contains("iv")) {
		settings.setValue("iv",generate());
	}
	_key = settings.value("key").toString();
	_iv = settings.value("iv").toString();
	/*****/

	_position = 0; // <<== WTF?
	_info_registered = true;
	_db = QSqlDatabase::addDatabase("QSQLITE");
	_db.setDatabaseName(home.absoluteFilePath(dbName));
	if (!_db.open())
	{
		qDebug() << "db not opened!";
		_info_registered = false;
		/* FIXIT */
	}
	if (!info_registered())
		_info_registered = false;
	else {
		getRegisteredData();
	}
}