msg_t mission_thread(void* arg) { (void)arg; state_t cur_state = STATE_PAD; state_t new_state; instance_data_t data; data.t_launch = data.t_last_ignition = data.t_last_burnout = 0; data.current_stage_position = STAGE; data.state = state_estimation_get_state(); data.h_pad = data.state.h; log_f(CHAN_CAL_PAD, data.h_pad, 0.0f); log_s32(CHAN_SM_MISSION, cur_state, cur_state); chRegSetThreadName("Mission"); while(1) { /* Run Kalman prediction step */ data.state = state_estimation_get_state(); /* Run state machine's current state function */ new_state = run_state(cur_state, &data); /* Log changes in state */ if(new_state != cur_state) { log_s32(CHAN_SM_MISSION, (int32_t)cur_state, (int32_t)new_state); cur_state = new_state; } /* Tick the state machine about every millisecond */ chThdSleepMilliseconds(1); } }
int main() { u8 good[] = {0xa5, 0x00, 0xa5, 0xa5, 0x22, 0x04, 0x38, 0x01, 0x03, 0x42, 0x00, 0xef, 0xbe}; u8 arr[]={1,2,3} ; u8 buff[1024]; u8 len=0; u8 type = 0x34; run_state((void *)good, sizeof(good)/sizeof(good[0])); //printf("%x\n", *(u16 *)&good[7]); //printf("%x\n", *(u16 *)&good[1]); printf("%x\n", *(u16*)&repository[1]); printf("%x\n", ip); make_pack(arr, 3, type, buff, &len); run_state((void *)buff, len); printf("[%d]\n", len); printf("%x\n", *(u16*)&repository[0]); printf("%x\n", ip); }
// -------------------------------------------------------- // // implementation of BFileInterface // -------------------------------------------------------- // status_t MediaReader::SetRef( const entry_ref & file, bool create, bigtime_t * out_time) { CALLED(); status_t status = AbstractFileInterfaceNode::SetRef(file,B_READ_ONLY,create,out_time); if (status != B_OK) { PRINT("AbstractFileInterfaceNode::SetRef returned an error\n"); return status; } if (output.destination == media_destination::null) { // reset the format, and set the requirements imposed by this file GetFormat(&output.format); AddRequirements(&output.format); return B_OK; } // if we are connected we may have to re-negotiate the connection media_format format; GetFormat(&format); AddRequirements(&format); if (format_is_acceptible(format,output.format)) { fprintf(stderr," compatible format = no re-negotiation necessary\n"); return B_OK; } // first try the easy way : SORRY DEPRECATED into private :-( // this code from MediaWriter would be different for MediaReader even if it worked... // int32 change_tag = NewChangeTag(); // status = this->BBufferConsumer::RequestFormatChange(output.source,output.destination,&format,&change_tag); // if (status == B_OK) { // fprintf(stderr," format change successful\n"); // return B_OK; // } // okay, the hard way requires we get the MediaRoster BMediaRoster * roster = BMediaRoster::Roster(&status); if (roster == 0) return B_MEDIA_SYSTEM_FAILURE; if (status != B_OK) return status; // before disconnect one should always stop the nodes (bebook says) // requires run_state cast since the return type on RunState() is // wrong [int32] run_state destinationRunState = run_state(RunState()); if (destinationRunState == BMediaEventLooper::B_STARTED) Stop(0,true); // stop us right now // should also stop the destination if it is running, but how? /* BMediaNode destinationNode = ?? run_state destinationRunState = destinationNode->??; status = destinationNode->StopNode(??,0,true); if (status != B_OK) { return status; } */ // we should disconnect right now media_destination outputDestination = output.destination; status = roster->Disconnect(output.source.id,output.source, output.destination.id,output.destination); if (status != B_OK) return status; // if that went okay, we'll try reconnecting media_output connectOutput; media_input connectInput; status = roster->Connect(output.source,outputDestination, &format,&connectOutput,&connectInput); if (status != B_OK) return status; // now restart if necessary if (destinationRunState == BMediaEventLooper::B_STARTED) { Start(0); } return status; }