/* * received on CTRL+C or SIGTERM */ static void signal_TERM(int sig) { #ifdef HAVE_STRSIGNAL DEBUG_MSG("Signal handler... (caught SIGNAL: %d) | %s", sig, strsignal(sig)); #else DEBUG_MSG("Signal handler... (caught SIGNAL: %d)", sig); #endif /* terminate the UI */ ui_cleanup(); if (sig == SIGINT) { fprintf(stderr, "\n\nUser requested a CTRL+C... (deprecated, next time use proper shutdown)\n\n"); } else { #ifdef HAVE_STRSIGNAL fprintf(stderr, "\n\n Shutting down %s (received SIGNAL: %d | %s)\n\n", GBL_PROGRAM, sig, strsignal(sig)); #else fprintf(stderr, "\n\n Shutting down %s (received SIGNAL: %d)\n\n", GBL_PROGRAM, sig); #endif } signal(sig, SIG_IGN); /* flush and close the log file */ log_stop(); /* make sure we exit gracefully */ clean_exit(0); }
inline GCTraceTimeImpl::~GCTraceTimeImpl() { Ticks stop_ticks; time_stamp(stop_ticks); if (_enabled) { log_stop(_start_ticks.value(), stop_ticks.value()); } if (_timer != NULL) { _timer->register_gc_phase_end(stop_ticks); } }
static void server_stop(void) { #ifdef HAVE_DB db_close(); #endif analy_stop(); monitor_stop(); log_stop(); kill_close(); match_close(); spam_close(); }
void PuttyView::do_log(bool isPressed) { bool isStarted = is_session_log_enabled(puttyController_->logctx)!= 0; if (isStarted == isPressed) return; if (!isStarted) { log_restart(puttyController_->logctx, puttyController_->cfg); } else { /* Pass new config data to the logging module */ log_stop(puttyController_->logctx, puttyController_->cfg); } }
static void shrm_modem_reset_callback(unsigned long irq) { dev_err(shm_dev->dev, "Received mod_reset_req interrupt\n"); log_stop(); #ifdef CONFIG_U8500_SHRM_MODEM_SILENT_RESET { int err; dev_info(shm_dev->dev, "Initiating Modem silent reset\n"); err = shrm_modem_reset_sequence(); if (err) dev_err(shm_dev->dev, "Failed multicast of modem reset\n"); } #else dev_info(shm_dev->dev, "Modem in reset loop, doing System reset\n"); /* Call the PRCMU reset API */ prcmu_system_reset(SW_RESET_NO_ARGUMENT); #endif }
int set_loglevel(int level, char *filename) { char eci[strlen(filename)+5]; char ecp[strlen(filename)+5]; /* close any previously opened file */ log_stop(); /* if we want to stop logging, return here */ if (level == LOG_STOP) { DEBUG_MSG("set_loglevel: stopping the log process"); return E_SUCCESS; } DEBUG_MSG("set_loglevel(%d, %s)", level, filename); /* all the host type will be unknown, warn the user */ if (EC_GBL_OPTIONS->read) { USER_MSG("*********************************************************\n"); USER_MSG("WARNING: while reading form file we cannot determine \n"); USER_MSG("if an host is local or not because the ip address of \n"); USER_MSG("the NIC may have been changed from the time of the dump. \n"); USER_MSG("*********************************************************\n\n"); } snprintf(eci, strlen(filename)+5, "%s.eci", filename); snprintf(ecp, strlen(filename)+5, "%s.ecp", filename); memset(&fdp, 0, sizeof(struct log_fd)); memset(&fdi, 0, sizeof(struct log_fd)); /* open the file(s) */ switch(level) { case LOG_PACKET: if (EC_GBL_OPTIONS->compress) { fdp.type = LOG_COMPRESSED; } else { fdp.type = LOG_UNCOMPRESSED; } /* create the file */ if (log_open(&fdp, ecp) != E_SUCCESS) return -E_FATAL; /* initialize the log file */ log_write_header(&fdp, LOG_PACKET); /* add the hook point to DISPATCHER */ hook_add(HOOK_DISPATCHER, &log_packet); /* no break here, loglevel is incremental */ /* fall through */ case LOG_INFO: if (EC_GBL_OPTIONS->compress) { fdi.type = LOG_COMPRESSED; } else { fdi.type = LOG_UNCOMPRESSED; } /* create the file */ if (log_open(&fdi, eci) != E_SUCCESS) return -E_FATAL; /* initialize the log file */ log_write_header(&fdi, LOG_INFO); /* add the hook point to DISPATCHER */ hook_add(HOOK_DISPATCHER, &log_info); /* add the hook for the ARP packets */ hook_add(HOOK_PACKET_ARP, &log_info); /* add the hook for ICMP packets */ hook_add(HOOK_PACKET_ICMP, &log_info); /* add the hook for DHCP packets */ /* (fake icmp packets from DHCP discovered GW and DNS) */ hook_add(HOOK_PROTO_DHCP_PROFILE, &log_info); break; } atexit(log_stop); return E_SUCCESS; }
unsigned char log_dologging(FS_STATE *fs_state,unsigned long deviceid,unsigned long time_absolute_offset) { unsigned char rv; unsigned long int t1,t2; unsigned char breakreason; // Reason while the logging loop is interrupted. 0: user interruption. 1: log errors unsigned char ln; rv = log_start(fs_state,deviceid,time_absolute_offset,&ln); if(rv) return rv; printf_P(PSTR("Logging in entry %d\r"),ln); t1 = t2 = timer_ms_get(); _log_numerr=0; uart_setblocking(file_usb,0); while(1) { // Log packets to MMC _log_numerr += log_logpacket(fs_state); // Display more detailed infos at regular intervals if(timer_ms_get()>t2) { sample_printstat(); pkt_printstat(); printf_P(PSTR("Cumulative log errors: %03d"),_log_numerr); t2+=501; } if(_log_numerr>1000) { breakreason=1; break; } int c; if((c=fgetc(file_usb))!=EOF) { breakreason=0; break; } } uart_setblocking(file_usb,1); _delay_ms(100); flush(file_usb); log_stop(fs_state); if(breakreason==1) { printf_P(PSTR("Interrupted due to too many logging errors\r")); return 2; } if(breakreason==0) printf_P(PSTR("User stopped recording\r")); return 0; }
/*Control Layout: Controller 1: Left Joystick x/y - Strafe and forward for robot Right Joystick x - Turn Button 1: Goal Latch Closed Button 3: Goal Latch Open Button 4: Gyro Reset Button 8: Slo-Mo Controller 2: Button 1: Blower Button 2: Intake Button 3: Ball storage Button 4: Kickstand Button 5: Intake slow (lift release) Button 6: Intake backwards Button 7: Touch sensor Timers: T1:Gyro T2:Measure RPM T3:Blower T4:Global */ task main() { float leftFront, leftBack, rightFront, rightBack; // motors float y, x, c; bool touchsensorenabled = false; bool blowerenabled = false; bool kickstandenabled = false; bool storageclosed = false; bool intakeenabled = false; bool estop = false; bool intakestartup = false; long intakelastchecked = -10000; int joy1Btn3last = 0; int joy1Btn2last = 0; int joy1Btn1last = 0; //Operator int joy2Btn1last = 0; int joy2Btn2last = 0; int joy2Btn3last = 0; int joy2Btn4last = 0; int power = 100; //power for drive motors /***** BEGIN Mecanum Field Oriented Drive Test *****/ init(); StartTask(readSensors); StartTask(displaySmartDiags); if (bCompetitionMode) {waitForStart();} ClearTimer(T4); tele_log_init(); while (true) { /***** Proportional Motor Control *****/ getJoystickSettings(joystick); //get all joystick statuses if (joy1Btn(8)) { power = 25; } else { power = 100; } //Drive Code if ((deadband(k_deadband,joystick.joy1_y1) == 0 && deadband(k_deadband,joystick.joy1_x1) == 0 && deadband(k_deadband,joystick.joy1_x2) == 0)) { motor[Lf] = 0; motor[Rf] = 0; motor[Lb] = 0; motor[Rb] = 0; } else { //scale to -1 to 1 y = ((deadband(k_deadband,joystick.joy1_y1)+1)/128); //strafe x = ((deadband(k_deadband,joystick.joy1_x1)+1)/128); //forward/rev c = ((deadband(k_deadband,joystick.joy1_x2)+1)/128); //spin mecanum_arcadeFOD(y, x, c, gyro_getheading(), leftFront, rightFront, leftBack, rightBack); motor[Lf] = leftFront*power; motor[Rf] = rightFront*power; motor[Lb] = leftBack*power; motor[Rb] = rightBack*power; } //Gyro Reset Code if(joy1Btn(4) == 1) { gyro_reset(); } if(joystick.joy1_TopHat == 0) { gyro_reset(); } //90 Deg if(joystick.joy1_TopHat == 2) { gyro_reset(); gyro_set(90); } //180 Deg if(joystick.joy1_TopHat == 4) { gyro_reset(); gyro_set(180); } //270 Deg if(joystick.joy1_TopHat == 6) { gyro_reset(); gyro_set(270); } if(nNxtButtonPressed == kEnterButton) { gyro_reset(); } if (joy1Btn(7) == 1){ servo[GoalRetainer] = 255; } //Goal Latch Open if(joy1Btn(3)== 1 && joy1Btn3last != 1){ servo[GoalRetainer] = 130; } //Goal Latch Closed if(joy1Btn(1)== 1 && joy1Btn1last != 1){ servo[GoalRetainer] = 5; } //Blower Toggle if(joy2Btn(1)== 1 && joy2Btn1last != 1){ if (blowerenabled){ motor[BlowerA] = 1; motor[BlowerB] = 1; motor[BlowerC] = 1; //Start timer for 1 sec, then set motors to 0 ClearTimer(T3); blowerenabled = false; log_write("BL","OFF"); } else{ ClearTimer(T2); nMotorEncoder[BlowerB] = 0; motor[BlowerA] = 100; motor[BlowerB] = 100; motor[BlowerC] = 100; blowerenabled = true; log_write("BL","ON"); } } //If 5 seconds since blower shutdown-brake motors if (time1[T3] > 5000 && !blowerenabled){ motor[BlowerA] = 0; motor[BlowerB] = 0; motor[BlowerC] = 0; } //Intake Forwards, back, slow forward if (joy2Btn(2) && joy2Btn2last != 1){ if (intakeenabled){ intakeenabled = false; log_write("IN","OFF"); } else{ intakelastchecked = -10000; nMotorEncoder[Rf] = 4000; intakeenabled = true; intakestartup = true; log_write("IN","ON"); } } int nIntakeHealthyVal = 400; if (joy2Btn(5) == 1){ motor[Intake] = 25; } else if (joy2Btn(6) == 1){ motor[Intake] = -100; } else if (joy2Btn(7) == 1){ motor[Intake] = 100; } else if (joy2Btn(8) == 1){ motor[Intake] = -50; } else if (!intakeenabled){ motor[Intake] = 0; } else if (intakeenabled && time1[T4] > intakelastchecked+500){ if (abs(nMotorEncoder[Rf]) > nIntakeHealthyVal || intakestartup){ motor[Intake] = 100; intakestartup = false; } else { motor[Intake] = -100; } nMotorEncoder[Rf] = 0; intakelastchecked = time1[T4]; } //Storage Toggle if(joy2Btn(3)== 1 && joy2Btn3last != 1){ if (storageclosed){ servo[BallStorage] = 80; storageclosed = false; } else{ servo[BallStorage] = 140; storageclosed = true; } } //Kickstand Toggle if(joy2Btn(4)== 1 && joy2Btn4last != 1){ if (kickstandenabled){ servo[Kickstand] = 155; kickstandenabled = false; } else{ servo[Kickstand] = 31; kickstandenabled = true; } } //Touch Sensor Toggle if(joy1Btn(2)== 1 && joy1Btn2last != 1){ if (touchsensorenabled){ servo[TouchSensor] = 65; touchsensorenabled = false; } else{ servo[TouchSensor] = 190; touchsensorenabled = true; } } //E Stop for blower if (!estop && time1[T4] > 117000 && blowerenabled){ motor[BlowerA] = 1; motor[BlowerB] = 1; motor[BlowerC] = 1; //Start timer for 1 sec, then set motors to 0 ClearTimer(T3); blowerenabled = false; estop = true; } else if (time1[T4] >117000){ log_stop(); } //VOLTAGE if (time100[T2] >= 20) { float v = (float)externalBatteryAvg / (float)1000; string sv = ""; StringFormat(sv, "%1.2f", v); log_write("V", sv); if (blowerenabled) { float dEncoderCount = nMotorEncoder[BlowerB]; float dTime = time1[T2]; float rpm = (4439 * (dEncoderCount))/(dTime); string s = ""; StringFormat(s,"RPM: %1.2f",rpm); nxtDisplayTextLine(5, s); log_write("BL",s); nMotorEncoder[BlowerB] = 0; } //Clear for next calculation ClearTimer(T2); } //Winch if (deadband(k_deadband,joystick.joy2_y2) == 0){ servo[TubeWinch] = 127; } else{ servo[TubeWinch] = (deadband(k_deadband,joystick.joy2_y2))+127; } joy1Btn1last = joy1Btn(1); joy1Btn2last = joy1Btn(2); joy1Btn3last = joy1Btn(3); joy2Btn1last = joy2Btn(1); joy2Btn2last = joy2Btn(2); joy2Btn3last = joy2Btn(3); joy2Btn4last = joy2Btn(4); //DO NOT REMOVE THIS WAIT, See issue #11 nxtDisplayTextLine(4, "%i", gyro_getheading()); wait1Msec(5); } }