diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-03-19 16:08:46 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-03-19 16:08:46 +0100 |
commit | 1cf6e37dc356144f3da2a2dcde75d1ced8bc5ad6 (patch) | |
tree | 287a8e4ce18d3a8c299d7b2a91599a7a48c7b59d /mavlink-library/src/test | |
download | sbt-mavlink-1cf6e37dc356144f3da2a2dcde75d1ced8bc5ad6.tar.gz sbt-mavlink-1cf6e37dc356144f3da2a2dcde75d1ced8bc5ad6.tar.bz2 sbt-mavlink-1cf6e37dc356144f3da2a2dcde75d1ced8bc5ad6.zip |
initial commit
Diffstat (limited to 'mavlink-library/src/test')
-rw-r--r-- | mavlink-library/src/test/resources/concise.xml | 115 | ||||
-rw-r--r-- | mavlink-library/src/test/scala/com/github/jodersky/mavlink/MainTest.scala | 16 |
2 files changed, 131 insertions, 0 deletions
diff --git a/mavlink-library/src/test/resources/concise.xml b/mavlink-library/src/test/resources/concise.xml new file mode 100644 index 0000000..fcbdc35 --- /dev/null +++ b/mavlink-library/src/test/resources/concise.xml @@ -0,0 +1,115 @@ +<?xml version='1.0'?> +<mavlink> + <version>1</version> + <enums> + <enum name="MAV_STATE"> + <entry value="0" name="MAV_STATE_UNINIT"> + <description>Uninitialized system, state is unknown.</description> + </entry> + <entry value="1" name="MAV_STATE_BOOT"> + <description>System is booting up.</description> + </entry> + <entry value="2" name="MAV_STATE_CALIBRATING"> + <description>System is calibrating and not flight-ready.</description> + </entry> + <entry value="3" name="MAV_STATE_STANDBY"> + <description>System is grounded and on standby. It can be launched any time.</description> + </entry> + <entry value="4" name="MAV_STATE_ACTIVE"> + <description>System is active and might be already airborne. Motors are engaged.</description> + </entry> + <entry value="5" name="MAV_STATE_CRITICAL"> + <description>System is in a non-normal flight mode. It can however still navigate.</description> + </entry> + <entry value="6" name="MAV_STATE_EMERGENCY"> + <description>System is in a non-normal flight mode. It lost control over parts or over the whole airframe. It is in mayday and going down.</description> + </entry> + <entry value="7" name="MAV_STATE_POWEROFF"> + <description>System just initialized its power-down sequence, will shut down now.</description> + </entry> + + </enum> + </enums> + <messages> + <message id="0" name="HEARTBEAT"> + <description>The heartbeat message shows that a system is present and responding.</description> + <field type="uint8_t" name="system_state" enum="MAV_STATE">Global state of system.</field> + </message> + <message id="1" name="POWER"> + <description>Information about the main power source.</description> + <field type="uint16_t" name="voltage">Voltage of the source (mV)</field> + </message> + <message id="2" name="IMU"> + <description>The IMU readings in a NED body frame</description> + <field type="int32_t" name="xacc">X acceleration (mm/s^2)</field> + <field type="int32_t" name="yacc">Y acceleration (mm/s^2)</field> + <field type="int32_t" name="zacc">Z acceleration (mm/s^2)</field> + <field type="int32_t" name="xgyro">Angular speed around X axis (mrad / sec)</field> + <field type="int32_t" name="ygyro">Angular speed around Y axis (mrad / sec)</field> + <field type="int32_t" name="zgyro">Angular speed around Z axis (mrad / sec)</field> + <field type="int32_t" name="xmag">X Magnetic field (uT)</field> + <field type="int32_t" name="ymag">Y Magnetic field (uT)</field> + <field type="int32_t" name="zmag">Z Magnetic field (uT)</field> + <field type="int32_t" name="alt">Altitude to mean sea level (mm)</field> + <field type="uint32_t" name="temperature">Ambient temperature (mK)</field> + </message> + <message id="3" name="DISTANCE"> + <description>Information on distance sensors</description> + <field type="int16_t" name="relative_alt">Relative altitude to ground (mm)</field> + </message> + <message name="PING" id="4"> + <description>Ping a target system, usually used to determine latency.</description> + <field type="uint8_t" name="target_system">System ID</field> + <field type="uint8_t" name="target_component">Component ID</field> + </message> + <message name="ACK" id="5"> + <description>Acknowledgement packet</description> + <field type="uint8_t" name="target_system">System ID</field> + <field type="uint8_t" name="target_component">Component ID</field> + </message> + <message name="MOTOR" id="6"> + <description>Status of motors</description> + <field type="uint8_t" name="m0">m0</field> + <field type="uint8_t" name="m1">m1</field> + <field type="uint8_t" name="m2">m2</field> + <field type="uint8_t" name="m3">m3</field> + </message> + <message id="30" name="ATTITUDE"> + <description>The attitude in the aeronautical frame (right-handed, Z-down, X-front, Y-right).</description> + <field type="int16_t" name="roll">Roll angle</field> + <field type="int16_t" name="pitch">Pitch angle</field> + <field type="uint16_t" name="yaw">Yaw angle</field> + </message> + <message id="70" name="RC_CHANNELS_OVERRIDE"> + <description>The RAW values of the RC channels sent to the MAV to override info received from the RC radio. A value of UINT16_MAX means no change to that channel. A value of 0 means control of that channel should be released back to the RC radio. The standard PPM modulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%. Individual receivers/transmitters might violate this specification.</description> + <field type="uint8_t" name="target_system">System ID</field> + <field type="uint8_t" name="target_component">Component ID</field> + <field type="uint16_t" name="chan1_raw">RC channel 1 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan2_raw">RC channel 2 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan3_raw">RC channel 3 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan4_raw">RC channel 4 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan5_raw">RC channel 5 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan6_raw">RC channel 6 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan7_raw">RC channel 7 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + <field type="uint16_t" name="chan8_raw">RC channel 8 value, in microseconds. A value of UINT16_MAX means to ignore this field.</field> + </message> + <message name="RADIO_STATUS" id="109"> + <description>Status generated by radio</description> + <field type="uint8_t" name="rssi">local signal strength</field> + <field type="uint8_t" name="remrssi">remote signal strength</field> + <field type="uint8_t" name="txbuf">how full the tx buffer is as a percentage</field> + <field type="uint8_t" name="noise">background noise level</field> + <field type="uint8_t" name="remnoise">remote background noise level</field> + <field type="uint16_t" name="rxerrors">receive errors</field> + <field type="uint16_t" name="fixed">count of error corrected packets</field> + </message> + <message name="TEST_MESSAGE" id="110"> + <description>Test</description> + <field type="uint8_t[2]" name="bytearray">a byte array</field> + <field type="float[20]" name="floatarray">a float array</field> + <field type="char" name="chars">a char</field> + <field type="double" name="doubles">a double</field> + <field type="char[20]" name="strings">a string</field> + </message> + </messages> +</mavlink> diff --git a/mavlink-library/src/test/scala/com/github/jodersky/mavlink/MainTest.scala b/mavlink-library/src/test/scala/com/github/jodersky/mavlink/MainTest.scala new file mode 100644 index 0000000..faf252a --- /dev/null +++ b/mavlink-library/src/test/scala/com/github/jodersky/mavlink/MainTest.scala @@ -0,0 +1,16 @@ +package com.github.jodersky.mavlink + +import scala.io.Source +import scala.xml.XML +import trees._ + +object MainTest { + + def main(args: Array[String]): Unit = { + val definition = XML.load(getClass.getResource("/concise.xml")) + val dialect = Parser.parseDialect(definition) + val generator = new Generator(dialect) + println(generator.generate()) + } + +}
\ No newline at end of file |