Merge branch 'dev' into dev_i2c

This commit is contained in:
Felix Ruess
2012-03-22 09:16:37 +01:00
73 changed files with 17609 additions and 172 deletions
+10
View File
@@ -170,3 +170,13 @@
# Mac OS X # Mac OS X
.DS_Store .DS_Store
sw/ground_segment/lpc21iap/lpc21iap.dSYM/Contents/Info.plist
sw/ground_segment/lpc21iap/lpc21iap.dSYM/Contents/Resources/DWARF/lpc21iap
tests/results/*
sw/logalizer/plotprofile.dSYM/Contents/Resources/DWARF/plotprofile
sw/logalizer/plotprofile.dSYM/Contents/Info.plist
+6 -3
View File
@@ -238,6 +238,7 @@ clean:
$(Q)find . -mindepth 2 -name Makefile -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \; $(Q)find . -mindepth 2 -name Makefile -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
$(Q)find . -name '*~' -exec rm -f {} \; $(Q)find . -name '*~' -exec rm -f {} \;
$(Q)rm -f paparazzi sw/simulator/launchsitl $(Q)rm -f paparazzi sw/simulator/launchsitl
$(Q)rm -rf tests/results/*
cleanspaces: cleanspaces:
find ./sw/airborne -name '*.[ch]' -exec sed -i {} -e 's/[ \t]*$$//' \; find ./sw/airborne -name '*.[ch]' -exec sed -i {} -e 's/[ \t]*$$//' \;
@@ -258,9 +259,6 @@ dist_clean_irreversible: clean
ab_clean: ab_clean:
find sw/airborne -name '*~' -exec rm -f {} \; find sw/airborne -name '*~' -exec rm -f {} \;
test_all_example_airframes: replace_current_conf_xml
for ap in `grep name conf/conf.xml.example | sed -e 's/.*name=\"//' | sed -e 's/".*//'`; do for airframe in `grep $$ap conf/conf.xml.example | sed -e 's/.*airframe=\"//' | sed -e 's/".*//'`; do for target in `grep target conf/$$airframe | grep name | sed -e 's/.*name=\"//' | sed -e 's/\".*//'`; do echo "Making $$ap $$target"; make -C ./ AIRCRAFT=$$ap clean_ac $$target.compile || exit 1; done; done; done
replace_current_conf_xml: replace_current_conf_xml:
test conf/conf.xml || mv conf/conf.xml conf/conf.xml.backup.`date +%Y%m%d-%H%M%s` test conf/conf.xml || mv conf/conf.xml conf/conf.xml.backup.`date +%Y%m%d-%H%M%s`
cp conf/conf.xml.example conf/conf.xml cp conf/conf.xml.example conf/conf.xml
@@ -275,4 +273,9 @@ sw/simulator/launchsitl:
cat src/$(@F) | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@ cat src/$(@F) | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@ chmod a+x $@
test: all replace_current_conf_xml
cd tests; $(MAKE) $(@)
test_all_example_airframes: replace_current_conf_xml
cd tests; $(MAKE) $(@) TARGET_BOARD=examples
+4 -1
View File
@@ -82,6 +82,9 @@ OOCD = $(shell if test -e $(TOOLCHAIN_DIR)/bin/openocd ; then echo $(TOOLCHAIN_D
endif endif
endif endif
ifneq ($(BOARD_SERIAL),)
OOCD_OPTIONS = -c "ft2232_serial $(BOARD_SERIAL)"
endif
LOADER=/home/poine/work/stm32/stm32loader-a3c51c26ad6c/stm32loader.py LOADER=/home/poine/work/stm32/stm32loader-a3c51c26ad6c/stm32loader.py
@@ -258,7 +261,7 @@ upload: $(OBJDIR)/$(TARGET).elf
@echo "Using OOCD = $(OOCD)" @echo "Using OOCD = $(OOCD)"
@echo " OOCD\t$<" @echo " OOCD\t$<"
$(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
-f board/$(OOCD_BOARD).cfg \ -f board/$(OOCD_BOARD).cfg $(OOCD_OPTIONS) \
-c init \ -c init \
-c "reset halt" \ -c "reset halt" \
-c "reset init" \ -c "reset init" \
@@ -1,2 +1,192 @@
<!--
This airframe is connected to the build server and is used for hardware testing.
The hardware configuration is
Powered via a plug 12V pack
Lisa/L v1.1 board
XBee connected to UART2 configured at 38400
Aspirin v1.5
overo
-->
<airframe name="TestConfig"> <airframe name="TestConfig">
<firmware name="fixedwing">
<target name="sim" board="pc"/>
<target name="ap" board="lisa_l_1.1">
<configure name="PERIODIC_FREQUENCY" value="120"/>
</target>
<subsystem name="radio_control" type="ppm"/>
<subsystem name="telemetry" type="xbee_api">
<configure name="MODEM_BAUD" value="B38400"/>
</subsystem>
<subsystem name="control"/>
<subsystem name="imu" type="ppzuav"/>
<subsystem name="ahrs" type="float_dcm"/>
<subsystem name="navigation"/>
</firmware>
<servos>
<servo name="MOTOR" no="0" min="1000" neutral="1000" max="2000"/>
<servo name="AILEVON_LEFT" no="1" min="1900" neutral="1534" max="1100"/>
<servo name="AILEVON_RIGHT" no="2" min="1100" neutral="1468" max="1900"/>
</servos>
<commands>
<axis name="THROTTLE" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="PITCH" failsafe_value="0"/>
</commands>
<rc_commands>
<set command="THROTTLE" value="@THROTTLE"/>
<set command="ROLL" value="@ROLL"/>
<set command="PITCH" value="@PITCH"/>
</rc_commands>
<section name="MIXER">
<define name="AILEVON_AILERON_RATE" value="0.45"/>
<define name="AILEVON_ELEVATOR_RATE" value="0.8"/>
</section>
<command_laws>
<let var="aileron" value="@ROLL * AILEVON_AILERON_RATE"/>
<let var="elevator" value="@PITCH * AILEVON_ELEVATOR_RATE"/>
<set servo="MOTOR" value="@THROTTLE"/>
<set servo="AILEVON_LEFT" value="$elevator + $aileron"/>
<set servo="AILEVON_RIGHT" value="$elevator - $aileron"/>
</command_laws>
<section name="AUTO1" prefix="AUTO1_">
<define name="MAX_ROLL" value="50" unit="deg"/>
<define name="MAX_PITCH" value="35" unit="deg"/>
</section>
<section name="BAT">
<define name="LOW_BAT_LEVEL" value="10.5" unit="V"/>
<define name="CRITIC_BAT_LEVEL" value="10" unit="V"/>
<define name="CATASTROPHIC_BAT_LEVEL" value="9.1" unit="V"/>
</section>
<section name="FAILSAFE" prefix="FAILSAFE_">
<define name="DELAY_WITHOUT_GPS" value="2" unit="s"/>
<define name="DEFAULT_THROTTLE" value="0.3" unit="%"/>
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
<define name="HOME_RADIUS" value="100" unit="m"/>
</section>
<section name="MISC">
<define name="NOMINAL_AIRSPEED" value="13." unit="m/s"/>
<define name="CARROT" value="5." unit="s"/>
<define name="CONTROL_RATE" value="60" unit="Hz"/>
<define name="XBEE_INIT" value="&quot;ATPL2\rATRN5\rATTT80\r&quot;"/>
<!-- <define name="NO_XBEE_API_INIT" value="TRUE"/> -->
<define name="ALT_KALMAN_ENABLED" value="TRUE"/>
<define name="DEFAULT_CIRCLE_RADIUS" value="80."/>
</section>
<!-- Local magnetic field -->
<section name="AHRS" prefix="AHRS_" >
<define name="H_X" value="0.51562740288882" />
<define name="H_Y" value="-0.05707735220832" />
<define name="H_Z" value="0.85490967783446" />
</section>
<section name="IMU" prefix="IMU_">
<!-- Calibration Neutral -->
<define name="GYRO_P_NEUTRAL" value="0"/>
<define name="GYRO_Q_NEUTRAL" value="0"/>
<define name="GYRO_R_NEUTRAL" value="0"/>
<!-- SENS = 14.375 LSB/(deg/sec) * 57.6 deg/rad = 828 LSB/rad/sec / 12bit FRAC: 4096 / 828 -->
<define name="GYRO_P_SENS" value="4.947" integer="16"/>
<define name="GYRO_Q_SENS" value="4.947" integer="16"/>
<define name="GYRO_R_SENS" value="4.947" integer="16"/>
<define name="GYRO_P_Q" value="0."/>
<define name="GYRO_P_R" value="0"/>
<define name="GYRO_Q_P" value="0."/>
<define name="GYRO_Q_R" value="0."/>
<define name="GYRO_R_P" value="0."/>
<define name="GYRO_R_Q" value="0."/>
<define name="GYRO_P_SIGN" value="1"/>
<define name="GYRO_Q_SIGN" value="1"/>
<define name="GYRO_R_SIGN" value="1"/>
<define name="ACCEL_X_NEUTRAL" value="-14"/>
<define name="ACCEL_Y_NEUTRAL" value="0"/>
<define name="ACCEL_Z_NEUTRAL" value="0"/>
<!-- SENS = 256 LSB/g @ 2.5V [X&Y: 265 LSB/g @ 3.3V] / 9.81 ms2/g = 26.095 LSB/ms2 / 10bit FRAC: 1024 / 26.095 for z and 1024 / 27.01 for X&Y -->
<define name="ACCEL_X_SENS" value="37.9" integer="16"/>
<define name="ACCEL_Y_SENS" value="37.9" integer="16"/>
<define name="ACCEL_Z_SENS" value="39.24" integer="16"/>
<define name="ACCEL_X_SIGN" value="1"/>
<define name="ACCEL_Y_SIGN" value="1"/>
<define name="ACCEL_Z_SIGN" value="1"/>
<define name="MAG_X_NEUTRAL" value="0"/>
<define name="MAG_Y_NEUTRAL" value="0"/>
<define name="MAG_Z_NEUTRAL" value="0"/>
<define name="MAG_X_SENS" value="1" integer="16"/>
<define name="MAG_Y_SENS" value="1" integer="16"/>
<define name="MAG_Z_SENS" value="1" integer="16"/>
<define name="MAG_X_SIGN" value="1"/>
<define name="MAG_Y_SIGN" value="1"/>
<define name="MAG_Z_SIGN" value="1"/>
<define name="BODY_TO_IMU_PHI" value="0"/>
<define name="BODY_TO_IMU_THETA" value="0"/>
<define name="BODY_TO_IMU_PSI" value="0"/>
</section>
<section name="INS" prefix="INS_">
<define name="ROLL_NEUTRAL_DEFAULT" value="0" unit="deg"/>
<define name="PITCH_NEUTRAL_DEFAULT" value="0" unit="deg"/>
</section>
<section name="VERTICAL CONTROL" prefix="V_CTL_">
<define name="POWER_CTL_BAT_NOMINAL" value="11.1" unit="volt"/>
<!-- outer loop proportional gain -->
<define name="ALTITUDE_PGAIN" value="-0.03"/>
<!-- outer loop saturation -->
<define name="ALTITUDE_MAX_CLIMB" value="2."/>
<!-- auto throttle inner loop -->
<define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.32"/>
<define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE" value="0.25"/>
<define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE" value="0.65"/>
<define name="AUTO_THROTTLE_LOITER_TRIM" value="1500"/>
<define name="AUTO_THROTTLE_DASH_TRIM" value="-4000"/>
<define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.15" unit="%/(m/s)"/>
<define name="AUTO_THROTTLE_PGAIN" value="-0.01"/>
<define name="AUTO_THROTTLE_IGAIN" value="0.1"/>
<define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN" value="0.05"/>
<define name="THROTTLE_SLEW_LIMITER" value="2" unit="s"/>
</section>
<section name="HORIZONTAL CONTROL" prefix="H_CTL_">
<define name="COURSE_PGAIN" value="-1.20000004768"/>
<define name="COURSE_DGAIN" value="0.3"/>
<define name="COURSE_PRE_BANK_CORRECTION" value="0.2"/>
<define name="ROLL_MAX_SETPOINT" value="0.75" unit="rad"/>
<define name="PITCH_MAX_SETPOINT" value="0.5" unit="rad"/>
<define name="PITCH_MIN_SETPOINT" value="-0.5" unit="rad"/>
<define name="PITCH_PGAIN" value="-12000."/>
<define name="PITCH_DGAIN" value="1.5"/>
<define name="ELEVATOR_OF_ROLL" value="1000."/>
<define name="ROLL_SLEW" value="1."/>
<define name="ROLL_ATTITUDE_GAIN" value="-7500"/>
<define name="ROLL_RATE_GAIN" value="0."/>
</section>
</airframe> </airframe>
@@ -1,2 +1,23 @@
<!--
This airframe is connected to the build server and is used for hardware testing.
The hardware configuration is
Powered via a plug 12V pack
Lisa/L v1.1 board
XBee connected to UART2 configured at 38400
Aspirin v1.5
overo
-->
<airframe name="TestConfig"> <airframe name="TestConfig">
<firmware name="rotorcraft">
<target name="sim" board="pc"/>
<target name="ap" board="lisa_l_1.1"/>
<subsystem name="radio_control" type="ppm"/>
<subsystem name="telemetry" type="xbee_api">
<configure name="MODEM_BAUD" value="B38400"/>
</subsystem>
<subsystem name="control"/>
<subsystem name="navigation"/>
</firmware>
</airframe> </airframe>
@@ -1,2 +1,60 @@
<!--
This airframe is connected to the build server and is used for hardware testing.
The hardware configuration is
Powered via a plug 12V pack
Lisa/L v1.1 board
XBee connected to UART2 configured at 38400
Booz2 v1.2
GPS connected to UART1 (Since this is inside in a metal box it won't ever get a solution)
-->
<airframe name="TestConfig"> <airframe name="TestConfig">
<firmware name="fixedwing">
<target name="sim" board="pc"/>
<target name="ap" board="lisa_l_1.1"/>
<subsystem name="radio_control" type="ppm"/>
<subsystem name="telemetry" type="xbee_api">
<configure name="MODEM_BAUD" value="B38400"/>
</subsystem>
<subsystem name="control"/>
<subsystem name="gps" type="ublox"/>
<subsystem name="navigation"/>
</firmware>
<servos>
<servo name="MOTOR" no="0" min="1000" neutral="1000" max="2000"/>
<servo name="AILEVON_LEFT" no="1" min="1900" neutral="1534" max="1100"/>
<servo name="AILEVON_RIGHT" no="2" min="1100" neutral="1468" max="1900"/>
</servos>
<commands>
<axis name="THROTTLE" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="PITCH" failsafe_value="0"/>
</commands>
<rc_commands>
<set command="THROTTLE" value="@THROTTLE"/>
<set command="ROLL" value="@ROLL"/>
<set command="PITCH" value="@PITCH"/>
</rc_commands>
<section name="MIXER">
<define name="AILEVON_AILERON_RATE" value="0.45"/>
<define name="AILEVON_ELEVATOR_RATE" value="0.8"/>
</section>
<command_laws>
<let var="aileron" value="@ROLL * AILEVON_AILERON_RATE"/>
<let var="elevator" value="@PITCH * AILEVON_ELEVATOR_RATE"/>
<set servo="MOTOR" value="@THROTTLE"/>
<set servo="AILEVON_LEFT" value="$elevator + $aileron"/>
<set servo="AILEVON_RIGHT" value="$elevator - $aileron"/>
</command_laws>
<section name="AUTO1" prefix="AUTO1_">
<define name="MAX_ROLL" value="50" unit="deg"/>
<define name="MAX_PITCH" value="35" unit="deg"/>
</section>
</airframe> </airframe>
@@ -1,2 +1,303 @@
<!--
This airframe is connected to the build server and is used for hardware testing.
The hardware configuration is
Powered via a plug 12V pack
Lisa/L v1.1 board
XBee connected to UART2 configured at 38400
Booz2 v1.2
GPS connected to UART1 (Since this is inside in a metal box it won't ever get a solution)
-->
<airframe name="TestConfig"> <airframe name="TestConfig">
<!--
<firmware name="rotorcraft">
<target name="sim" board="pc"/>
<target name="ap" board="lisa_l_1.1"/>
<subsystem name="radio_control" type="ppm"/>
<subsystem name="telemetry" type="xbee_api">
<configure name="MODEM_BAUD" value="B38400"/>
</subsystem>
<subsystem name="control"/>
<subsystem name="gps" type="ublox"/>
<subsystem name="imu" type="b2_v1.2"/>
<subsystem name="stabilization" type="euler"/>
<subsystem name="ahrs" type="int_cmpl_quat"/>
<subsystem name="navigation"/>
</firmware>
-->
<firmware name="rotorcraft">
<target name="ap" board="lisa_l_1.1">
<!--define name="NO_RC_THRUST_LIMIT"/-->
<subsystem name="radio_control" type="spektrum"/>
<define name="RADIO_MODE" value="RADIO_AUX1"/>
<define name="RADIO_KILL_SWITCH" value="RADIO_GEAR"/>
<define name ="RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT" value = "UART5"/>
<define name ="OVERRIDE_UART5_IRQ_HANDLER"/>
<subsystem name="actuators" type="mkk"/>
<subsystem name="telemetry" type="transparent"/>
</target>
<target name="sim" board="pc">
<subsystem name="fdm" type="nps"/>
<subsystem name="radio_control" type="ppm"/>
<subsystem name="actuators" type="mkk"/>
</target>
<subsystem name="imu" type="b2_v1.2"/>
<subsystem name="gps" type="ublox">
<configure name="GPS_BAUD" value="B57600"/>
</subsystem>
<subsystem name="stabilization" type="euler"/>
<subsystem name="ahrs" type="int_cmpl_quat"/>
</firmware>
<!--
<firmware name="lisa_test_progs">
<target name="test_led" board="lisa_l_1.1"/>
<target name="test_uart" board="lisa_l_1.1"/>
<target name="test_servos" board="lisa_l_1.1"/>
<target name="test_telemetry" board="lisa_l_1.1"/>
<target name="test_baro" board="lisa_l_1.1"/>
<target name="test_imu_b2" board="lisa_l_1.1"/>
<target name="test_imu_b2_2" board="lisa_l_1.1"/>
<target name="test_imu_aspirin" board="lisa_l_1.1"/>
<target name="test_rc_spektrum" board="lisa_l_1.1"/>
<target name="test_rc_ppm" board="lisa_l_1.1"/>
<target name="test_adc" board="lisa_l_1.1"/>
<target name="test_hmc5843" board="lisa_l_1.1"/>
<target name="test_itg3200" board="lisa_l_1.1"/>
<target name="test_adxl345" board="lisa_l_1.1"/>
<target name="test_esc_mkk_simple" board="lisa_l_1.1"/>
<target name="test_esc_asctecv1_simple" board="lisa_l_1.1"/>
<target name="test_actuators_mkk" board="lisa_l_1.1"/>
<target name="test_actuators_asctecv1" board="lisa_l_1.1"/>
</firmware>
<firmware name="lisa_passthrough">
<target name="overo_test_passthrough" board="lisa_l_1.1" >
<configure name="HOST" value="A7"/>
<configure name="USER" value=""/>
<configure name="TARGET_DIR" value="~"/>
<configure name="PERIODIC_FREQ" value="512"/>
</target>
<target name="stm_passthrough" board="lisa_l_1.1">
<subsystem name="radio_control" type="spektrum"/>
<subsystem name="imu" type="b2_v1.2"/>
</target>
</firmware>
-->
<servos min="0" neutral="0" max="0xff">
<servo name="FRONT" no="0" min="0" neutral="0" max="255"/>
<servo name="BACK" no="1" min="0" neutral="0" max="255"/>
<servo name="RIGHT" no="2" min="0" neutral="0" max="255"/>
<servo name="LEFT" no="3" min="0" neutral="0" max="255"/>
</servos>
<commands>
<axis name="PITCH" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="YAW" failsafe_value="0"/>
<axis name="THRUST" failsafe_value="0"/>
</commands>
<!-- for the sim -->
<section name="ACTUATORS_MKK" prefix="ACTUATORS_MKK_">
<define name="NB" value="4"/>
<define name="ADDR" value="{ 0x52, 0x54, 0x56, 0x58 }"/>
</section>
<section name="SUPERVISION" prefix="SUPERVISION_">
<define name="MIN_MOTOR" value="2"/>
<define name="MAX_MOTOR" value="210"/>
<define name="TRIM_A" value="0"/>
<define name="TRIM_E" value="0"/>
<define name="TRIM_R" value="0"/>
<define name="NB_MOTOR" value="4"/>
<define name="SCALE" value="256"/>
<define name="ROLL_COEF" value="{ 0, 0, -256, 256 }"/>
<define name="PITCH_COEF" value="{ 256, -256, 0, 0 }"/>
<define name="YAW_COEF" value="{ -256, -256, 256, 256 }"/>
<define name="THRUST_COEF" value="{ 256, 256, 256, 256 }"/>
</section>
<section name="IMU" prefix="IMU_">
<define name="GYRO_P_NEUTRAL" value="32581"/>
<define name="GYRO_Q_NEUTRAL" value="32008"/>
<define name="GYRO_R_NEUTRAL" value="33207"/>
<define name="GYRO_P_SENS" value=".903" integer="16"/>
<define name="GYRO_Q_SENS" value=".905" integer="16"/>
<define name="GYRO_R_SENS" value=".893" integer="16"/>
<define name="GYRO_PQ_SENS" value="0.0" integer="16"/>
<define name="GYRO_PR_SENS" value="0.0" integer="16"/>
<define name="GYRO_QR_SENS" value="0.0" integer="16"/>
<define name="ACCEL_X_NEUTRAL" value="25950"/>
<define name="ACCEL_Y_NEUTRAL" value="26351"/>
<define name="ACCEL_Z_NEUTRAL" value="25696"/>
<define name="ACCEL_X_SENS" value="1.86342150011" integer="16"/>
<define name="ACCEL_Y_SENS" value="1.88378993899" integer="16"/>
<define name="ACCEL_Z_SENS" value="1.86557913201" integer="16"/>
<define name="ACCEL_XY_SENS" value="0.0" integer="16"/>
<define name="ACCEL_XZ_SENS" value="0.0" integer="16"/>
<define name="ACCEL_YZ_SENS" value="0.0" integer="16"/>
<define name="MAG_X_NEUTRAL" value="0"/>
<define name="MAG_Y_NEUTRAL" value="0"/>
<define name="MAG_Z_NEUTRAL" value="0"/>
<define name="MAG_X_SENS" value="1." integer="16"/>
<define name="MAG_Y_SENS" value="1." integer="16"/>
<define name="MAG_Z_SENS" value="1." integer="16"/>
<define name="MAG_XY_SENS" value="0.0" integer="16"/>
<define name="MAG_XZ_SENS" value="0.0" integer="16"/>
<define name="MAG_YZ_SENS" value="0.0" integer="16"/>
<define name="BODY_TO_IMU_PHI" value="0." unit="deg"/>
<define name="BODY_TO_IMU_THETA" value="0." unit="deg"/>
<define name="BODY_TO_IMU_PSI" value="0." unit="deg"/>
</section>
<section name="AUTOPILOT">
<define name="MODE_AUTO1" value="AP_MODE_ATTITUDE_DIRECT"/>
<define name="MODE_MANUAL" value="AP_MODE_ATTITUDE_Z_HOLD"/>
<define name="MODE_AUTO2" value="AP_MODE_HOVER_Z_HOLD"/>
</section>
<section name="BAT">
<define name="CATASTROPHIC_BAT_LEVEL" value="12.4" unit="V"/>
<define name="MAX_BAT_LEVEL" value="16.8" unit="V" />
<define name="CRITIC_BAT_LEVEL" value="13.0" unit="V" />
<define name="LOW_BAT_LEVEL" value="14.0" unit="V" />
</section>
<section name="STABILIZATION_RATE" prefix="STABILIZATION_RATE_">
<define name="SP_MAX_P" value="10000"/>
<define name="SP_MAX_Q" value="10000"/>
<define name="SP_MAX_R" value="10000"/>
<define name="GAIN_P" value="-400"/>
<define name="GAIN_Q" value="-400"/>
<define name="GAIN_R" value="-350"/>
</section>
<section name="STABILIZATION_ATTITUDE" prefix="STABILIZATION_ATTITUDE_">
<!-- setpoints -->
<define name="SP_MAX_PHI" value="45." unit="deg"/>
<define name="SP_MAX_THETA" value="45." unit="deg"/>
<define name="SP_MAX_R" value="90." unit="deg/s"/>
<define name="DEADBAND_R" value="250"/>
<!-- reference -->
<define name="REF_OMEGA_P" value="800" unit="deg/s"/>
<define name="REF_ZETA_P" value="0.9"/>
<define name="REF_MAX_P" value="300." unit="deg/s"/>
<define name="REF_MAX_PDOT" value="RadOfDeg(7000.)"/>
<define name="REF_OMEGA_Q" value="800" unit="deg/s"/>
<define name="REF_ZETA_Q" value="0.9"/>
<define name="REF_MAX_Q" value="300." unit="deg/s"/>
<define name="REF_MAX_QDOT" value="RadOfDeg(7000.)"/>
<define name="REF_OMEGA_R" value="500" unit="deg/s"/>
<define name="REF_ZETA_R" value="0.9"/>
<define name="REF_MAX_R" value="180." unit="deg/s"/>
<define name="REF_MAX_RDOT" value="RadOfDeg(1800.)"/>
<!--
<define name="PHI_PGAIN" value="-2000"/>
<define name="PHI_DGAIN" value="-400"/>
<define name="PHI_IGAIN" value="-200"/>
<define name="THETA_PGAIN" value="-2000"/>
<define name="THETA_DGAIN" value="-400"/>
<define name="THETA_IGAIN" value="-200"/>
<define name="PSI_PGAIN" value="-2000"/>
<define name="PSI_DGAIN" value="-400"/>
<define name="PSI_IGAIN" value="-10"/>
<define name="PHI_DDGAIN" value=" 300"/>
<define name="THETA_DDGAIN" value=" 300"/>
<define name="PSI_DDGAIN" value=" 300"/>
-->
<!-- feedback -->
<define name="PHI_PGAIN" value="-900"/>
<define name="PHI_DGAIN" value="-200"/>
<define name="PHI_IGAIN" value="-200"/>
<define name="THETA_PGAIN" value="-900"/>
<define name="THETA_DGAIN" value="-200"/>
<define name="THETA_IGAIN" value="-200"/>
<define name="PSI_PGAIN" value="-900"/>
<define name="PSI_DGAIN" value="-200"/>
<define name="PSI_IGAIN" value="-10"/>
<!-- feedforward -->
<define name="PHI_DDGAIN" value=" 200"/>
<define name="THETA_DDGAIN" value=" 200"/>
<define name="PSI_DDGAIN" value=" 200"/>
</section>
<section name="AHRS" prefix="AHRS_">
<define name="PROPAGATE_FREQUENCY" value="512"/>
<define name="H_X" value=" 0.3723657"/>
<define name="H_Y" value=" 0.1515225"/>
<define name="H_Z" value="-0.9156335"/>
</section>
<section name="INS" prefix="INS_">
<define name="BARO_SENS" value="10." integer="16"/>
</section>
<section name="GUIDANCE_V" prefix="GUIDANCE_V_">
<define name="MIN_ERR_Z" value="POS_BFP_OF_REAL(-10.)"/>
<define name="MAX_ERR_Z" value="POS_BFP_OF_REAL( 10.)"/>
<define name="MIN_ERR_ZD" value="SPEED_BFP_OF_REAL(-10.)"/>
<define name="MAX_ERR_ZD" value="SPEED_BFP_OF_REAL( 10.)"/>
<define name="MAX_SUM_ERR" value="2000000"/>
<define name="HOVER_KP" value="-150"/>
<define name="HOVER_KD" value="-80"/>
<define name="HOVER_KI" value="0"/>
<!--
<define name="HOVER_KP" value="-150"/>
<define name="HOVER_KD" value="-80"/>
<define name="HOVER_KI" value="0"/>
-->
<!-- 1.5m/s for full stick : BOOZ_SPEED_I_OF_F(1.5) / (MAX_PPRZ/2) -->
<define name="RC_CLIMB_COEF" value ="163"/>
<!-- BOOZ_SPEED_I_OF_F(1.5) * 20% -->
<define name="RC_CLIMB_DEAD_BAND" value ="160000"/>
<!-- <define name="INV_M" value ="0.2"/> -->
</section>
<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="PGAIN" value="-100"/>
<define name="DGAIN" value="-100"/>
<define name="IGAIN" value="-0"/>
<define name="NGAIN" value="-0"/>
</section>
<section name="MISC">
<define name="FACE_REINJ_1" value="1024"/>
</section>
<section name="SIMULATOR" prefix="NPS_">
<define name="ACTUATOR_NAMES" value="{&quot;front_motor&quot;, &quot;back_motor&quot;, &quot;right_motor&quot;, &quot;left_motor&quot;}"/>
<define name="INITIAL_CONDITITONS" value="&quot;reset00&quot;"/>
<define name="SENSORS_PARAMS" value="&quot;nps_sensors_params_booz2_a1.h&quot;"/>
</section>
</airframe> </airframe>
+21 -21
View File
@@ -128,9 +128,9 @@ AP_MODE_NAV
<define name="SP_MAX_Q" value="10000"/> <define name="SP_MAX_Q" value="10000"/>
<define name="SP_MAX_R" value="10000"/> <define name="SP_MAX_R" value="10000"/>
<define name="GAIN_P" value="-400"/> <define name="GAIN_P" value="400"/>
<define name="GAIN_Q" value="-400"/> <define name="GAIN_Q" value="400"/>
<define name="GAIN_R" value="-350"/> <define name="GAIN_R" value="350"/>
</section> </section>
@@ -161,22 +161,22 @@ AP_MODE_NAV
<define name="REF_MAX_PDOT" value="RadOfDeg(1800.)"/> <define name="REF_MAX_PDOT" value="RadOfDeg(1800.)"/>
<!-- feedback --> <!-- feedback -->
<define name="PSI_PGAIN" value="-750"/> <define name="PSI_PGAIN" value="750"/>
<define name="PSI_DGAIN" value="-370"/> <define name="PSI_DGAIN" value="370"/>
<define name="PSI_IGAIN" value="-100"/> <define name="PSI_IGAIN" value="100"/>
<define name="THETA_PGAIN" value="-800"/> <define name="THETA_PGAIN" value="800"/>
<define name="THETA_DGAIN" value="-240"/> <define name="THETA_DGAIN" value="240"/>
<define name="THETA_IGAIN" value="-100"/> <define name="THETA_IGAIN" value="100"/>
<define name="PHI_PGAIN" value="-4000"/> <define name="PHI_PGAIN" value="4000"/>
<define name="PHI_DGAIN" value="-600"/> <define name="PHI_DGAIN" value="600"/>
<define name="PHI_IGAIN" value="-10"/> <define name="PHI_IGAIN" value="10"/>
<!-- feedforward --> <!-- feedforward -->
<define name="PHI_DDGAIN" value=" 300"/> <define name="PHI_DDGAIN" value="300"/>
<define name="THETA_DDGAIN" value=" 300"/> <define name="THETA_DDGAIN" value="300"/>
<define name="PSI_DDGAIN" value=" 300"/> <define name="PSI_DDGAIN" value="300"/>
</section> </section>
@@ -190,9 +190,9 @@ AP_MODE_NAV
<define name="MIN_ERR_ZD" value="SPEED_BFP_OF_REAL(-10.)"/> <define name="MIN_ERR_ZD" value="SPEED_BFP_OF_REAL(-10.)"/>
<define name="MAX_ERR_ZD" value="SPEED_BFP_OF_REAL( 10.)"/> <define name="MAX_ERR_ZD" value="SPEED_BFP_OF_REAL( 10.)"/>
<define name="MAX_SUM_ERR" value="2000000"/> <define name="MAX_SUM_ERR" value="2000000"/>
<define name="HOVER_KP" value="-150"/> <define name="HOVER_KP" value="150"/>
<define name="HOVER_KD" value="-80"/> <define name="HOVER_KD" value="80"/>
<define name="HOVER_KI" value="-20"/> <define name="HOVER_KI" value="20"/>
<!-- 1.5m/s for full stick : BOOZ_SPEED_I_OF_F(1.5) / (MAX_PPRZ/2) --> <!-- 1.5m/s for full stick : BOOZ_SPEED_I_OF_F(1.5) / (MAX_PPRZ/2) -->
<define name="RC_CLIMB_COEF" value ="163"/> <define name="RC_CLIMB_COEF" value ="163"/>
<!-- BOOZ_SPEED_I_OF_F(1.5) * 20% --> <!-- BOOZ_SPEED_I_OF_F(1.5) * 20% -->
@@ -210,9 +210,9 @@ AP_MODE_NAV
</section> </section>
<section name="GUIDANCE_H" prefix="GUIDANCE_H_"> <section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="PGAIN" value="-100"/> <define name="PGAIN" value="100"/>
<define name="DGAIN" value="-100"/> <define name="DGAIN" value="100"/>
<define name="IGAIN" value="-0"/> <define name="IGAIN" value="0"/>
</section> </section>
<section name="SIMULATOR" prefix="NPS_"> <section name="SIMULATOR" prefix="NPS_">
+1 -1
View File
@@ -44,7 +44,7 @@ LOG_MSG_FMT = LOG_PPRZ
endif endif
#set the speed #set the speed
ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=$(UART0_BAUD) -DUSE_UART0_RX_ONLY ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=$(UART0_BAUD) -DUSE_UART0_RX_ONLY -DPERIPHERALS_AUTO_INIT
ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=$(UART1_BAUD) -DUSE_UART1_RX_ONLY ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=$(UART1_BAUD) -DUSE_UART1_RX_ONLY
ap.CFLAGS += -DLOG_STOP_KEY=$(LOG_STOP_KEY) ap.CFLAGS += -DLOG_STOP_KEY=$(LOG_STOP_KEY)
ap.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c ap.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
@@ -37,6 +37,7 @@ ap.CFLAGS += -DIMU_TYPE_H=\"modules/ins/ins_xsens.h\"
# AHRS Results # AHRS Results
ap.CFLAGS += -DAHRS_TYPE_H=\"modules/ins/ins_xsens.h\" ap.CFLAGS += -DAHRS_TYPE_H=\"modules/ins/ins_xsens.h\"
ap.CFLAGS += -DINS_MODULE_H=\"modules/ins/ins_xsens.h\" ap.CFLAGS += -DINS_MODULE_H=\"modules/ins/ins_xsens.h\"
ap.CFLAGS += -DGPS_TYPE_H=\"modules/ins/ins_xsens.h\"
ap.CFLAGS += -DUSE_UART$(XSENS_UART_NR) ap.CFLAGS += -DUSE_UART$(XSENS_UART_NR)
ap.CFLAGS += -DINS_LINK=Uart$(XSENS_UART_NR) ap.CFLAGS += -DINS_LINK=Uart$(XSENS_UART_NR)
@@ -9,4 +9,9 @@ $(TARGET).CFLAGS += -DSSP_VIC_SLOT=9
else ifeq ($(ARCH), stm32) else ifeq ($(ARCH), stm32)
endif endif
ifeq ($(TARGET), sim)
else
$(TARGET).srcs += mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_slave_hs_arch.c $(TARGET).srcs += mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_slave_hs_arch.c
endif
@@ -1,4 +1,5 @@
ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_INT ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_INT
ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_QUAT
ap.CFLAGS += -DSTABILISATION_ATTITUDE_H=\"stabilization/stabilization_attitude_int.h\" ap.CFLAGS += -DSTABILISATION_ATTITUDE_H=\"stabilization/stabilization_attitude_int.h\"
ap.CFLAGS += -DSTABILISATION_ATTITUDE_REF_H=\"stabilization/stabilization_attitude_ref_quat_int.h\" ap.CFLAGS += -DSTABILISATION_ATTITUDE_REF_H=\"stabilization/stabilization_attitude_ref_quat_int.h\"
ap.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_attitude_ref_quat_int.c ap.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_attitude_ref_quat_int.c
@@ -1,4 +1,5 @@
ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_INT ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_INT
ap.CFLAGS += -DSTABILISATION_ATTITUDE_TYPE_QUAT
ap.CFLAGS += -DSTABILISATION_ATTITUDE_H=\"stabilization/stabilization_attitude_int.h\" ap.CFLAGS += -DSTABILISATION_ATTITUDE_H=\"stabilization/stabilization_attitude_int.h\"
ap.CFLAGS += -DSTABILISATION_ATTITUDE_REF_H=\"stabilization/stabilization_attitude_ref_quat_int.h\" ap.CFLAGS += -DSTABILISATION_ATTITUDE_REF_H=\"stabilization/stabilization_attitude_ref_quat_int.h\"
ap.CFLAGS += -DUSE_SETPOINTS_WITH_TRANSITIONS ap.CFLAGS += -DUSE_SETPOINTS_WITH_TRANSITIONS
+85 -15
View File
@@ -1,22 +1,92 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<conf> <conf>
<!-- arm7 aircrafts -->
<!-- NOTE: All targets in the example config need to be on single lines so that the "make test_all_example_airframes" target can build all targets for each aircraft airframe --> <!-- booz2 -->
<aircraft
name="BOOZ2_A1"
ac_id="150"
airframe="airframes/Poine/booz2_a1.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/telemetry_booz2.xml"
flight_plan="flight_plans/dummy.xml"
settings="settings/settings_booz2.xml settings/settings_booz2_ahrs_cmpl.xml"
gui_color="white"
/>
<!-- arm7 aircrafts --> <!-- LISA -->
<aircraft
name="Hexa_LisaL"
ac_id="153"
airframe="airframes/Poine/h_hex.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/telemetry_booz2.xml"
flight_plan="flight_plans/dummy.xml"
settings="settings/settings_booz2.xml"
gui_color="white"
/>
<aircraft
name="LISA_ASCTEC_PIOTR"
ac_id="161"
airframe="airframes/esden/lisa_asctec.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/telemetry_booz2.xml"
flight_plan="flight_plans/dummy.xml"
settings="settings/settings_booz2.xml settings/settings_booz2_ahrs_cmpl.xml"
gui_color="white"
/>
<!-- booz2 --> <!-- tiny -->
<aircraft name="BOOZ2_A1" ac_id="150" airframe="airframes/Poine/booz2_a1.xml" radio="radios/cockpitSX.xml" telemetry="telemetry/telemetry_booz2.xml" flight_plan="flight_plans/dummy.xml" settings="settings/settings_booz2.xml settings/settings_booz2_ahrs_cmpl.xml" gui_color="white" /> <aircraft
name="Microjet"
<!-- LISA --> ac_id="5"
<aircraft name="Hexa_LisaL" ac_id="153" airframe="airframes/Poine/h_hex.xml" radio="radios/cockpitSX.xml" telemetry="telemetry/telemetry_booz2.xml" flight_plan="flight_plans/dummy.xml" settings="settings/settings_booz2.xml" gui_color="white" /> airframe="airframes/microjet_example.xml"
<aircraft name="LISA_ASCTEC_PIOTR" ac_id="161" airframe="airframes/esden/lisa_asctec.xml" radio="radios/cockpitSX.xml" telemetry="telemetry/telemetry_booz2.xml" flight_plan="flight_plans/dummy.xml" settings="settings/settings_booz2.xml settings/settings_booz2_ahrs_cmpl.xml" gui_color="white" /> radio="radios/cockpitMM.xml"
telemetry="telemetry/default.xml"
<!-- tiny --> flight_plan="flight_plans/basic.xml"
<aircraft name="Microjet" ac_id="5" airframe="airframes/microjet_example.xml" radio="radios/cockpitMM.xml" telemetry="telemetry/default.xml" flight_plan="flight_plans/basic.xml" settings="settings/basic_infrared.xml" gui_color="#6293ba" /> settings="settings/basic_infrared.xml"
<aircraft name="Tiny_IMU" ac_id="7" airframe="airframes/example_twog_analogimu.xml" radio="radios/cockpitSX.xml" telemetry="telemetry/default_fixedwing_imu.xml" flight_plan="flight_plans/versatile.xml" settings="settings/tuning_ins.xml" gui_color="blue" /> gui_color="#6293ba"
<aircraft name="Twinjet" ac_id="6" airframe="airframes/twinjet_example.xml" radio="radios/cockpitMM.xml" telemetry="telemetry/default.xml" flight_plan="flight_plans/versatile.xml" settings="settings/tuning.xml settings/infrared.xml" gui_color="#ba6293" /> />
<aircraft name="EasyStar_ETS" ac_id="8" airframe="airframes/easystar_ets_example.xml" radio="radios/cockpitSX.xml" telemetry="telemetry/default.xml" flight_plan="flight_plans/versatile.xml" settings="settings/tuning.xml settings/infrared.xml" gui_color="red" /> <aircraft
name="Tiny_IMU"
ac_id="7"
airframe="airframes/example_twog_analogimu.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/default_fixedwing_imu.xml"
flight_plan="flight_plans/versatile.xml"
settings="settings/tuning_ins.xml"
gui_color="blue"
/>
<aircraft
name="Twinjet"
ac_id="6"
airframe="airframes/twinjet_example.xml"
radio="radios/cockpitMM.xml"
telemetry="telemetry/default.xml"
flight_plan="flight_plans/versatile.xml"
settings="settings/tuning.xml settings/infrared.xml"
gui_color="#ba6293"
/>
<aircraft
name="EasyStar_ETS"
ac_id="8"
airframe="airframes/easystar_ets_example.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/default.xml"
flight_plan="flight_plans/versatile.xml"
settings="settings/tuning.xml settings/infrared.xml"
gui_color="red"
/>
<!-- Hardware test Lisa/L -->
<aircraft
name="LisaLv11_Booz2v12_RC"
ac_id="9"
airframe="airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/telemetry_booz2.xml"
flight_plan="flight_plans/dummy.xml"
settings="settings/settings_booz2.xml"
gui_color="white"
/>
</conf> </conf>
+2 -2
View File
@@ -428,8 +428,8 @@
</message> </message>
<message name="GPS_LLA" id="59"> <message name="GPS_LLA" id="59">
<field name="lat" type="int32" unit="cm" alt_unit="m"/> <field name="lat" type="int32" alt_unit="deg" alt_unit_coef="0.0000057296"/>
<field name="lon" type="int32" unit="cm" alt_unit="m"/> <field name="lon" type="int32" alt_unit="deg" alt_unit_coef="0.0000057296"/>
<field name="alt" type="int32" unit="mm" alt_unit="m"/> <field name="alt" type="int32" unit="mm" alt_unit="m"/>
<field name="course" type="int16" unit="decideg" alt_unit="deg"/> <field name="course" type="int16" unit="decideg" alt_unit="deg"/>
<field name="speed" type="uint16" unit="cm/s" alt_unit="m/s"/> <field name="speed" type="uint16" unit="cm/s" alt_unit="m/s"/>
-1
View File
@@ -4,7 +4,6 @@
<!-- <depend conflict="ins" --> <!-- <depend conflict="ins" -->
<header> <header>
<file name="ins_module.h"/> <file name="ins_module.h"/>
<file name="ins_chimu.h"/>
</header> </header>
<init fun="ins_init()"/> <init fun="ins_init()"/>
<event fun="parse_ins_msg()"/> <event fun="parse_ins_msg()"/>
-1
View File
@@ -10,7 +10,6 @@ For older CHIMU v1.0 you should define CHIMU_BIG_ENDIAN
<!-- <depend conflict="ins" --> <!-- <depend conflict="ins" -->
<header> <header>
<file name="ins_module.h"/> <file name="ins_module.h"/>
<file name="ins_chimu.h"/>
</header> </header>
<init fun="ins_init()"/> <init fun="ins_init()"/>
<!--<periodic fun="ins_periodic_task()" freq="60"/>--> <!--<periodic fun="ins_periodic_task()" freq="60"/>-->
+24 -24
View File
@@ -1,26 +1,26 @@
<!-- Mediatek/DIYDrones protocol DTD --> <!-- Mediatek/DIYDrones protocol DTD -->
<!ELEMENT mtk (class+)> <!ELEMENT mtk (class+)>
<!ELEMENT class (message+)> <!ELEMENT class (message+)>
<!ELEMENT message (field|block)*> <!ELEMENT message (field|block)*>
<!ELEMENT block (field*)> <!ELEMENT block (field*)>
<!ELEMENT field EMPTY> <!ELEMENT field EMPTY>
<!ATTLIST class <!ATTLIST class
name CDATA #REQUIRED name CDATA #REQUIRED
ID CDATA #REQUIRED> ID CDATA #REQUIRED>
<!ATTLIST message <!ATTLIST message
name CDATA #REQUIRED name CDATA #REQUIRED
ID CDATA #REQUIRED ID CDATA #REQUIRED
length CDATA #IMPLIED> length CDATA #IMPLIED>
<!ATTLIST block <!ATTLIST block
times CDATA #IMPLIED times CDATA #IMPLIED
length CDATA #REQUIRED> length CDATA #REQUIRED>
<!ATTLIST field <!ATTLIST field
name CDATA #REQUIRED name CDATA #REQUIRED
format CDATA #REQUIRED format CDATA #REQUIRED
scaling CDATA #IMPLIED scaling CDATA #IMPLIED
unit CDATA #IMPLIED> unit CDATA #IMPLIED>
@@ -231,6 +231,45 @@ extern uint8_t telemetry_mode_Ap_DefaultChannel;
i++; \ i++; \
} }
#if USE_GPS
#define PERIODIC_SEND_GPS_INT(_trans, _dev) { \
DOWNLINK_SEND_GPS_INT( _trans, _dev, \
&gps.ecef_pos.x, \
&gps.ecef_pos.y, \
&gps.ecef_pos.z, \
&gps.lla_pos.lat, \
&gps.lla_pos.lon, \
&gps.lla_pos.alt, \
&gps.hmsl, \
&gps.ecef_vel.x, \
&gps.ecef_vel.y, \
&gps.ecef_vel.z, \
&gps.pacc, \
&gps.sacc, \
&gps.tow, \
&gps.pdop, \
&gps.num_sv, \
&gps.fix); \
}
#define PERIODIC_SEND_GPS_LLA(_trans, _dev) { \
int16_t climb = -gps.ned_vel.z; \
int16_t course = (DegOfRad(gps.course)/((int32_t)1e6)); \
DOWNLINK_SEND_GPS_LLA( _trans, _dev, \
&gps.lla_pos.lat, \
&gps.lla_pos.lon, \
&gps.lla_pos.alt, \
&gps.hmsl, \
&course, \
&gps.gspeed, \
&climb, \
&gps.week, \
&gps.tow, \
&gps.fix, \
&gps.fix); \
}
#endif
#if USE_BARO_MS5534A #if USE_BARO_MS5534A
//#include "baro_MS5534A.h" //#include "baro_MS5534A.h"
#define PERIODIC_SEND_BARO_MS5534A(_trans, _dev) DOWNLINK_SEND_BARO_MS5534A(_trans, _dev, &baro_MS5534A_pressure, &baro_MS5534A_temp, &baro_MS5534A_z) #define PERIODIC_SEND_BARO_MS5534A(_trans, _dev) DOWNLINK_SEND_BARO_MS5534A(_trans, _dev, &baro_MS5534A_pressure, &baro_MS5534A_temp, &baro_MS5534A_z)
@@ -44,7 +44,6 @@ void actuators_init(void)
} }
#define PWM_GAIN_SCALE 2 #define PWM_GAIN_SCALE 2
#define PWM_OFF 1000
void actuators_set(bool_t motors_on) { void actuators_set(bool_t motors_on) {
int32_t pwm_commands[COMMANDS_NB]; int32_t pwm_commands[COMMANDS_NB];
@@ -64,12 +63,8 @@ void actuators_set(bool_t motors_on) {
SetActuatorsFromCommands(pwm_commands_pprz); SetActuatorsFromCommands(pwm_commands_pprz);
if (motors_on) { for (int i = 0; i < SUPERVISION_NB_MOTOR; i++) {
for (int i = 0; i < SUPERVISION_NB_MOTOR; i++)
actuators_pwm_values[i] = supervision.commands[i]; actuators_pwm_values[i] = supervision.commands[i];
} else {
for (int i = 0; i < SUPERVISION_NB_MOTOR; i++)
actuators_pwm_values[i] = PWM_OFF;
} }
actuators_pwm_commit(); actuators_pwm_commit();
@@ -34,6 +34,10 @@
#define INT32_MAX (2147483647) #define INT32_MAX (2147483647)
#endif #endif
#ifndef SUPERVISION_STOP_MOTOR
#define SUPERVISION_STOP_MOTOR 0
#endif
#ifndef SUPERVISION_MIN_MOTOR_STARTUP #ifndef SUPERVISION_MIN_MOTOR_STARTUP
#define SUPERVISION_MIN_MOTOR_STARTUP SUPERVISION_MIN_MOTOR #define SUPERVISION_MIN_MOTOR_STARTUP SUPERVISION_MIN_MOTOR
#endif #endif
@@ -166,7 +170,9 @@ void supervision_run(bool_t motors_on, bool_t override_on, int32_t in_cmd[] ) {
bound_commands(); bound_commands();
bound_commands_step(); bound_commands_step();
} }
else else {
for (i=0; i<SUPERVISION_NB_MOTOR; i++) for (i=0; i<SUPERVISION_NB_MOTOR; i++) {
supervision.commands[i] = 0; supervision.commands[i] = SUPERVISION_STOP_MOTOR;
}
}
} }
@@ -378,8 +378,11 @@ __attribute__ ((always_inline)) static inline void guidance_h_nav_run(bool_t in
guidance_h_command_body.psi = guidance_h_psi_sp + guidance_h_rc_sp.psi; guidance_h_command_body.psi = guidance_h_psi_sp + guidance_h_rc_sp.psi;
ANGLE_REF_NORMALIZE(guidance_h_command_body.psi); ANGLE_REF_NORMALIZE(guidance_h_command_body.psi);
// Set attitude setpoint /* Set attitude setpoint in eulers and as quaternion */
EULERS_COPY(stab_att_sp_euler, guidance_h_command_body); EULERS_COPY(stab_att_sp_euler, guidance_h_command_body);
#ifdef STABILISATION_ATTITUDE_TYPE_QUAT
INT32_QUAT_OF_EULERS(stab_att_sp_quat, stab_att_sp_euler);
#endif
} }
@@ -1,16 +1,16 @@
#ifndef FLIGHTBENCHMARK_H #ifndef FLIGHTBENCHMARK_H
#define FLIGHTBENCHMARK_H #define FLIGHTBENCHMARK_H
#include <inttypes.h> #include <inttypes.h>
void flight_benchmark_init( void ); void flight_benchmark_init( void );
void flight_benchmark_periodic( void ); void flight_benchmark_periodic( void );
void flight_benchmark_reset( void ); void flight_benchmark_reset( void );
extern float ToleranceAispeed; extern float ToleranceAispeed;
extern float ToleranceAltitude; extern float ToleranceAltitude;
extern float TolerancePosition; extern float TolerancePosition;
extern bool_t benchm_reset; extern bool_t benchm_reset;
extern bool_t benchm_go; extern bool_t benchm_go;
#endif /* FLIGHTBENCHMARK_H */ #endif /* FLIGHTBENCHMARK_H */
-6
View File
@@ -1,6 +0,0 @@
#ifndef INS_CHIMU_H
#define INS_CHIMU_H
extern void ahrs_update_gps( void );
#endif
+1 -2
View File
@@ -14,6 +14,7 @@
// For centripedal corrections // For centripedal corrections
#include "subsystems/gps.h" #include "subsystems/gps.h"
#include "subsystems/ahrs.h"
// Telemetry // Telemetry
#ifndef DOWNLINK_DEVICE #ifndef DOWNLINK_DEVICE
@@ -27,8 +28,6 @@
#include "ins_module.h" #include "ins_module.h"
#include "imu_chimu.h" #include "imu_chimu.h"
#include "subsystems/gps.h"
CHIMU_PARSER_DATA CHIMU_DATA; CHIMU_PARSER_DATA CHIMU_DATA;
+1
View File
@@ -14,6 +14,7 @@
// For centripedal corrections // For centripedal corrections
#include "subsystems/gps.h" #include "subsystems/gps.h"
#include "subsystems/ahrs.h"
// Telemetry // Telemetry
#ifndef DOWNLINK_DEVICE #ifndef DOWNLINK_DEVICE
-12
View File
@@ -71,22 +71,12 @@ INS_FORMAT ins_mz;
float ins_pitch_neutral; float ins_pitch_neutral;
float ins_roll_neutral; float ins_roll_neutral;
//volatile uint8_t new_ins_attitude;
#include "subsystems/imu.h"
void ahrs_init(void) void ahrs_init(void)
{ {
ins_init(); ins_init();
} }
void imu_periodic(void)
{
ins_periodic_task();
}
//struct Imu imu;
#include "subsystems/imu.h" #include "subsystems/imu.h"
@@ -100,8 +90,6 @@ void imu_periodic(void)
ins_periodic_task(); ins_periodic_task();
} }
//struct Imu imu;
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
+3
View File
@@ -33,6 +33,9 @@
#include "ins_module.h" #include "ins_module.h"
#include "subsystems/ahrs.h"
extern int8_t xsens_hour; extern int8_t xsens_hour;
extern int8_t xsens_min; extern int8_t xsens_min;
extern int8_t xsens_sec; extern int8_t xsens_sec;
+2 -2
View File
@@ -53,7 +53,7 @@
#endif #endif
#include "mcu_periph/uart.h" #include "mcu_periph/uart.h"
#include "messages.h" #include "messages.h"
#include "downlink.h" #include "subsystems/datalink/datalink.h"
static bool_t nav_catapult_armed = FALSE; static bool_t nav_catapult_armed = FALSE;
@@ -189,7 +189,7 @@ bool_t nav_catapult(uint8_t _to, uint8_t _climb)
WaypointX(_climb) = nav_catapult_x + (dir_x / dir_L) * 300; WaypointX(_climb) = nav_catapult_x + (dir_x / dir_L) * 300;
WaypointY(_climb) = nav_catapult_y + (dir_y / dir_L) * 300; WaypointY(_climb) = nav_catapult_y + (dir_y / dir_L) * 300;
DownlinkSendWp(DefaultChannel, _climb); DownlinkSendWp(DefaultChannel, DefaultDevice, _climb);
} }
+4
View File
@@ -37,6 +37,10 @@
#include GPS_TYPE_H #include GPS_TYPE_H
#endif #endif
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#define GpsFixValid() (gps.fix == GPS_FIX_3D) #define GpsFixValid() (gps.fix == GPS_FIX_3D)
+33 -1
View File
@@ -63,6 +63,12 @@
#define GPS_MTK_ERR_UNEXPECTED 4 #define GPS_MTK_ERR_UNEXPECTED 4
#define GPS_MTK_ERR_OUT_OF_SYNC 5 #define GPS_MTK_ERR_OUT_OF_SYNC 5
/* mediatek gps fix mask */
#define MTK_DIY_FIX_3D 3
#define MTK_DIY_FIX_2D 2
#define MTK_DIY_FIX_NONE 1
/* defines for UTC-GPS time conversion */ /* defines for UTC-GPS time conversion */
#define SECS_MINUTE (60) #define SECS_MINUTE (60)
#define SECS_HOUR (60*60) #define SECS_HOUR (60*60)
@@ -76,6 +82,23 @@ const int8_t DAYS_MONTH[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
struct GpsMtk gps_mtk; struct GpsMtk gps_mtk;
#ifdef GPS_CONFIGURE #ifdef GPS_CONFIGURE
#define MTK_DIY_SET_BINARY "$PGCMD,16,0,0,0,0,0*6A\r\n"
#define MTK_DIY_SET_NMEA "$PGCMD,16,1,1,1,1,1*6B\r\n"
#define MTK_DIY_OUTPUT_1HZ "$PMTK220,1000*1F\r\n"
#define MTK_DIY_OUTPUT_2HZ "$PMTK220,500*2B\r\n"
#define MTK_DIY_OUTPUT_4HZ "$PMTK220,250*29\r\n"
#define MTK_DIY_OTUPUT_5HZ "$PMTK220,200*2C\r\n"
#define MTK_DIY_OUTPUT_10HZ "$PMTK220,100*2F\r\n"
#define MTK_BAUD_RATE_38400 "$PMTK251,38400*27\r\n"
#define MTK_DIY_SBAS_ON "$PMTK313,1*2E\r\n"
#define MTK_DIY_SBAS_OFF "$PMTK313,0*2F\r\n"
#define MTK_DIY_WAAS_ON "$PSRF151,1*3F\r\n"
#define MTK_DIY_WAAS_OFF "$PSRF151,0*3E\r\n"
bool_t gps_configuring; bool_t gps_configuring;
static uint8_t gps_status_config; static uint8_t gps_status_config;
#endif #endif
@@ -158,7 +181,16 @@ void gps_mtk_read_message(void) {
gps.speed_3d = gps.gspeed; gps.speed_3d = gps.gspeed;
gps.course = (RadOfDeg(MTK_DIY14_NAV_Heading(gps_mtk.msg_buf)))*10; gps.course = (RadOfDeg(MTK_DIY14_NAV_Heading(gps_mtk.msg_buf)))*10;
gps.num_sv = MTK_DIY14_NAV_numSV(gps_mtk.msg_buf); gps.num_sv = MTK_DIY14_NAV_numSV(gps_mtk.msg_buf);
gps.fix = MTK_DIY14_NAV_GPSfix(gps_mtk.msg_buf); switch (MTK_DIY14_NAV_GPSfix(gps_mtk.msg_buf)) {
case MTK_DIY_FIX_3D:
gps.fix = GPS_FIX_3D;
break;
case MTK_DIY_FIX_2D:
gps.fix = GPS_FIX_2D;
break;
default:
gps.fix = GPS_FIX_NONE;
}
gps.tow = MTK_DIY14_NAV_ITOW(gps_mtk.msg_buf);; gps.tow = MTK_DIY14_NAV_ITOW(gps_mtk.msg_buf);;
// FIXME: with MTK DIY 1.4 you do not receive GPS week // FIXME: with MTK DIY 1.4 you do not receive GPS week
gps.week = 0; gps.week = 0;
-21
View File
@@ -28,10 +28,6 @@
/** Includes macros generated from mtk.xml */ /** Includes macros generated from mtk.xml */
#include "mtk_protocol.h" #include "mtk_protocol.h"
#define GPS_FIX_NONE 0x01
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#define GPS_MTK_MAX_PAYLOAD 255 #define GPS_MTK_MAX_PAYLOAD 255
struct GpsMtk { struct GpsMtk {
@@ -113,23 +109,6 @@ extern void gps_mtk_parse(uint8_t c);
* dynamic GPS configuration * dynamic GPS configuration
*/ */
#ifdef GPS_CONFIGURE #ifdef GPS_CONFIGURE
#define MTK_DIY_SET_BINARY "$PGCMD,16,0,0,0,0,0*6A\r\n"
#define MTK_DIY_SET_NMEA "$PGCMD,16,1,1,1,1,1*6B\r\n"
#define MTK_DIY_OUTPUT_1HZ "$PMTK220,1000*1F\r\n"
#define MTK_DIY_OUTPUT_2HZ "$PMTK220,500*2B\r\n"
#define MTK_DIY_OUTPUT_4HZ "$PMTK220,250*29\r\n"
#define MTK_DIY_OTUPUT_5HZ "$PMTK220,200*2C\r\n"
#define MTK_DIY_OUTPUT_10HZ "$PMTK220,100*2F\r\n"
#define MTK_BAUD_RATE_38400 "$PMTK251,38400*27\r\n"
#define MTK_DIY_SBAS_ON "$PMTK313,1*2E\r\n"
#define MTK_DIY_SBAS_OFF "$PMTK313,0*2F\r\n"
#define MTK_DIY_WAAS_ON "$PSRF151,1*3F\r\n"
#define MTK_DIY_WAAS_OFF "$PSRF151,0*3E\r\n"
extern void gps_configure(void); extern void gps_configure(void);
extern void gps_configure_uart(void); extern void gps_configure_uart(void);
#endif #endif
+2 -6
View File
@@ -20,8 +20,8 @@
* *
*/ */
/** @file gps_nmea.h /** \file gps_nmea.h
* NMEA protocol specific code * \brief NMEA protocol specific code
* *
*/ */
@@ -33,10 +33,6 @@
#define GPS_NB_CHANNELS 16 #define GPS_NB_CHANNELS 16
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#ifdef DEBUG_NMEA #ifdef DEBUG_NMEA
#define NMEA_PRINT(...) { UsbSPrintString( __VA_ARGS__);}; #define NMEA_PRINT(...) { UsbSPrintString( __VA_ARGS__);};
#else #else
-4
View File
@@ -3,10 +3,6 @@
#include "std.h" #include "std.h"
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#define GPS_NB_CHANNELS 16 #define GPS_NB_CHANNELS 16
extern bool_t gps_available; extern bool_t gps_available;
-4
View File
@@ -3,10 +3,6 @@
#include "nps_sensors.h" #include "nps_sensors.h"
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#define GPS_NB_CHANNELS 16 #define GPS_NB_CHANNELS 16
extern bool_t gps_available; extern bool_t gps_available;
+23 -7
View File
@@ -20,6 +20,7 @@
*/ */
#include "subsystems/gps.h" #include "subsystems/gps.h"
#include "led.h"
#if GPS_USE_LATLONG #if GPS_USE_LATLONG
/* currently needed to get nav_utm_zone0 */ /* currently needed to get nav_utm_zone0 */
@@ -40,8 +41,12 @@ struct GpsSkytraq gps_skytraq;
#define GOT_CHECKSUM 7 #define GOT_CHECKSUM 7
#define GOT_SYNC3 8 #define GOT_SYNC3 8
#define SKYTRAQ_FIX_NONE 0x00
#define SKYTRAQ_FIX_2D 0x01
#define SKYTRAQ_FIX_3D 0x02
#define SKYTRAQ_FIX_3D_DGPS 0x03
//#include "my_debug_servo.h" //#include "my_debug_servo.h"
#include "led.h"
void gps_impl_init(void) { void gps_impl_init(void) {
@@ -64,17 +69,28 @@ void gps_skytraq_read_message(void) {
gps.ecef_vel.x = SKYTRAQ_NAVIGATION_DATA_ECEFVX(gps_skytraq.msg_buf); gps.ecef_vel.x = SKYTRAQ_NAVIGATION_DATA_ECEFVX(gps_skytraq.msg_buf);
gps.ecef_vel.y = SKYTRAQ_NAVIGATION_DATA_ECEFVY(gps_skytraq.msg_buf); gps.ecef_vel.y = SKYTRAQ_NAVIGATION_DATA_ECEFVY(gps_skytraq.msg_buf);
gps.ecef_vel.z = SKYTRAQ_NAVIGATION_DATA_ECEFVZ(gps_skytraq.msg_buf); gps.ecef_vel.z = SKYTRAQ_NAVIGATION_DATA_ECEFVZ(gps_skytraq.msg_buf);
gps.lla_pos.lat = SKYTRAQ_NAVIGATION_DATA_LAT(gps_skytraq.msg_buf); gps.lla_pos.lat = RadOfDeg(SKYTRAQ_NAVIGATION_DATA_LAT(gps_skytraq.msg_buf));
gps.lla_pos.lon = SKYTRAQ_NAVIGATION_DATA_LON(gps_skytraq.msg_buf); gps.lla_pos.lon = RadOfDeg(SKYTRAQ_NAVIGATION_DATA_LON(gps_skytraq.msg_buf));
gps.lla_pos.alt = SKYTRAQ_NAVIGATION_DATA_AEL(gps_skytraq.msg_buf); gps.lla_pos.alt = SKYTRAQ_NAVIGATION_DATA_AEL(gps_skytraq.msg_buf)/10;
gps.hmsl = SKYTRAQ_NAVIGATION_DATA_ASL(gps_skytraq.msg_buf); gps.hmsl = SKYTRAQ_NAVIGATION_DATA_ASL(gps_skytraq.msg_buf)/10;
// pacc; // pacc;
// sacc; // sacc;
// gps.pdop = SKYTRAQ_NAVIGATION_DATA_PDOP(gps_skytraq.msg_buf); // gps.pdop = SKYTRAQ_NAVIGATION_DATA_PDOP(gps_skytraq.msg_buf);
gps.num_sv = SKYTRAQ_NAVIGATION_DATA_NumSV(gps_skytraq.msg_buf); gps.num_sv = SKYTRAQ_NAVIGATION_DATA_NumSV(gps_skytraq.msg_buf);
gps.fix = SKYTRAQ_NAVIGATION_DATA_FixMode(gps_skytraq.msg_buf);
gps.tow = SKYTRAQ_NAVIGATION_DATA_TOW(gps_skytraq.msg_buf)/10; gps.tow = SKYTRAQ_NAVIGATION_DATA_TOW(gps_skytraq.msg_buf)/10;
switch (SKYTRAQ_NAVIGATION_DATA_FixMode(gps_skytraq.msg_buf)) {
case SKYTRAQ_FIX_3D_DGPS:
case SKYTRAQ_FIX_3D:
gps.fix = GPS_FIX_3D;
break;
case SKYTRAQ_FIX_2D:
gps.fix = GPS_FIX_2D;
break;
default:
gps.fix = GPS_FIX_NONE;
}
#if GPS_USE_LATLONG #if GPS_USE_LATLONG
/* Computes from (lat, long) in the referenced UTM zone */ /* Computes from (lat, long) in the referenced UTM zone */
struct LlaCoor_f lla_f; struct LlaCoor_f lla_f;
@@ -89,7 +105,7 @@ void gps_skytraq_read_message(void) {
gps.utm_pos.north = utm_f.north*100; gps.utm_pos.north = utm_f.north*100;
gps.utm_pos.alt = utm_f.alt*1000; gps.utm_pos.alt = utm_f.alt*1000;
gps.utm_pos.zone = nav_utm_zone0; gps.utm_pos.zone = nav_utm_zone0;
#else #endif
//DEBUG_S2_TOGGLE(); //DEBUG_S2_TOGGLE();
-7
View File
@@ -24,13 +24,6 @@
#include "mcu_periph/uart.h" #include "mcu_periph/uart.h"
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x01
#define GPS_FIX_3D 0x02
#define GPS_FIX_3D_DGPS 0x03
#define SKYTRAQ_SYNC1 0xA0 #define SKYTRAQ_SYNC1 0xA0
#define SKYTRAQ_SYNC2 0xA1 #define SKYTRAQ_SYNC2 0xA1
-4
View File
@@ -38,10 +38,6 @@
#define GPS_NB_CHANNELS 16 #define GPS_NB_CHANNELS 16
#define GPS_FIX_NONE 0x00
#define GPS_FIX_2D 0x02
#define GPS_FIX_3D 0x03
#define GPS_UBX_MAX_PAYLOAD 255 #define GPS_UBX_MAX_PAYLOAD 255
struct GpsUbx { struct GpsUbx {
bool_t msg_available; bool_t msg_available;
+5 -1
View File
@@ -146,7 +146,11 @@ module Make(A:Data.MISSION) = struct
let max_bat_level = let max_bat_level =
try float_value (section "BAT") "MAX_BAT_LEVEL" with _ -> 12.5 try float_value (section "BAT") "MAX_BAT_LEVEL" with _ -> 12.5
let max_phi = 0.7 (* rad *) let h_ctrl_section =
try section "HORIZONTAL CONTROL" with _ -> Xml.Element("",[],[])
let max_phi =
try code_value h_ctrl_section "ROLL_MAX_SETPOINT" with _ -> 0.7 (* rad *)
let max_phi_dot = 0.25 (* rad/s *) let max_phi_dot = 0.25 (* rad/s *)
let bound = fun x mi ma -> if x > ma then ma else if x < mi then mi else x let bound = fun x mi ma -> if x > ma then ma else if x < mi then mi else x
+95
View File
@@ -0,0 +1,95 @@
#!/usr/bin/perl -w
use Test::More tests => 7;
use lib "$ENV{'PAPARAZZI_SRC'}/tests/lib";
use Program;
use Proc::Background;
use Ivy;
$|++;
####################
# Make the airframe
my $make_compile_options = "AIRCRAFT=LisaLv11_Booz2v12_RC clean_ac ap.compile";
my $compile_output = run_program(
"Attempting to build and upload the firmware.",
$ENV{'PAPARAZZI_SRC'},
"make $make_compile_options",
0,1);
unlike($compile_output, '/Aircraft \'LisaLv11_Booz2v12_RC\' not found in/', "The compile output does not contain the message \"Aircraft \'LisaLv11_Booz2v12_RC\' not found in\"");
unlike($compile_output, '/\bError\b/i', "The compile output does not contain the word \"Error\"");
####################
# Upload the airframe
my $make_upload_options = "AIRCRAFT=LisaLv11_Booz2v12_RC BOARD_SERIAL=LISA-L-000156 ap.upload";
my $upload_output = run_program(
"Attempting to build and upload the firmware.",
$ENV{'PAPARAZZI_SRC'},
"make $make_upload_options",
0,1);
unlike($upload_output, '/\bError\b/i', "The upload output does not contain the word \"Error\"");
# Start the server process
my $server_command = "$ENV{'PAPARAZZI_HOME'}/sw/ground_segment/tmtc/server";
my $server_options = "";
my $server = Proc::Background->new($server_command, $server_options);
sleep 2; # The service should die in this time if there's an error
ok($server->alive(), "The server started successfully");
# Start the link process
my $link_command = "$ENV{'PAPARAZZI_HOME'}/sw/ground_segment/tmtc/link";
my @link_options = qw(-d /dev/tty.usbserial-000013FD -s 57600 -transport xbee -xbee_addr 123);
#my @link_options = qw(-d /dev/tty.usbserial-000013FD -s 57600);
sleep 2; # The service should die in this time if there's an error
my $link = Proc::Background->new($link_command, @link_options);
ok($link->alive(), "The link started successfully");
# Open the Ivy bus and read from it...
# TODO: learn how to read and write to the Ivy bus
# Shutdown the server and link processes
ok($server->die(), "The server shutdown successfully.");
ok($link->die(), "The link shutdown successfully.");
################################################################################
# functions used by this test script.
sub run_program
{
my $message = shift;
my $dir = shift;
my $command = shift;
my $verbose = shift;
my $dont_fail_on_error = shift;
warn "$message\n" if $verbose;
if (defined $dir)
{
$command = "cd $dir;" . $command;
}
my $prog = new Program("bash");
my $fh = $prog->open("-c \"$command\"");
warn "Running command: \"". $prog->last_command() ."\"\n" if $verbose;
$fh->autoflush(1);
my @output;
while (<$fh>)
{
warn $_ if $verbose;
chomp $_;
push @output, $_;
}
$fh->close;
my $exit_status = $?/256;
unless ($exit_status == 0)
{
if ($dont_fail_on_error)
{
warn "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n" if $verbose;
}
else
{
die "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
}
}
return wantarray ? @output : join "\n", @output;
}
+19
View File
@@ -0,0 +1,19 @@
Q = @
PERL = /usr/bin/perl
TEST_VERBOSE = 0
ifeq ($(TARGET_BOARD),)
TARGET_BOARD = *
endif
TEST_FILES := $(shell ls $(TARGET_BOARD)/*.t)
ifneq ($(JUNIT),)
PERLENV=PERL_TEST_HARNESS_DUMP_TAP=$(PAPARAZZI_SRC)/tests/results
RUNTESTS=use TAP::Harness; TAP::Harness->new({ formatter_class => 'TAP::Formatter::JUnit', verbosity => $(TEST_VERBOSE), merge => 1, } )->runtests(qw($(TEST_FILES)))
else
PERLENV=
RUNTESTS=use TAP::Harness;TAP::Harness->new( { verbosity => $(TEST_VERBOSE) } )->runtests(qw($(TEST_FILES)))
endif
test:
$(Q)$(PERLENV) $(PERL) "-e" "$(RUNTESTS)"
@@ -0,0 +1,109 @@
#!/usr/bin/perl -w
use Test::More;
use lib "$ENV{'PAPARAZZI_SRC'}/tests/lib";
use XML::Simple;
use Program;
use Data::Dumper;
use Config;
$|++;
my $examples = XMLin("$ENV{'PAPARAZZI_SRC'}/conf/conf.xml.example");
use Data::Dumper;
ok(1, "Parsed the example file");
foreach my $example (sort keys%{$examples->{'aircraft'}})
{
#next unless $example =~ m#easystar#i;
my $airframe = $examples->{'aircraft'}->{$example}->{'airframe'};
my $airframe_config = XMLin("$ENV{'PAPARAZZI_SRC'}/conf/$airframe");
foreach my $process (sort keys %{$airframe_config->{'firmware'}})
{
if ($process =~ m#setup|fixedwing|rotorcraft|lisa_test_progs#)
{
#warn "EX: [$example] ". Dumper($airframe_config->{'firmware'}->{$process}->{'target'});
foreach my $target (sort keys %{$airframe_config->{'firmware'}->{$process}->{'target'}})
{
next unless scalar $airframe_config->{'firmware'}->{$process}->{'target'}->{$target}->{'board'};
# Exclude some builds on Mac as they are currently broken.
next if ( ($Config{'osname'} =~ m#darwin#i) and ($example =~ m#LISA_ASCTEC_PIOTR|LisaLv11_Booz2v12_RC|BOOZ2_A1#i) and ($target =~ m#sim#i) );
#warn "EXAMPLE: [$example] TARGET: [$target]\n";
my $make_upload_options = "AIRCRAFT=$example clean_ac $target.compile";
my $upload_output = run_program(
"Attempting to build the firmware $target for the airframe $example.",
$ENV{'PAPARAZZI_SRC'},
"make $make_upload_options",
$ENV->{'TEST_VERBOSE'},1);
unlike($upload_output, '/\bError\b/i', "The upload output does not contain the word \"Error\"");
}
}
elsif ($process =~ m#target#)
{
#warn "EXT: [$example] ". Dumper($airframe_config->{'firmware'}->{$process});
foreach my $target (sort keys %{$airframe_config->{'firmware'}->{$process}})
{
next unless scalar $airframe_config->{'firmware'}->{$process}->{$target}->{'board'};
# Exclude some builds on Mac as they are currently broken.
next if ( ($Config{'osname'} =~ m#darwin#i) and ($example =~ m#LISA_ASCTEC_PIOTR|LisaLv11_Booz2v12_RC|BOOZ2_A1#i) and ($target =~ m#sim#i) );
#warn "EXAMPLET: [$example] TARGET: [$target]\n";
my $make_upload_options = "AIRCRAFT=$example clean_ac $target.compile";
my $upload_output = run_program(
"Attempting to build the firmware $target for the airframe $example.",
$ENV{'PAPARAZZI_SRC'},
"make $make_upload_options",
$ENV->{'TEST_VERBOSE'},1);
unlike($upload_output, '/\bError\b/i', "The upload output does not contain the word \"Error\"");
}
}
}
}
done_testing();
################################################################################
# functions used by this test script.
sub run_program
{
my $message = shift;
my $dir = shift;
my $command = shift;
my $verbose = shift;
my $dont_fail_on_error = shift;
warn "$message\n" if $verbose;
if (defined $dir)
{
$command = "cd $dir;" . $command;
}
my $prog = new Program("bash");
my $fh = $prog->open("-c \"$command\"");
warn "Running command: \"". $prog->last_command() ."\"\n" if $verbose;
$fh->autoflush(1);
my @output;
while (<$fh>)
{
warn $_ if $verbose;
chomp $_;
push @output, $_;
}
$fh->close;
my $exit_status = $?/256;
unless ($exit_status == 0)
{
if ($dont_fail_on_error)
{
warn "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n" if $verbose;
}
else
{
die "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
}
}
return wantarray ? @output : join "\n", @output;
}
+3091
View File
File diff suppressed because it is too large Load Diff
+477
View File
@@ -0,0 +1,477 @@
# Proc::Background: Generic interface to background process management.
#
# Copyright (C) 1998-2005 Blair Zajac. All rights reserved.
package Proc::Background;
require 5.004_04;
use strict;
use Exporter;
use Carp;
use Cwd;
use vars qw(@ISA $VERSION @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(timeout_system);
$VERSION = sprintf '%d.%02d', '$Revision: 1.10 $' =~ /(\d+)\.(\d+)/;
# Determine if the operating system is Windows.
my $is_windows = $^O eq 'MSWin32';
# Set up a regular expression that tests if the path is absolute and
# if it has a directory separator in it. Also create a list of file
# extensions of append to the programs name to look for the real
# executable.
my $is_absolute_re;
my $has_dir_element_re;
my @extensions = ('');
if ($is_windows) {
$is_absolute_re = '^(?:(?:[a-zA-Z]:[\\\\/])|(?:[\\\\/]{2}\w+[\\\\/]))';
$has_dir_element_re = "[\\\\/]";
push(@extensions, '.exe');
} else {
$is_absolute_re = "^/";
$has_dir_element_re = "/";
}
# Make this class a subclass of Proc::Win32 or Proc::Unix. Any
# unresolved method calls will go to either of these classes.
if ($is_windows) {
require Proc::Background::Win32;
unshift(@ISA, 'Proc::Background::Win32');
} else {
require Proc::Background::Unix;
unshift(@ISA, 'Proc::Background::Unix');
}
# Take either a relative or absolute path to a command and make it an
# absolute path.
sub _resolve_path {
my $command = shift;
return unless length $command;
# Make the path to the progam absolute if it isn't already. If the
# path is not absolute and if the path contains a directory element
# separator, then only prepend the current working to it. If the
# path is not absolute, then look through the PATH environment to
# find the executable. In all cases, look for the programs with any
# extensions added to the original path name.
my $path;
if ($command =~ /$is_absolute_re/o) {
foreach my $ext (@extensions) {
my $p = "$command$ext";
if (-f $p and -x _) {
$path = $p;
last;
}
}
unless (defined $path) {
warn "$0: no executable program located at $command\n";
}
} else {
my $cwd = cwd;
if ($command =~ /$has_dir_element_re/o) {
my $p1 = "$cwd/$command";
foreach my $ext (@extensions) {
my $p2 = "$p1$ext";
if (-f $p2 and -x _) {
$path = $p2;
last;
}
}
} else {
foreach my $dir (split($is_windows ? ';' : ':', $ENV{PATH})) {
next unless length $dir;
$dir = "$cwd/$dir" unless $dir =~ /$is_absolute_re/o;
my $p1 = "$dir/$command";
foreach my $ext (@extensions) {
my $p2 = "$p1$ext";
if (-f $p2 and -x _) {
$path = $p2;
last;
}
}
last if defined $path;
}
}
unless (defined $path) {
warn "$0: cannot find absolute location of $command\n";
}
}
$path;
}
# We want the created object to live in Proc::Background instead of
# the OS specific class so that generic method calls can be used.
sub new {
my $class = shift;
my $options;
if (@_ and defined $_[0] and UNIVERSAL::isa($_[0], 'HASH')) {
$options = shift;
}
unless (@_ > 0) {
confess "Proc::Background::new called with insufficient number of arguments";
}
return unless defined $_[0];
my $self = $class->SUPER::_new(@_) or return;
# Save the start time of the class.
$self->{_start_time} = time;
# Handle the specific options.
if ($options) {
$self->{_die_upon_destroy} = $options->{die_upon_destroy};
}
bless $self, $class;
}
sub DESTROY {
my $self = shift;
if ($self->{_die_upon_destroy}) {
$self->die;
}
}
# Reap the child. If the first argument is 0 the wait should return
# immediately, 1 if it should wait forever. If this number is
# non-zero, then wait. If the wait was sucessful, then delete
# $self->{_os_obj} and set $self->{_exit_value} to the OS specific
# class return of _reap. Return 1 if we sucessfully waited, 0
# otherwise.
sub _reap {
my $self = shift;
my $timeout = shift || 0;
return 0 unless exists($self->{_os_obj});
# Try to wait on the process. Use the OS dependent wait call using
# the Proc::Background::*::waitpid call, which returns one of three
# values.
# (0, exit_value) : sucessfully waited on.
# (1, undef) : process already reaped and exist value lost.
# (2, undef) : process still running.
my ($result, $exit_value) = $self->_waitpid($timeout);
if ($result == 0 or $result == 1) {
$self->{_exit_value} = defined($exit_value) ? $exit_value : 0;
delete $self->{_os_obj};
# Save the end time of the class.
$self->{_end_time} = time;
return 1;
}
return 0;
}
sub alive {
my $self = shift;
# If $self->{_os_obj} is not set, then the process is definitely
# not running.
return 0 unless exists($self->{_os_obj});
# If $self->{_exit_value} is set, then the process has already finished.
return 0 if exists($self->{_exit_value});
# Try to reap the child. If it doesn't reap, then it's alive.
!$self->_reap(0);
}
sub wait {
my $self = shift;
# If neither _os_obj or _exit_value are set, then something is wrong.
if (!exists($self->{_exit_value}) and !exists($self->{_os_obj})) {
return;
}
# If $self->{_exit_value} exists, then we already waited.
return $self->{_exit_value} if exists($self->{_exit_value});
# Otherwise, wait forever for the process to finish.
$self->_reap(1);
return $self->{_exit_value};
}
sub die {
my $self = shift;
# See if the process has already died.
return 1 unless $self->alive;
# Kill the process using the OS specific method.
$self->_die;
# See if the process is still alive.
!$self->alive;
}
sub start_time {
$_[0]->{_start_time};
}
sub end_time {
$_[0]->{_end_time};
}
sub pid {
$_[0]->{_pid};
}
sub timeout_system {
unless (@_ > 1) {
confess "$0: timeout_system passed too few arguments.\n";
}
my $timeout = shift;
unless ($timeout =~ /^\d+(?:\.\d*)?$/ or $timeout =~ /^\.\d+$/) {
confess "$0: timeout_system passed a non-positive number first argument.\n";
}
my $proc = Proc::Background->new(@_) or return;
my $end_time = $proc->start_time + $timeout;
while ($proc->alive and time < $end_time) {
sleep(1);
}
my $alive = $proc->alive;
if ($alive) {
$proc->die;
}
if (wantarray) {
return ($proc->wait, $alive);
} else {
return $proc->wait;
}
}
1;
__END__
=pod
=head1 NAME
Proc::Background - Generic interface to Unix and Win32 background process management
=head1 SYNOPSIS
use Proc::Background;
timeout_system($seconds, $command, $arg1);
timeout_system($seconds, "$command $arg1");
my $proc1 = Proc::Background->new($command, $arg1, $arg2);
my $proc2 = Proc::Background->new("$command $arg1 1>&2");
$proc1->alive;
$proc1->die;
$proc1->wait;
my $time1 = $proc1->start_time;
my $time2 = $proc1->end_time;
# Add an option to kill the process with die when the variable is
# DETROYed.
my $opts = {'die_upon_destroy' => 1};
my $proc3 = Proc::Background->new($opts, $command, $arg1, $arg2);
$proc3 = undef;
=head1 DESCRIPTION
This is a generic interface for placing processes in the background on
both Unix and Win32 platforms. This module lets you start, kill, wait
on, retrieve exit values, and see if background processes still exist.
=head1 METHODS
=over 4
=item B<new> [options] I<command>, [I<arg>, [I<arg>, ...]]
=item B<new> [options] 'I<command> [I<arg> [I<arg> ...]]'
This creates a new background process. As exec() or system() may be
passed an array with a single single string element containing a
command to be passed to the shell or an array with more than one
element to be run without calling the shell, B<new> has the same
behavior.
In certain cases B<new> will attempt to find I<command> on the system
and fail if it cannot be found.
For Win32 operating systems:
The Win32::Process module is always used to spawn background
processes on the Win32 platform. This module always takes a
single string argument containing the executable's name and
any option arguments. In addition, it requires that the
absolute path to the executable is also passed to it. If
only a single argument is passed to new, then it is split on
whitespace into an array and the first element of the split
array is used at the executable's name. If multiple
arguments are passed to new, then the first element is used
as the executable's name.
If the executable's name is an absolute path, then new
checks to see if the executable exists in the given location
or fails otherwise. If the executable's name is not
absolute, then the executable is searched for using the PATH
environmental variable. The input executable name is always
replaced with the absolute path determined by this process.
In addition, when searching for the executable, the
executable is searched for using the unchanged executable
name and if that is not found, then it is checked by
appending `.exe' to the name in case the name was passed
without the `.exe' suffix.
Finally, the argument array is placed back into a single
string and passed to Win32::Process::Create.
For non-Win32 operating systems, such as Unix:
If more than one argument is passed to new, then new
assumes that the command will not be passed through the
shell and the first argument is the executable's relative
or absolute path. If the first argument is an absolute
path, then it is checked to see if it exists and can be
run, otherwise new fails. If the path is not absolute,
then the PATH environmental variable is checked to see if
the executable can be found. If the executable cannot be
found, then new fails. These steps are taking to prevent
exec() from failing after an fork() without the caller of
new knowing that something failed.
The first argument to B<new> I<options> may be a reference to a hash
which contains key/value pairs to modify Proc::Background's behavior.
Currently the only key understood by B<new> is I<die_upon_destroy>.
When this value is set to true, then when the Proc::Background object
is being DESTROY'ed for any reason (i.e. the variable goes out of
scope) the process is killed via the die() method.
If anything fails, then new returns an empty list in a list context,
an undefined value in a scalar context, or nothing in a void context.
=item B<pid>
Returns the process ID of the created process. This value is saved
even if the process has already finished.
=item B<alive>
Return 1 if the process is still active, 0 otherwise.
=item B<die>
Reliably try to kill the process. Returns 1 if the process no longer
exists once B<die> has completed, 0 otherwise. This will also return
1 if the process has already died. On Unix, the following signals are
sent to the process in one second intervals until the process dies:
HUP, QUIT, INT, KILL.
=item B<wait>
Wait for the process to exit. Return the exit status of the command
as returned by wait() on the system. To get the actual exit value,
divide by 256 or right bit shift by 8, regardless of the operating
system being used. If the process never existed, then return an empty
list in a list context, an undefined value in a scalar context, or
nothing in a void context. This function may be called multiple times
even after the process has exited and it will return the same exit
status.
=item B<start_time>
Return the value that the Perl function time() returned when the
process was started.
=item B<end_time>
Return the value that the Perl function time() returned when the exit
status was obtained from the process.
=back
=head1 FUNCTIONS
=over 4
=item B<timeout_system> I<timeout>, I<command>, [I<arg>, [I<arg>...]]
=item B<timeout_system> 'I<timeout> I<command> [I<arg> [I<arg>...]]'
Run a command for I<timeout> seconds and if the process did not exit,
then kill it. While the timeout is implemented using sleep(), this
function makes sure that the full I<timeout> is reached before killing
the process. B<timeout_system> does not wait for the complete
I<timeout> number of seconds before checking if the process has
exited. Rather, it sleeps repeatidly for 1 second and checks to see
if the process still exists.
In a scalar context, B<timeout_system> returns the exit status from
the process. In an array context, B<timeout_system> returns a two
element array, where the first element is the exist status from the
process and the second is set to 1 if the process was killed by
B<timeout_system> or 0 if the process exited by itself.
The exit status is the value returned from the wait() call. If the
process was killed, then the return value will include the killing of
it. To get the actual exit value, divide by 256.
If something failed in the creation of the process, the subroutine
returns an empty list in a list context, an undefined value in a
scalar context, or nothing in a void context.
=back
=head1 IMPLEMENTATION
I<Proc::Background> comes with two modules, I<Proc::Background::Unix>
and I<Proc::Background::Win32>. Currently, on Unix platforms
I<Proc::Background> uses the I<Proc::Background::Unix> class and on
Win32 platforms it uses I<Proc::Background::Win32>, which makes use of
I<Win32::Process>.
The I<Proc::Background> assigns to @ISA either
I<Proc::Background::Unix> or I<Proc::Background::Win32>, which does
the OS dependent work. The OS independent work is done in
I<Proc::Background>.
Proc::Background uses two variables to keep track of the process.
$self->{_os_obj} contains the operating system object to reference the
process. On a Unix systems this is the process id (pid). On Win32,
it is an object returned from the I<Win32::Process> class. When
$self->{_os_obj} exists, then the process is running. When the
process dies, this is recorded by deleting $self->{_os_obj} and saving
the exit value $self->{_exit_value}.
Anytime I<alive> is called, a waitpid() is called on the process and
the return status, if any, is gathered and saved for a call to
I<wait>. This module does not install a signal handler for SIGCHLD.
If for some reason, the user has installed a signal handler for
SIGCHLD, then, then when this module calls waitpid(), the failure will
be noticed and taken as the exited child, but it won't be able to
gather the exit status. In this case, the exit status will be set to
0.
=head1 SEE ALSO
See also L<Proc::Background::Unix> and L<Proc::Background::Win32>.
=head1 AUTHOR
Blair Zajac <blair@orcaware.com>
=head1 COPYRIGHT
Copyright (C) 1998-2005 Blair Zajac. All rights reserved. This
package is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
+138
View File
@@ -0,0 +1,138 @@
# Proc::Background::Unix: Unix interface to background process management.
#
# Copyright (C) 1998-2005 Blair Zajac. All rights reserved.
package Proc::Background::Unix;
require 5.004_04;
use strict;
use Exporter;
use Carp;
use POSIX qw(:errno_h :sys_wait_h);
use vars qw(@ISA $VERSION);
@ISA = qw(Exporter);
$VERSION = sprintf '%d.%02d', '$Revision: 1.10 $' =~ /(\d+)\.(\d+)/;
# Start the background process. If it is started sucessfully, then record
# the process id in $self->{_os_obj}.
sub _new {
my $class = shift;
unless (@_ > 0) {
confess "Proc::Background::Unix::_new called with insufficient number of arguments";
}
return unless defined $_[0];
# If there is only one element in the @_ array, then it may be a
# command to be passed to the shell and should not be checked, in
# case the command sets environmental variables in the beginning,
# i.e. 'VAR=arg ls -l'. If there is more than one element in the
# array, then check that the first element is a valid executable
# that can be found through the PATH and find the absolute path to
# the executable. If the executable is found, then replace the
# first element it with the absolute path.
my @args = @_;
if (@_ > 1) {
$args[0] = Proc::Background::_resolve_path($args[0]) or return;
}
my $self = bless {}, $class;
# Fork a child process.
my $pid;
{
if ($pid = fork()) {
# parent
$self->{_os_obj} = $pid;
$self->{_pid} = $pid;
last;
} elsif (defined $pid) {
# child
exec @_ or croak "$0: exec failed: $!\n";
} elsif ($! == EAGAIN) {
sleep 5;
redo;
} else {
return;
}
}
$self;
}
# Wait for the child.
sub _waitpid {
my $self = shift;
my $timeout = shift;
{
# Try to wait on the process.
my $result = waitpid($self->{_os_obj}, $timeout ? 0 : WNOHANG);
# Process finished. Grab the exit value.
if ($result == $self->{_os_obj}) {
return (0, $?);
}
# Process already reaped. We don't know the exist status.
elsif ($result == -1 and $! == ECHILD) {
return (1, 0);
}
# Process still running.
elsif ($result == 0) {
return (2, 0);
}
# If we reach here, then waitpid caught a signal, so let's retry it.
redo;
}
return 0;
}
sub _die {
my $self = shift;
# Try to kill the process with different signals. Calling alive() will
# collect the exit status of the program.
SIGNAL: {
foreach my $signal (qw(HUP QUIT INT KILL)) {
my $count = 5;
while ($count and $self->alive) {
--$count;
kill($signal, $self->{_os_obj});
last SIGNAL unless $self->alive;
sleep 1;
}
}
}
}
1;
__END__
=head1 NAME
Proc::Background::Unix - Unix interface to process mangement
=head1 SYNOPSIS
Do not use this module directly.
=head1 DESCRIPTION
This is a process management class designed specifically for Unix
operating systems. It is not meant used except through the
I<Proc::Background> class. See L<Proc::Background> for more information.
=head1 AUTHOR
Blair Zajac <blair@orcaware.com>
=head1 COPYRIGHT
Copyright (C) 1998-2005 Blair Zajac. All rights reserved. This
package is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
+157
View File
@@ -0,0 +1,157 @@
# Proc::Background::Win32 Windows interface to background process management.
#
# Copyright (C) 1998-2005 Blair Zajac. All rights reserved.
package Proc::Background::Win32;
require 5.004_04;
use strict;
use Exporter;
use Carp;
use vars qw(@ISA $VERSION);
@ISA = qw(Exporter);
$VERSION = sprintf '%d.%02d', '$Revision: 1.10 $' =~ /(\d+)\.(\d+)/;
BEGIN {
eval "use Win32";
$@ and die "Proc::Background::Win32 needs Win32 from libwin32-?.??.zip to run.\n";
eval "use Win32::Process";
$@ and die "Proc::Background::Win32 needs Win32::Process from libwin32-?.??.zip to run.\n";
}
sub _new {
my $class = shift;
unless (@_ > 0) {
confess "Proc::Background::Win32::_new called with insufficient number of arguments";
}
return unless defined $_[0];
# If there is only one element in the @_ array, then just split the
# argument by whitespace. If there is more than one element in @_,
# then assume that each argument should be properly protected from
# the shell so that whitespace and special characters are passed
# properly to the program, just as it would be in a Unix
# environment. This will ensure that a single argument with
# whitespace will not be split into multiple arguments by the time
# the program is run. Make sure that any arguments that are already
# protected stay protected. Then convert unquoted "'s into \"'s.
# Finally, check for whitespace and protect it.
my @args;
if (@_ == 1) {
@args = split(' ', $_[0]);
} else {
@args = @_;
for (my $i=1; $i<@args; ++$i) {
my $arg = $args[$i];
$arg =~ s#\\\\#\200#g;
$arg =~ s#\\"#\201#g;
$arg =~ s#"#\\"#g;
$arg =~ s#\200#\\\\#g;
$arg =~ s#\201#\\"#g;
if (length($arg) == 0 or $arg =~ /\s/) {
$arg = "\"$arg\"";
}
$args[$i] = $arg;
}
}
# Find the absolute path to the program. If it cannot be found,
# then return. To work around a problem where
# Win32::Process::Create cannot start a process when the full
# pathname has a space in it, convert the full pathname to the
# Windows short 8.3 format which contains no spaces.
$args[0] = Proc::Background::_resolve_path($args[0]) or return;
$args[0] = Win32::GetShortPathName($args[0]);
my $self = bless {}, $class;
# Perl 5.004_04 cannot run Win32::Process::Create on a nonexistant
# hash key.
my $os_obj = 0;
# Create the process.
if (Win32::Process::Create($os_obj,
$args[0],
"@args",
0,
NORMAL_PRIORITY_CLASS,
'.')) {
$self->{_pid} = $os_obj->GetProcessID;
$self->{_os_obj} = $os_obj;
return $self;
} else {
return;
}
}
# Reap the child.
sub _waitpid {
my ($self, $timeout) = @_;
# Try to wait on the process.
my $result = $self->{_os_obj}->Wait($timeout ? INFINITE : 0);
# Process finished. Grab the exit value.
if ($result == 1) {
my $_exit_status;
$self->{_os_obj}->GetExitCode($_exit_status);
return (0, $_exit_status<<8);
}
# Process still running.
elsif ($result == 0) {
return (2, 0);
}
# If we reach here, then something odd happened.
return (0, 1<<8);
}
sub _die {
my $self = shift;
# Try the kill the process several times. Calling alive() will
# collect the exit status of the program.
my $count = 5;
while ($count and $self->alive) {
--$count;
$self->{_os_obj}->Kill(1<<8);
last unless $self->alive;
sleep 1;
}
}
1;
__END__
=head1 NAME
Proc::Background::Win32 - Interface to process mangement on Win32 systems
=head1 SYNOPSIS
Do not use this module directly.
=head1 DESCRIPTION
This is a process management class designed specifically for Win32
operating systems. It is not meant used except through the
I<Proc::Background> class. See L<Proc::Background> for more information.
=head1 IMPLEMENTATION
This package uses the Win32::Process class to manage the objects.
=head1 AUTHOR
Blair Zajac <blair@orcaware.com>
=head1 COPYRIGHT
Copyright (C) 1998-2005 Blair Zajac. All rights reserved. This
package is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
+304
View File
@@ -0,0 +1,304 @@
=head1 SYNOPSIS
use Program;
my $m_program = new Program('ls');
=head1 DESCRIPTION
Program is a generic program wrapper that allows easy use of programs on
multipul platforms with the correct file handle redirection.
=head1 FUNCTIONS
=cut
package Program;
###################
# Standard Modules
use strict;
use Config;
use FileHandle;
###################
# Variables
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
@ISA = qw();
@EXPORT = qw();
@EXPORT_OK = qw();
$VERSION = 0.04;
# This hash contains the values for redirection.
my %m_redirect_values;
# Standard values
$m_redirect_values{'none'} = '';
$m_redirect_values{'stdout&stderr2stdout'} = '2>&1';
$m_redirect_values{'stdout&stderr2stderr'} = '1>&2';
$m_redirect_values{'stdout2stderr&stderr2stdout'} = '3>&1 1>&2 2>&3 3>&-';
# Platform specific values
if ($Config{'osname'} eq 'MSWin32')
{
if ($Config{'osvers'} ge 4.0)
{
$m_redirect_values{'stdout2stdnull'} = '1>NUL';
$m_redirect_values{'stderr2stdnull'} = '2>NUL';
}
else
{
$m_redirect_values{'stdout2stdnull'} = '1>';
$m_redirect_values{'stderr2stdnull'} = '2>';
}
}
else
{
$m_redirect_values{'stdout2stdnull'} = '1>/dev/null';
$m_redirect_values{'stderr2stdnull'} = '2>/dev/null';
}
###################
# Functions
################################################################################
# Function: new()
=head2 B<new()>
Description: This method returns an objective interface the the passed program.
Arguments: $program
Return: class
Usage: my $ls = new Program('ls');
=cut
sub new
{
my $class = shift;
my $program = shift;
my $self = bless {}, $class;
$self->{'PROGRAM'} = $program;
$self->{'CHOMP'} = 1;
$self->{'REDIRECT'} = 'stdout&stderr2stdout';
$self->{'LAST_COMMAND'} = "No commands have been executed yet.";
$self->{'EXIT_STATUS'} = 0;
return $self;
}
################################################################################
# Function: strip_new_lines()
=head2 B<strip_new_lines()>
Description: This functions is used to set wether the output from a command
has trailing new lines removed.
Arguments: 0 to turn chomping off
1 to turn chomping on
Default: 1
Return: true if chomping is on else undef
Usage: $ls->strip_new_lines(1);
$ls->strip_new_lines(0);
=cut
sub strip_new_lines
{
my $self = shift;
my $value = shift;
if (scalar $value)
{
$self->{'CHOMP'} = $value;
}
else
{
return $self->{'CHOMP'};
}
}
################################################################################
# Function: redirect()
=head2 B<redirect()>
Description: This functions is used to set the STDOUT and STDERR redirection
for commands executed by the program.
Arguments: possible values are stdout&stderr2stdout, stdout&stderr2stderr
stdout2stderr&stderr2stdout, stdout2stdnull, stderr2stdnull
Default: sdtout&stderr2stdout
Return: redirection option if nothing passed else set the redirection
Usage: $ls->redirect('stderr2sdtnull');
=cut
sub redirect
{
my $self = shift;
my $value = shift;
if (scalar $value)
{
$self->{'REDIRECT'} = $value;
}
else
{
return $m_redirect_values{$self->{'REDIRECT'}};
}
}
################################################################################
# Function: last_command()
=head2 B<last_command()>
Description: This function returns the last command executed.
Arguments: None.
Return: The last command
Usage: print $ls->last_command();
=cut
sub last_command
{
my $self = shift;
return $self->{'LAST_COMMAND'};
}
################################################################################
# Function: output()
=head2 B<output()>
Description: This function returns the output from a program.
Arguments: command to execute.
Return: array if called in an array context else string
Usage: my $output = $ls->output("-l");
my @output = $ls->output("-l");
=cut
sub output
{
my $self = shift;
my $command = shift;
my $exec_command = "$self->{'PROGRAM'} $command " . $self->redirect();
$self->{'LAST_COMMAND'} = $exec_command;
my @output_list;
my $output_line;
if (wantarray)
{
@output_list = `$exec_command`;
foreach my $line (@output_list)
{
chomp $line if $self->strip_new_lines();
}
}
else
{
$output_line = `$exec_command`;
chomp $output_line if $self->strip_new_lines();
}
$self->{'EXIT_STATUS'} = $?/256;
return wantarray ? @output_list : $output_line;
}
################################################################################
# Function: status()
=head2 B<status()>
Description: This function returns the exit status of the last
command.
Arguments: None.
Return: exit status.
Usage: my $status = $ls->status();
=cut
sub status
{
my $self = shift;
return $self->{'EXIT_STATUS'};
}
################################################################################
# Function: success()
=head2 B<success()>
Description: This function returns true if the last command was successful
Arguments: None.
Return: true for success else undef.
Usage: if ($ls->success())
{
Print "Success\n";
}
else
{
Print "Failure\n";
}
=cut
sub success
{
my $self = shift;
return 1 if $self->status() eq 0;
return undef
}
################################################################################
# Function: open()
=head2 B<open()>
Description: This function returns an open file handle for the passed command
NOTE: Since the exit status of the file handle cannot be
retrieved by this module the user must check the exit status of
the file handle using the $fh->error() method. See IO::Handle.
Arguments: command to execute.
Return: open file handle.
Usage: my $fh = $ls->open("-l)
while (<$fh>)
{
print "$_\n";
}
=cut
sub open
{
my $self = shift;
my $command = shift;
my $exec_command = "$self->{'PROGRAM'} $command " . $self->redirect() ." |";
$self->{'LAST_COMMAND'} = $exec_command;
$self->{'EXIT_STATUS'} = 0;
my $fh = new FileHandle($exec_command);
return $fh;
}
1;
__END__
=head1 SEE ALSO
FileHandle
=head1 AUTHOR
Bernard Davison bernard@gondwana.com.au
=head1 COPYRIGHT
Copyright (C) 2000, Gondwanatech.
=cut
+583
View File
File diff suppressed because it is too large Load Diff
+379
View File
@@ -0,0 +1,379 @@
# $Id$
package XML::SAX;
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
$VERSION = '0.99';
use Exporter ();
@ISA = ('Exporter');
@EXPORT_OK = qw(Namespaces Validation);
use File::Basename qw(dirname);
use File::Spec ();
use Symbol qw(gensym);
use XML::SAX::ParserFactory (); # loaded for simplicity
use constant PARSER_DETAILS => "ParserDetails.ini";
use constant Namespaces => "http://xml.org/sax/features/namespaces";
use constant Validation => "http://xml.org/sax/features/validation";
my $known_parsers = undef;
# load_parsers takes the ParserDetails.ini file out of the same directory
# that XML::SAX is in, and looks at it. Format in POD below
=begin EXAMPLE
[XML::SAX::PurePerl]
http://xml.org/sax/features/namespaces = 1
http://xml.org/sax/features/validation = 0
# a comment
# blank lines ignored
[XML::SAX::AnotherParser]
http://xml.org/sax/features/namespaces = 0
http://xml.org/sax/features/validation = 1
=end EXAMPLE
=cut
sub load_parsers {
my $class = shift;
my $dir = shift;
# reset parsers
$known_parsers = [];
# get directory from wherever XML::SAX is installed
if (!$dir) {
$dir = $INC{'XML/SAX.pm'};
$dir = dirname($dir);
}
my $fh = gensym();
if (!open($fh, File::Spec->catfile($dir, "SAX", PARSER_DETAILS))) {
XML::SAX->do_warn("could not find " . PARSER_DETAILS . " in $dir/SAX\n");
return $class;
}
$known_parsers = $class->_parse_ini_file($fh);
return $class;
}
sub _parse_ini_file {
my $class = shift;
my ($fh) = @_;
my @config;
my $lineno = 0;
while (defined(my $line = <$fh>)) {
$lineno++;
my $original = $line;
# strip whitespace
$line =~ s/\s*$//m;
$line =~ s/^\s*//m;
# strip comments
$line =~ s/[#;].*$//m;
# ignore blanks
next if $line =~ /^$/m;
# heading
if ($line =~ /^\[\s*(.*)\s*\]$/m) {
push @config, { Name => $1 };
next;
}
# instruction
elsif ($line =~ /^(.*?)\s*?=\s*(.*)$/) {
unless(@config) {
push @config, { Name => '' };
}
$config[-1]{Features}{$1} = $2;
}
# not whitespace, comment, or instruction
else {
die "Invalid line in ini: $lineno\n>>> $original\n";
}
}
return \@config;
}
sub parsers {
my $class = shift;
if (!$known_parsers) {
$class->load_parsers();
}
return $known_parsers;
}
sub remove_parser {
my $class = shift;
my ($parser_module) = @_;
if (!$known_parsers) {
$class->load_parsers();
}
@$known_parsers = grep { $_->{Name} ne $parser_module } @$known_parsers;
return $class;
}
sub add_parser {
my $class = shift;
my ($parser_module) = @_;
if (!$known_parsers) {
$class->load_parsers();
}
# first load module, then query features, then push onto known_parsers,
my $parser_file = $parser_module;
$parser_file =~ s/::/\//g;
$parser_file .= ".pm";
require $parser_file;
my @features = $parser_module->supported_features();
my $new = { Name => $parser_module };
foreach my $feature (@features) {
$new->{Features}{$feature} = 1;
}
# If exists in list already, move to end.
my $done = 0;
my $pos = undef;
for (my $i = 0; $i < @$known_parsers; $i++) {
my $p = $known_parsers->[$i];
if ($p->{Name} eq $parser_module) {
$pos = $i;
}
}
if (defined $pos) {
splice(@$known_parsers, $pos, 1);
push @$known_parsers, $new;
$done++;
}
# Otherwise (not in list), add at end of list.
if (!$done) {
push @$known_parsers, $new;
}
return $class;
}
sub save_parsers {
my $class = shift;
# get directory from wherever XML::SAX is installed
my $dir = $INC{'XML/SAX.pm'};
$dir = dirname($dir);
my $file = File::Spec->catfile($dir, "SAX", PARSER_DETAILS);
chmod 0644, $file;
unlink($file);
my $fh = gensym();
open($fh, ">$file") ||
die "Cannot write to $file: $!";
foreach my $p (@$known_parsers) {
print $fh "[$p->{Name}]\n";
foreach my $key (keys %{$p->{Features}}) {
print $fh "$key = $p->{Features}{$key}\n";
}
print $fh "\n";
}
print $fh "\n";
close $fh;
return $class;
}
sub do_warn {
my $class = shift;
# Don't output warnings if running under Test::Harness
warn(@_) unless $ENV{HARNESS_ACTIVE};
}
1;
__END__
=head1 NAME
XML::SAX - Simple API for XML
=head1 SYNOPSIS
use XML::SAX;
# get a list of known parsers
my $parsers = XML::SAX->parsers();
# add/update a parser
XML::SAX->add_parser(q(XML::SAX::PurePerl));
# remove parser
XML::SAX->remove_parser(q(XML::SAX::Foodelberry));
# save parsers
XML::SAX->save_parsers();
=head1 DESCRIPTION
XML::SAX is a SAX parser access API for Perl. It includes classes
and APIs required for implementing SAX drivers, along with a factory
class for returning any SAX parser installed on the user's system.
=head1 USING A SAX2 PARSER
The factory class is XML::SAX::ParserFactory. Please see the
documentation of that module for how to instantiate a SAX parser:
L<XML::SAX::ParserFactory>. However if you don't want to load up
another manual page, here's a short synopsis:
use XML::SAX::ParserFactory;
use XML::SAX::XYZHandler;
my $handler = XML::SAX::XYZHandler->new();
my $p = XML::SAX::ParserFactory->parser(Handler => $handler);
$p->parse_uri("foo.xml");
# or $p->parse_string("<foo/>") or $p->parse_file($fh);
This will automatically load a SAX2 parser (defaulting to
XML::SAX::PurePerl if no others are found) and return it to you.
In order to learn how to use SAX to parse XML, you will need to read
L<XML::SAX::Intro> and for reference, L<XML::SAX::Specification>.
=head1 WRITING A SAX2 PARSER
The first thing to remember in writing a SAX2 parser is to subclass
XML::SAX::Base. This will make your life infinitely easier, by providing
a number of methods automagically for you. See L<XML::SAX::Base> for more
details.
When writing a SAX2 parser that is compatible with XML::SAX, you need
to inform XML::SAX of the presence of that driver when you install it.
In order to do that, XML::SAX contains methods for saving the fact that
the parser exists on your system to a "INI" file, which is then loaded
to determine which parsers are installed.
The best way to do this is to follow these rules:
=over 4
=item * Add XML::SAX as a prerequisite in Makefile.PL:
WriteMakefile(
...
PREREQ_PM => { 'XML::SAX' => 0 },
...
);
Alternatively you may wish to check for it in other ways that will
cause more than just a warning.
=item * Add the following code snippet to your Makefile.PL:
sub MY::install {
package MY;
my $script = shift->SUPER::install(@_);
if (ExtUtils::MakeMaker::prompt(
"Do you want to modify ParserDetails.ini?", 'Y')
=~ /^y/i) {
$script =~ s/install :: (.*)$/install :: $1 install_sax_driver/m;
$script .= <<"INSTALL";
install_sax_driver :
\t\@\$(PERL) -MXML::SAX -e "XML::SAX->add_parser(q(\$(NAME)))->save_parsers()"
INSTALL
}
return $script;
}
Note that you should check the output of this - \$(NAME) will use the name of
your distribution, which may not be exactly what you want. For example XML::LibXML
has a driver called XML::LibXML::SAX::Generator, which is used in place of
\$(NAME) in the above.
=item * Add an XML::SAX test:
A test file should be added to your t/ directory containing something like the
following:
use Test;
BEGIN { plan tests => 3 }
use XML::SAX;
use XML::SAX::PurePerl::DebugHandler;
XML::SAX->add_parser(q(XML::SAX::MyDriver));
local $XML::SAX::ParserPackage = 'XML::SAX::MyDriver';
eval {
my $handler = XML::SAX::PurePerl::DebugHandler->new();
ok($handler);
my $parser = XML::SAX::ParserFactory->parser(Handler => $handler);
ok($parser);
ok($parser->isa('XML::SAX::MyDriver');
$parser->parse_string("<tag/>");
ok($handler->{seen}{start_element});
};
=back
=head1 EXPORTS
By default, XML::SAX exports nothing into the caller's namespace. However you
can request the symbols C<Namespaces> and C<Validation> which are the
URIs for those features, allowing an easier way to request those features
via ParserFactory:
use XML::SAX qw(Namespaces Validation);
my $factory = XML::SAX::ParserFactory->new();
$factory->require_feature(Namespaces);
$factory->require_feature(Validation);
my $parser = $factory->parser();
=head1 AUTHOR
Current maintainer: Grant McLean, grantm@cpan.org
Originally written by:
Matt Sergeant, matt@sergeant.org
Kip Hampton, khampton@totalcinema.com
Robin Berjon, robin@knowscape.com
=head1 LICENSE
This is free software, you may use it and distribute it under
the same terms as Perl itself.
=head1 SEE ALSO
L<XML::SAX::Base> for writing SAX Filters and Parsers
L<XML::SAX::PurePerl> for an XML parser written in 100%
pure perl.
L<XML::SAX::Exception> for details on exception handling
=cut
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More