diff --git a/RevolveUavcan/Properties/Resources.Designer.cs b/RevolveUavcan/Properties/Resources.Designer.cs new file mode 100644 index 0000000..ecdb4e7 --- /dev/null +++ b/RevolveUavcan/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RevolveUavcan.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RevolveUavcan.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/RevolveUavcan/Properties/Resources.resx b/RevolveUavcan/Properties/Resources.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/RevolveUavcan/Properties/Resources.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RevolveUavcan/Properties/launchSettings.json b/RevolveUavcan/Properties/launchSettings.json index dd43c71..ee96a4b 100644 --- a/RevolveUavcan/Properties/launchSettings.json +++ b/RevolveUavcan/Properties/launchSettings.json @@ -1,7 +1,9 @@ { "profiles": { "Profile 1": { - "commandName": "Executable" + "commandName": "Executable", + "executablePath": "C:\\Users\\Alice Madama\\RevolveUavcan\\RevolveUavcan.sln", + "workingDirectory": "C:\\Users\\Alice Madama\\RevolveUavcan" } } } \ No newline at end of file diff --git a/RevolveUavcan/RevolveUavcan.csproj b/RevolveUavcan/RevolveUavcan.csproj index 97501c6..71a2985 100644 --- a/RevolveUavcan/RevolveUavcan.csproj +++ b/RevolveUavcan/RevolveUavcan.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -38,4 +38,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + diff --git a/RevolveUavcan/Tools/BitArrayTools.cs b/RevolveUavcan/Tools/BitArrayTools.cs index e771a39..6fe6cb7 100644 --- a/RevolveUavcan/Tools/BitArrayTools.cs +++ b/RevolveUavcan/Tools/BitArrayTools.cs @@ -166,10 +166,10 @@ public static double GetFloatFromBitArray(this BitArray dataBits) byte[] bytes = new byte[dataBits.Length / 8]; dataBits.CopyTo(bytes, 0); - - if(dataBits.Length == 16) - return (double) BitConverter.ToHalf(bytes, 0); - else if(dataBits.Length == 32) + + if (dataBits.Length == 16) + return (double)BitConverter.ToHalf(bytes, 0); + else if (dataBits.Length == 32) return BitConverter.ToSingle(bytes, 0); else return BitConverter.ToDouble(bytes, 0); @@ -230,7 +230,24 @@ public static BitArray GetBitArrayFromUInt(uint value, int size) public static BitArray GetBitArrayFromDouble(double value, int size) { - var bytes = size == 64 ? BitConverter.GetBytes(value) : BitConverter.GetBytes((float)value); + byte[] bytes; + if (size == 64) + { + bytes = BitConverter.GetBytes(value); + } + else if (size == 32) + { + bytes = BitConverter.GetBytes((float)value); + } + else if (size == 16) + { + bytes = BitConverter.GetBytes((Half)value); + } + else + { + throw new ArgumentException("Unsupported bit length; must be 16, 32, or 64 bits."); + } + if (!BitConverter.IsLittleEndian) { Array.Reverse(bytes);