fix an autobug

java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.geeksville.andropilot.gui.ParameterListFragment.com$geeksville$andropilot$gui$ParameterListFragment$$updateParameters(ParameterListFragment.scala:74)
at com.geeksville.andropilot.gui.ParameterListFragment$$anonfun$onVehicleReceive$1$$anonfun$applyOrElse$2.apply(ParameterListFragment.scala:66)
at com.geeksville.andropilot.gui.ParameterListFragment$$anonfun$onVehicleReceive$1$$anonfun$applyOrElse$2.apply(ParameterListFragment.scala:66)
at com.geeksville.util.ThreadTools$$anon$1.run(ThreadTools.scala:11)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
at dalvik.system.NativeStart.main(Native Method)
begin mocking up a mavelous server
Kindly donated by Mission Motors

I asked my former employer if they would open source this small
HTTP server. And they kindly said yes.

---------- Forwarded message ----------
From: Eyal Cohen <XXX@ridemission.com>
Date: Tue, Feb 19, 2013 at 5:43 PM
Subject: Re: Mission's blessing to opensource a little bit of code?
To: Kevin Hester <kevinh@geeksville.com>

Doing great!  Hope you are as well.  I've followed your project from updates on Facebook, looks super-fun.

I just looked through the files while waiting for an excruciatingly long
Scala compile.  Blessed to open-source from Mission's end.
A note that it came from Mission would be appreciated.

Eyal

On Tue, Feb 19, 2013 at 5:23 PM, Kevin Hester <kevinh@geeksville.com> wrote:
Hi Eyal,

So for fun I've been working on a new open-source project ( http://diydrones.com/forum/topics/andropilot-alpha-tester-discussion-for-this-android-application?commentId=705844%3AComment%3A1133823 ).
Do you think I could get ya'lls blessing to open source three
files in mission-java?
1.0.05 released
Add MavServe - an http server designed to serve data to Mavulous

Hi Pat,
Here ya go.  See MavServe.scala for a beginning class that you can use
as a starting point.  Search for FIXME to see particularly important
comments.

If you hook your 3dr radio to your desktop and then do "run" in posixpilot
you should be able to surf over to

http://localhost:4404/
And get a nice html welcome screen (you should slap all your JS etc... into
the new httpcontent directory (or change that directory to a symbolic
link while developing)

You'll see a couple of interesting links on the placeholder html.
One link will take you to vehicle params as JSON:

http://localhost:4404/parameters
{"AHRS_BARO_USE":0,"AHRS_GPS_GAIN":"1.0","AHRS_GPS_USE":1,"AHRS_ORIENTATION":0,"AHRS_RP_P":"0.4","AHRS_TRIM_X":"0.0","AHRS_TRIM_Y":"0.0","AHRS_TRIM_Z":"0.0","AHRS_WIND_MAX":0,"AHRS_YAW_P":"0.2","ALT2PTCH_D":"0.0","ALT2PTCH_I":"0.1","ALT2PTCH_IMAX":500,"ALT2PTCH_P":"0.65","ALT_CTRL_ALG":0,"ALT_HOLD_FBWCM":3000,"ALT_HOLD_RTL":5000,"ALT_MIX":"1.0","ALT_OFFSET":0,"AMP_OFFSET":"0.0","AMP_PER_VOLT":"18.0018","ARSP2PTCH_D":"0.0","ARSP2PTCH_I":"0.1","ARSP2PTCH_IMAX":500,"ARSP2PTCH_P":"0.65","ARSPD_ENABLE":1,"ARSPD_FBW_MAX":22,"ARSPD_FBW_MIN":6,"ARSPD_OFFSET":"874.3545","ARSPD_RATIO":"1.9936","ARSPD_USE":0,"BATT_CAPACITY":2200,"BATT_CURR_PIN":12,"BATT_MONITOR":4,"BATT_VOLT_PIN":13,"CAM_DURATION":10,"CAM_SERVO_OFF":1100,"CAM_SERVO_ON":1300,"CAM_TRIGG_TYPE":0,"CMD_INDEX":0,"CMD_TOTAL":6,"COMPASS_AUTODEC":1,"COMPASS_DEC":"0.23569317","COMPASS_LEARN":1,"COMPASS_OFS_X":"-68.38813","COMPASS_OFS_Y":"8.65761","COMPASS_OFS_Z":"-11.714572","COMPASS_USE":1,"ELEVON_CH1_REV":0,"ELEVON_CH2_REV":0,"ELEVON_MIXING":0,"ELEVON_REVERSE":0,"ENRGY2THR_D":"0.0","ENRGY2THR_I":"0.0","ENRGY2THR_IMAX":20,"ENRGY2THR_P":"0.5","FBWB_ELEV_REV":0,"FENCE_ACTION":0,"FENCE_CHANNEL":0,"FENCE_MAXALT":0,"FENCE_MINALT":0,"FENCE_TOTAL":0,"FLAP_1_PERCNT":0,"FLAP_1_SPEED":-1,"FLAP_2_PERCNT":0,"FLAP_2_SPEED":-1,"FLTMODE1":0,"FLTMODE2":11,"FLTMODE3":2,"FLTMODE4":10,"FLTMODE5":5,"FLTMODE6":0,"FLTMODE_CH":8,"FORMAT_VERSION":13,"FS_GCS_ENABL":0,"FS_LONG_ACTN":1,"FS_SHORT_ACTN":1,"GND_ABS_PRESS":"99112.66","GND_TEMP":"22.230902","HDNG2RLL_D":"0.02","HDNG2RLL_I":"0.1","HDNG2RLL_IMAX":500,"HDNG2RLL_P":"0.7","INPUT_VOLTS":"4.68","INS_ACCOFFS_X":"-0.96357244","INS_ACCOFFS_Y":"-0.3638848","INS_ACCOFFS_Z":"0.57882404","INS_ACCSCAL_X":"1.0","INS_ACCSCAL_Y":"1.0","INS_ACCSCAL_Z":"1.0","INS_GYROFFS_X":"-0.0058665094","INS_GYROFFS_Y":"-0.029481757","INS_GYROFFS_Z":"-0.01077921","INS_MPU6K_FILTER":0,"INS_PRODUCT_ID":88,"INVERTEDFLT_CH":0,"KFF_PTCH2THR":"0.0","KFF_PTCHCOMP":"0.2","KFF_RDDRMIX":"0.5","KFF_THR2PTCH":"0.0","LAND_FLARE_ALT":"3.0","LAND_FLARE_SEC":"2.0","LAND_PITCH_CD":0,"LIM_PITCH_MAX":1500,"LIM_PITCH_MIN":-2500,"LIM_ROLL_CD":4500,"LOG_BITMASK":334,"MAG_ENABLE":1,"MANUAL_LEVEL":1,"MIN_GNDSPD_CM":0,"MNT_ANGMAX_PAN":4500,"MNT_ANGMAX_ROL":4500,"MNT_ANGMAX_TIL":4500,"MNT_ANGMIN_PAN":-4500,"MNT_ANGMIN_ROL":-4500,"MNT_ANGMIN_TIL":-4500,"MNT_CONTROL_X":"0.0","MNT_CONTROL_Y":"0.0","MNT_CONTROL_Z":"0.0","MNT_JSTICK_SPD":0,"MNT_MODE":0,"MNT_NEUTRAL_X":"0.0","MNT_NEUTRAL_Y":"0.0","MNT_NEUTRAL_Z":"0.0","MNT_RC_IN_PAN":0,"MNT_RC_IN_ROLL":0,"MNT_RC_IN_TILT":0,"MNT_RETRACT_X":"0.0","MNT_RETRACT_Y":"0.0","MNT_RETRACT_Z":"0.0","MNT_STAB_PAN":0,"MNT_STAB_ROLL":0,"MNT_STAB_TILT":0,"PTCH2SRV_D":"0.0","PTCH2SRV_I":"0.0","PTCH2SRV_IMAX":500,"PTCH2SRV_P":"1.2","RC10_DZ":0,"RC10_FUNCTION":0,"RC10_MAX":1900,"RC10_MIN":1100,"RC10_REV":1,"RC10_TRIM":1500,"RC11_DZ":0,"RC11_FUNCTION":0,"RC11_MAX":1900,"RC11_MIN":1100,"RC11_REV":1,"RC11_TRIM":1500,"RC1_DZ":30,"RC1_MAX":1878,"RC1_MIN":1504,"RC1_REV":-1,"RC1_TRIM":900,"RC2_DZ":30,"RC2_MAX":2016,"RC2_MIN":992,"RC2_REV":-1,"RC2_TRIM":900,"RC3_DZ":3,"RC3_MAX":2017,"RC3_MIN":1123,"RC3_REV":1,"RC3_TRIM":1125,"RC4_DZ":30,"RC4_MAX":1828,"RC4_MIN":1003,"RC4_REV":-1,"RC4_TRIM":900,"RC5_DZ":0,"RC5_FUNCTION":0,"RC5_MAX":1505,"RC5_MIN":1504,"RC5_REV":1,"RC5_TRIM":1504,"RC6_DZ":0,"RC6_FUNCTION":0,"RC6_MAX":1505,"RC6_MIN":1504,"RC6_REV":1,"RC6_TRIM":1504,"RC7_DZ":0,"RC7_FUNCTION":0,"RC7_MAX":1505,"RC7_MIN":1504,"RC7_REV":1,"RC7_TRIM":1505,"RC8_DZ":0,"RC8_FUNCTION":0,"RC8_MAX":1816,"RC8_MIN":1294,"RC8_REV":1,"RC8_TRIM":1815,"RC9_DZ":0,"RC9_FUNCTION":0,"RC9_MAX":1900,"RC9_MIN":1100,"RC9_REV":1,"RC9_TRIM":1500,"RLL2SRV_D":"0.0","RLL2SRV_I":"0.0","RLL2SRV_IMAX":500,"RLL2SRV_P":"0.8","RSSI_PIN":-1,"RST_MISSION_CH":0,"RST_SWITCH_CH":0,"RUDDER_STEER":0,"SCALING_SPEED":"15.0","SERIAL0_BAUD":115,"SERIAL3_BAUD":57,"SR0_EXTRA1":10,"SR0_EXTRA2":1,"SR0_EXTRA3":2,"SR0_EXT_STAT":1,"SR0_PARAMS":50,"SR0_POSITION":3,"SR0_RAW_CTRL":2,"SR0_RAW_SENS":2,"SR0_RC_CHAN":1,"SR3_EXTRA1":10,"SR3_EXTRA2":10,"SR3_EXTRA3":2,"SR3_EXT_STAT":2,"SR3_PARAMS":0,"SR3_POSITION":3,"SR3_RAW_CTRL":0,"SR3_RAW_SENS":0,"SR3_RC_CHAN":2,"STICK_MIXING":1,"SYSID_MYGCS":255,"SYSID_SW_TYPE":0,"SYSID_THISMAV":1,"SYS_NUM_RESETS":427,"TELEM_DELAY":0,"THROTTLE_NUDGE":1,"THR_FAILSAFE":1,"THR_FS_VALUE":1020,"THR_MAX":75,"THR_MIN":0,"THR_PASS_STAB":0,"THR_SLEWRATE":0,"THR_SUPP_MAN":0,"TRIM_ARSPD_CM":1200,"TRIM_AUTO":0,"TRIM_PITCH_CD":0,"TRIM_THROTTLE":45,"VOLT_DIVIDER":"10.0","WHEELSTEER_D":"0.0","WHEELSTEER_I":"0.0","WHEELSTEER_IMAX":0,"WHEELSTEER_P":"0.0","WP_LOITER_RAD":60,"WP_RADIUS":30,"XTRK_ANGLE_CD":3000,"XTRK_GAIN_SC":"100.0","XTRK_MIN_DIST":50,"XTRK_USE_WIND":1,"YW2SRV_D":"0.0","YW2SRV_I":"0.0","YW2SRV_IMAX":0,"YW2SRV_P":"0.0"}

The other link will take you to some basic vehicle info:
http://localhost:4404/vehicle
If you fetch that URL you'll see more JSON:
{"loc":[37.5209667,-122.3090234,169.58],"attitude":[0.04189648,1.4802325,-0.057521753]}

You can add new REST endpoints by following the templates in MavServe.scala
- feel free to change anything you wish (anywhere in this project).

If you look at VehicleModel.scala you'll see it already captures a lot of
state that would be easy to expose to the JS world.  Also it publishes a
bunch of events when vehicle state changes.  See the placeholder I left
in MavServe for how to handle events.  Those events could be mapped to
a method that returns a 'comet style' endless stream of data to the client.