Skip to content

Commit

Permalink
Device: add device map WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jan 8, 2017
1 parent 8c6d365 commit f8e0c49
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 6 deletions.
5 changes: 1 addition & 4 deletions MissionPlanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@
<Compile Include="Utilities\AP_GPS_NOVA.cs" />
<Compile Include="Utilities\AP_GPS_SBF.cs" />
<Compile Include="Utilities\AP_Terrain.cs" />
<Compile Include="Utilities\Device.cs" />
<Compile Include="Utilities\dxf.cs" />
<Compile Include="Utilities\Extensions.cs" />
<Compile Include="Utilities\GMapMarkerOverlapCount.cs" />
Expand Down Expand Up @@ -2537,7 +2538,6 @@
<EmbeddedResource Include="Utilities\AltitudeAngel\AASettings.resx">
<DependentUpon>AASettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Wizard\10FlightModes.ar.resx" />
<EmbeddedResource Include="Wizard\10FlightModes.id-ID.resx">
<DependentUpon>10FlightModes.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -2559,7 +2559,6 @@
<EmbeddedResource Include="Wizard\10FlightModes.zh-TW.resx">
<DependentUpon>10FlightModes.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Wizard\11Verify.ar.resx" />
<EmbeddedResource Include="Wizard\11Verify.id-ID.resx">
<DependentUpon>11Verify.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -2581,7 +2580,6 @@
<EmbeddedResource Include="Wizard\11Verify.zh-TW.resx">
<DependentUpon>11Verify.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Wizard\12FailSafe.ar.resx" />
<EmbeddedResource Include="Wizard\12FailSafe.id-ID.resx">
<DependentUpon>12FailSafe.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -2603,7 +2601,6 @@
<EmbeddedResource Include="Wizard\12FailSafe.zh-TW.resx">
<DependentUpon>12FailSafe.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Wizard\13GeoFence.ar.resx" />
<EmbeddedResource Include="Wizard\13GeoFence.id-ID.resx">
<DependentUpon>13GeoFence.cs</DependentUpon>
</EmbeddedResource>
Expand Down
24 changes: 24 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ public static void Main(string[] args)
log.InfoFormat("64bit os {0}, 64bit process {1}", System.Environment.Is64BitOperatingSystem,
System.Environment.Is64BitProcess);


Device.DeviceStructure test1 = new Device.DeviceStructure(73225);
Device.DeviceStructure test2 = new Device.DeviceStructure(262434);
Device.DeviceStructure test3 = new Device.DeviceStructure(131874);

MAVLink.MavlinkParse tmp = new MAVLink.MavlinkParse();
MAVLink.mavlink_heartbeat_t hb = new MAVLink.mavlink_heartbeat_t()
{
autopilot = 1,
base_mode = 2,
custom_mode = 3,
mavlink_version = 2,
system_status = 6,
type = 7
};
var t1 = tmp.GenerateMAVLinkPacket10(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb);
var t2 = tmp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb);
tmp.GenerateMAVLinkPacket10(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb);
tmp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb);

tmp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb, true);
tmp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.HEARTBEAT, hb, true);


try
{
//System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime;
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.1.*")]
[assembly: AssemblyFileVersion("1.3.43.2")]
[assembly: AssemblyFileVersion("1.3.43.3")]
[assembly: NeutralResourcesLanguageAttribute("")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
Expand Down
105 changes: 105 additions & 0 deletions Utilities/Device.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace MissionPlanner.Utilities
{
public class Device
{
//ph2
//COMPASS_DEV_ID 73225
//COMPASS_DEV_ID2 262434
//COMPASS_DEV_ID3 131874

// from ap_hal\device.h
public enum BusType
{
BUS_TYPE_UNKNOWN = 0,
BUS_TYPE_I2C = 1,
BUS_TYPE_SPI = 2,
BUS_TYPE_UAVCAN = 3
}

public enum Speed
{
SPEED_HIGH,
SPEED_LOW,
}

// float = 1 sign, 8 exponents, 23 significand

public struct DeviceStructure
{
// the data
public UInt32 devid;

// accessors
public BusType bus_type { get { return (BusType) (devid & 0x3); } } // : 3;
public byte bus { get { return (byte)((devid >> 2) & 0x1f); } } //: 5; // which instance of the bus type
public byte address { get { return (byte) ((devid >> 8) & 0xff); } } // address on the bus (eg. I2C address)
public DevTypes devtype { get { return (DevTypes)((devid >> 16) & 0xff); } } // device class specific device type

public DeviceStructure(UInt32 id)
{
devid = id;

Console.WriteLine("bus type {0} bus {1} address (i2c addr or spi CS) {2} devtype {3} ", bus_type, bus, address, devtype);
}

// from AP_Compass_Backend.h
public enum DevTypes
{
DEVTYPE_HMC5883_OLD = 0x01,
DEVTYPE_HMC5883 = 0x07,
DEVTYPE_LSM303D = 0x02,
DEVTYPE_AK8963 = 0x04,
DEVTYPE_BMM150 = 0x05,
DEVTYPE_LSM9DS1 = 0x06,
DEVTYPE_LIS3MDL = 0x08,
DEVTYPE_AK09916 = 0x09,
DEVTYPE_IST8310 = 0x0A,
};

public enum px4_i2c_bus
{
PX4_I2C_BUS_ONBOARD=0,
PX4_I2C_BUS_EXPANSION=1
}

// from PX4Firmware\src\drivers\boards\px4fmu-v2\board_config.h
public enum px4_spi_bus
{
PX4_SPI_BUS_SENSORS= 1,
PX4_SPI_BUS_RAMTRON= 2,
PX4_SPI_BUS_EXT = 4,
}
}

//DEV_ID
//DEV_ID2
//DEV_ID3

//ap_hal - device.h
//set_device_type
//get_bus_id

/**
* make a bus id given bus type, bus number, bus address and
* device type This is for use by devices that do not use one of
* the standard HAL Device types, such as UAVCAN devices
*/
/*
static uint32_t make_bus_id(enum BusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype) {
union DeviceId d;
d.devid_s.bus_type = bus_type;
d.devid_s.bus = bus;
d.devid_s.address = address;
d.devid_s.devtype = devtype;
return d.devid;
*/

// devid is a union of bus type, bus, address and devtype
}
}
2 changes: 1 addition & 1 deletion appxmanifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
<Identity Name="36541MichaelOborne.MissionPlanner"
Version="1.3.42.0"
Version="1.3.43.0"
Publisher="CN=3B1842DF-8664-4A02-B840-61F61DA8A94E" />
<Properties>
<DisplayName>Mission Planner</DisplayName>
Expand Down

0 comments on commit f8e0c49

Please sign in to comment.