bool ReflowParametersStorage::read(ReflowParameters& params) { // the flash device deals in pages even though we require far less // than that. uint32_t page[64]; // declare the flash device Flash flash; // read the last page memset(page,0,sizeof(page)); if(!flash.readLastPage(reinterpret_cast<uint8_t *>(page))) return false; // check the magic number if(page[0]!=0xDEADBEEF) return false; // bit-copy out the parameters memcpy(¶ms,&page[1],sizeof(params)); // completed OK return true; }
FlashInstance* FlashManager::create(string name, CreateAdapter* adapter) { Flash* conf = find(name); if(conf == 0) { return 0; } return conf->createInstance(adapter == 0 ? emptyAdapter : adapter); }
bool ReflowParametersStorage::write(const ReflowParameters& params) { // the flash device deals in pages even though we require far less // than that. uint32_t page[64]; // copy in the magic number page[0]=0xDEADBEEF; // bit-copy in the ReflowParameters structure memcpy(&page[1],¶ms,sizeof(params)); // declare the flash device Flash flash; // erase the last page if(!flash.eraseLastSector()) return false; // write the last page return flash.writeLastPage(reinterpret_cast<const uint8_t *>(page)); }
int main() { cout << "Hello EGit !!!" << endl; cout << "You are so fantastic!" << endl; int i = 123; cout << "feature2 = " << i << endl; cout << "Feature1 has to be printed!" << endl; cout << "rebase0 testing" << endl; A a; a.dump(); AA aa; aa.dump(); BB bb; bb.dump(); cout << "Let's make feature 2 as HEAD" << endl; CC cc; cc.dump(); cout << "What are you doing, master!" << endl; Flash f; f.flashing(); Flash f1; f1.flashing(); return 0; }
Flash *Flash::Clone(bool prototype) { Flash *c = ComponentPool<Flash>::Get()->Create(); c->Init(movie); c->meshScale = meshScale; c->scaleMatrix = scaleMatrix; c->bounds = bounds; return c; }
int main() { Blink blink; Flash flash; Zigbee zigbee; clock_begin(); // usart1.init(0x33, true); usart1.init(12, true); // usart1.setTrigger(';'); // usart1.setTriggerTime(60); // _delay_ms(1000); blink.start(0); usart1.send("zigbee_ready(a);"); _delay_ms(50); while ((addr_a = zigbee.addr()) == 0xfffe) { blink.onloop(); _delay_ms(100); } flash.start(0); while (!got_addr) { flash.onloop(); // usart1.send("zigbee_ready(a);"); _delay_ms(1000); checkCmd(usart1); } // while (addr_b == 0xfffe) // { // flash.onloop(); // checkCmd(usart1); // _delay_ms(500); // } // usart1.send("got(a);"); // _delay_ms(500); // lcd.dis("Waiting..."); // usart1.send("zigbee_ready(a);"); DDRA = 0xff; PORTA = 0x02; while (1) { motor.onloop(); checkCmd(usart1); } }
static Chan* flashattach(char *spec) { Flash *f; int bank; Chan *c; bank = strtol(spec, nil, 0); if(bank < 0 || bank >= Nbanks || (f = flash.card[bank]) == nil || f->attach != nil && f->attach(f) < 0) error(Enodev); c = devattach('F', spec); c->dev = bank; return c; }
static void flashreset(void) { Flash *f; Flashtype *t; char *e; int bank; for(bank = 0; bank < Nbanks; bank++){ f = malloc(sizeof(*f)); if(f == nil){ print("#F%d: can't allocate Flash data\n", bank); return; } f->cmask = ~(ulong)0; if(archflashreset(bank, f) < 0 || f->type == nil || f->addr == nil){ free(f); return; } for(t = flash.types; t != nil; t = t->next) if(strcmp(f->type, t->name) == 0) break; if(t == nil){ iprint("#F%d: no flash driver for type %s (addr %p)\n", bank, f->type, f->addr); free(f); return; } f->reset = t->reset; f->protect = 1; if(f->reset(f) == 0){ flash.card[bank] = f; iprint("#F%d: %s addr %#p len %lud width %d interleave %d\n", // bank, f->type, PADDR(f->addr), f->size, bank, f->type, f->addr, f->size, f->width, f->interleave); e = flashnewpart(f, "flash", 0, f->size); if(e != nil) panic("#F%d: couldn't init table: %s", bank, e); }else iprint("#F%d: %#p: reset failed (%s)\n", bank, f->addr, f->type); } }
int main(int argc, char **argv) { DeviceManager manager; Flash flash; if(argc != 3) { usage(argv[0]); return 0; } string action = argv[1]; if(action != "dump" && action != "flash") { cout << "Invalid action!" << endl; usage(argv[0]); return 0; } if(!UsbProgrammer::getProgrammer()->IsInitialized()) { cout << "Cannot connect to programmer!" << endl; return 1; } if(!manager.IsSupported()) { cout << "Device is NOT supported!" << endl; return 1; } if(action == "dump") { if(!flash.dump(argv[2])) { cout << "Dumping failed!" << endl; return 1; } } else if(action == "flash"){ cout << "Action currently not supported!" << endl; } manager.XapResetAndGo(); return 0; }
Flash* FlashManager::load(string name, string path) { // find if already loaded map<string, Flash*>::iterator findItor = configs.find(name); if(findItor != configs.end()) { Flash* previous = findItor->second; // if config has already loaded if(previous->getPath() == path) { return previous; } else { configs.erase(findItor); delete previous; } } Flash* flash = loader->load(path); if(flash == 0) { return 0; } // save the newly loaded config flash->setPath(path); configs.insert(map<string, Flash*>::value_type(name, flash)); return flash; }
int main(int argc,char **argv) { //Set default values bool forking = false; int port = 8080; int rtmpPort = 1935; const char *logfile = "mcu.log"; const char *pidfile = "mcu.pid"; //Get all for(int i=1;i<argc;i++) { //Check options if (strcmp(argv[i],"-h")==0 || strcmp(argv[i],"--help")==0) { //Show usage printf("Usage: mcu [-h] [--help] [--mcu-log logfile] [--mcu-pid pidfile] [--http-port port] [--rtmp-port port]\r\n\r\n" "Options:\r\n" " -h,--help Print help\r\n" " -f Run as daemon in safe mode\r\n" " --mcu-log Set mcu log file path (default: mcu.log)\r\n" " --mcu-pid Set mcu pid file path (default: mcu.pid)\r\n" " --http-port Set HTTP xmlrpc api port\r\n" " --rtmp-port Set RTMP xmlrpc api port\r\n"); //Exit return 0; } else if (strcmp(argv[i],"-f")==0) //Fork forking = true; else if (strcmp(argv[i],"--http-port")==0 && (i+1<argc)) //Get port port = atoi(argv[++i]); else if (strcmp(argv[i],"--rtmp-port")==0 && (i+1<argc)) //Get rtmp port rtmpPort = atoi(argv[++i]); else if (strcmp(argv[i],"--mcu-log")==0 && (i+1<argc)) //Get rtmp port logfile = argv[++i]; else if (strcmp(argv[i],"--mcu-pid")==0 && (i+1<argc)) //Get rtmp port pidfile = argv[++i]; } //Loop while(forking) { //Create the chld pid_t pid = fork(); // fork error if (pid<0) exit(1); // parent exits if (pid>0) exit(0); //Log printf("MCU started\r\n"); //Create the safe child pid = fork(); //Check pid if (pid==0) { //It is the child obtain a new process group setsid(); //for each descriptor for (int i=getdtablesize();i>=0;--i) //Close it close(i); //Redirect stdout and stderr int fd = open(logfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); dup(fd); dup2(1,2); close(fd); //And continule break; } else if (pid<0) //Error return 0; //Pid string char spid[16]; //Print it sprintf(spid,"%d",pid); //Write pid to file int pfd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); //Write it write(pfd,spid,strlen(spid)); //Close it close(pfd); int status; do { //Wait for child if (waitpid(pid, &status, WUNTRACED | WCONTINUED)<0) return -1; //If it has exited or stopped if (WIFEXITED(status) || WIFSTOPPED(status)) //Exit return 0; //If we have been killed if (WIFSIGNALED(status) && WTERMSIG(status)==9) //Exit return 0; } while (!WIFEXITED(status) && !WIFSIGNALED(status)); } //Dump core on fault rlimit l = {RLIM_INFINITY,RLIM_INFINITY}; //Set new limit setrlimit(RLIMIT_CORE, &l); //Register mutext for ffmpeg av_lockmgr_register(lock_ffmpeg); //Set log level av_log_set_callback(log_ffmpeg); //Ignore SIGPIPE signal( SIGPIPE, SIG_IGN ); //Create servers XmlRpcServer server(port); RTMPServer rtmpServer; // Live555MediaServer* rtspServer = Live555MediaServer::Instance(); //Create services MCU mcu; Broadcaster broadcaster; MediaGateway mediaGateway; JSR309Manager jsr309Manager; //Create xml cmd handlers for the mcu and broadcaster XmlHandler xmlrpcmcu(mcuCmdList,(void*)&mcu); XmlHandler xmlrpcbroadcaster(broadcasterCmdList,(void*)&broadcaster); XmlHandler xmlrpcmediagateway(mediagatewayCmdList,(void*)&mediaGateway); XmlHandler xmlrpcjsr309(jsr309CmdList,(void*)&jsr309Manager); //Create http streaming for service events XmlStreamingHandler xmleventjsr309; XmlStreamingHandler xmleventmcu; //And default status hanlder StatusHandler status; //Init de mcu mcu.Init(&xmleventmcu); //Init the broadcaster broadcaster.Init(); //Init the media gateway mediaGateway.Init(); //INit the jsr309 jsr309Manager.Init(&xmleventjsr309); //Add the rtmp application from the mcu to the rtmp server rtmpServer.AddApplication(L"mcu/",&mcu); //Add the rtmp applications from the broadcaster to the rmtp server rtmpServer.AddApplication(L"broadcaster/publish",&broadcaster); rtmpServer.AddApplication(L"broadcaster",&broadcaster); rtmpServer.AddApplication(L"streamer/mp4",&broadcaster); rtmpServer.AddApplication(L"streamer/flv",&broadcaster); //Add the rtmp applications from the media gateway rtmpServer.AddApplication(L"bridge/input",&mediaGateway); rtmpServer.AddApplication(L"bridge/output",&mediaGateway); //Append mcu cmd handler to the http server server.AddHandler(string("/mcu"),&xmlrpcmcu); server.AddHandler(string("/broadcaster"),&xmlrpcbroadcaster); server.AddHandler(string("/mediagateway"),&xmlrpcmediagateway); server.AddHandler(string("/jsr309"),&xmlrpcjsr309); server.AddHandler(string("/events/jsr309"),&xmleventjsr309); server.AddHandler(string("/events/mcu"),&xmleventmcu); #ifdef FLASHSTREAMER Flash flash; flash.Init(); XmlHandler xmlrpcFlash(flashCmdList,(void*)&flash); //Append flash cmldhandler server.AddHandler(string("/flash"),&xmlrpcFlash); #endif //Add the html status handler server.AddHandler(string("/status"),&status); //Init the rtmp server rtmpServer.Init(rtmpPort); // rtsp addon by liuhong // Init and start rtsp server //rtspServer->Init(); //Run it server.Start(); //End the rtmp server rtmpServer.End(); //End the mcu mcu.End(); //End the broadcaster broadcaster.End(); //End the media gateway mediaGateway.End(); //End the jsr309 jsr309Manager.End(); #ifdef FLASHSTREAMER //End flash player flash.End(); #endif }