- Netduino Forums
- → Brandon G's Content
Brandon G's Content
There have been 92 items by Brandon G (Search limited from 24-May 23)
#7600 NetDuino Quadrocopter
Posted by Brandon G on 13 January 2011 - 08:52 PM in Netduino 2 (and Netduino 1)
#7597 NetDuino Quadrocopter
Posted by Brandon G on 13 January 2011 - 08:43 PM in Netduino 2 (and Netduino 1)
#7665 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 05:43 PM in Netduino 2 (and Netduino 1)
#7784 NetDuino Quadrocopter
Posted by Brandon G on 16 January 2011 - 11:51 PM in Netduino 2 (and Netduino 1)
#9121 NetDuino Quadrocopter
Posted by Brandon G on 07 February 2011 - 04:34 PM in Netduino 2 (and Netduino 1)
#9146 NetDuino Quadrocopter
Posted by Brandon G on 08 February 2011 - 05:35 AM in Netduino 2 (and Netduino 1)
#7654 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:38 PM in Netduino 2 (and Netduino 1)
#7614 NetDuino Quadrocopter
Posted by Brandon G on 13 January 2011 - 10:55 PM in Netduino 2 (and Netduino 1)
#7633 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:23 AM in Netduino 2 (and Netduino 1)
#7631 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:02 AM in Netduino 2 (and Netduino 1)
#7635 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:34 AM in Netduino 2 (and Netduino 1)
#7632 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:18 AM in Netduino 2 (and Netduino 1)
#7581 NetDuino Quadrocopter
Posted by Brandon G on 13 January 2011 - 05:21 PM in Netduino 2 (and Netduino 1)
#7634 NetDuino Quadrocopter
Posted by Brandon G on 14 January 2011 - 04:30 AM in Netduino 2 (and Netduino 1)
#7778 NetDuino Quadrocopter
Posted by Brandon G on 16 January 2011 - 09:42 PM in Netduino 2 (and Netduino 1)
#7779 NetDuino Quadrocopter
Posted by Brandon G on 16 January 2011 - 09:44 PM in Netduino 2 (and Netduino 1)
Good call. BTW, the quantum is a constant and can be changed in code. We've never tried increasing it but it could be possible to increase it to, say, a few weeks/months. If everything is executing on a single thread and one is not using events or threading, this could be a valuable mod.
Chris
Chris where do i change this setting?
#7773 Netduino ESC driver
Posted by Brandon G on 16 January 2011 - 07:24 PM in Netduino 2 (and Netduino 1)
#7750 Netduino ESC driver
Posted by Brandon G on 16 January 2011 - 07:25 AM in Netduino 2 (and Netduino 1)
#8783 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 01 February 2011 - 01:20 AM in General Discussion
#8811 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 01 February 2011 - 04:34 PM in General Discussion
#7609 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 13 January 2011 - 10:28 PM in General Discussion
#8860 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 02 February 2011 - 05:18 AM in General Discussion
EDIT: didnt like what i posted earlier, here`s a revamp
using Quad.Net.Commons.Serialization; namespace Quad.Net.Commons.Logging { public interface ILogger { void Flush(); void Write(ISerializable obj); } } using System.IO; using Quad.Net.Commons.Serialization; namespace Quad.Net.Commons.Logging { public class PersistenceWriter : ILogger { private readonly IBinaryFormatter _formatter; private readonly string _fileName; private readonly FileStream _fileStream; public PersistenceWriter(string fileName, IBinaryFormatter formatter) { _formatter = formatter; _fileName = fileName; _fileStream = new FileStream(_fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512); } public void Flush() { _fileStream.Flush(); } public void Write(ISerializable obj) { _formatter.Serialize(_fileStream, obj); } } } using System.IO; using Quad.Net.Commons.Serialization; namespace Quad.Net.Commons.Logging { public class PersistanceReader { private readonly IBinaryFormatter _binaryFormatter; public PersistanceReader(IBinaryFormatter binaryFormatter) { _binaryFormatter = binaryFormatter; } public ISerializable[] GetMessages(string readPath) { FileStream readFile = new FileStream(readPath, FileMode.Open, FileAccess.Read); return _binaryFormatter.Deserialize(readFile); } } } using System; using System.IO; namespace Quad.Net.Commons.Serialization { public interface IBinaryFormatter { void Serialize(Stream stream, Object graph);//not implemented ISerializable[] Deserialize(Stream stream); void Serialize(Stream stream, ISerializable graph);//optimistic } } namespace Quad.Net.Commons.Serialization { public interface ISerializable //: where T : new() in classic C# this is what i would do force a parameterless contructor, cant do thisin netmf { byte[] Serialize(); object Deserialize(byte[] buffer); } } using System; using System.Collections; using System.IO; namespace Quad.Net.Commons.Serialization { public class TelemetryFormatter:IBinaryFormatter { public void Serialize(Stream stream, object graph) { throw new NotImplementedException(); } public ISerializable[] Deserialize(Stream stream) { ISerializable[] items = new ISerializable[stream.Length/44]; int counter = 0; while (stream.Position < stream.Length) { byte[] buffer = new byte[44]; stream.Read(buffer, 0, 44); ISerializable item = (ISerializable) typeof(TelemetryData).GetConstructor(new Type[0]).Invoke(new object[0]); item.Deserialize(buffer); items[counter] = item; counter++; } return items; } public void Serialize(Stream stream, ISerializable graph) { byte[] buffer = graph.Serialize(); stream.Write(buffer, 0, buffer.Length); } } } using System; using Microsoft.SPOT.Hardware; using Quad.Net.Avionics; using Quad.Net.Commons.Serialization; using Quad.Net.Commons.Utilities; namespace Quad.Net.FlightController { public class TelemetryData : ISerializable { private readonly AircraftPrincipalAxes _gyroAxes; private readonly AircraftPrincipalAxes _radioAxes; private readonly AircraftPrincipalAxes _pidAxes; private long _currentTime; private readonly byte[] _buffer; public TelemetryData() { _gyroAxes= new AircraftPrincipalAxes(0,0,0); _radioAxes = new AircraftPrincipalAxes(0, 0, 0); _pidAxes = new AircraftPrincipalAxes(0, 0, 0); _currentTime = DateTime.Now.Ticks; _buffer = new byte[44]; } public void Update(AircraftPrincipalAxes gyroAxes, AircraftPrincipalAxes radioAxes, AircraftPrincipalAxes pidAxes, long currentTime) { _gyroAxes.Update(gyroAxes.Pitch,gyroAxes.Roll,gyroAxes.Yaw); _radioAxes.Update(radioAxes.Pitch, radioAxes.Roll, radioAxes.Yaw); _pidAxes.Update(pidAxes.Pitch, pidAxes.Roll, pidAxes.Yaw); } public byte[] Serialize() { Utility.InsertValueIntoArray(_buffer, 0, 4, (uint)(_currentTime >> 32)); Utility.InsertValueIntoArray(_buffer, 4, 4, (uint)_currentTime); Utility.InsertValueIntoArray(_buffer, 8, 4, (uint)_gyroAxes.Pitch); Utility.InsertValueIntoArray(_buffer, 12, 4, (uint)_gyroAxes.Roll); Utility.InsertValueIntoArray(_buffer, 16, 4, (uint)_gyroAxes.Yaw); Utility.InsertValueIntoArray(_buffer, 20, 4, (uint)_radioAxes.Pitch); Utility.InsertValueIntoArray(_buffer, 24, 4, (uint)_radioAxes.Roll); Utility.InsertValueIntoArray(_buffer, 28, 4, (uint)_radioAxes.Yaw); Utility.InsertValueIntoArray(_buffer, 32, 4, (uint)_pidAxes.Pitch); Utility.InsertValueIntoArray(_buffer, 36, 4, (uint)_pidAxes.Roll); Utility.InsertValueIntoArray(_buffer, 40, 4, (uint)_pidAxes.Yaw); return _buffer; } public object Deserialize(byte[] buffer) { _currentTime = BitConverter.ToLong(buffer, 0); _gyroAxes.Update( Utility.ExtractValueFromArray(buffer, 8, 4), Utility.ExtractValueFromArray(buffer, 12, 4), Utility.ExtractValueFromArray(buffer, 16, 4) ); _radioAxes.Update( Utility.ExtractValueFromArray(buffer, 20, 4), Utility.ExtractValueFromArray(buffer, 24, 4), Utility.ExtractValueFromArray(buffer, 28, 4) ); _pidAxes.Update( Utility.ExtractValueFromArray(buffer, 32, 4), Utility.ExtractValueFromArray(buffer, 36, 4), Utility.ExtractValueFromArray(buffer, 40, 4) ); return this; } public override string ToString() { //csv format return _currentTime + "," + _gyroAxes.Pitch + "," + _gyroAxes.Roll + "," + _gyroAxes.Yaw + "," + _radioAxes.Pitch + "," + _radioAxes.Roll + "," + _radioAxes.Yaw + "," + _pidAxes.Pitch + "," + _pidAxes.Roll + "," + _pidAxes.Yaw + ","; } } }
#8886 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 02 February 2011 - 04:15 PM in General Discussion
#8861 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 02 February 2011 - 05:20 AM in General Discussion
#7610 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...
Posted by Brandon G on 13 January 2011 - 10:34 PM in General Discussion
- Netduino Forums
- → Brandon G's Content
- Privacy Policy