stevehayles Geschrieben January 29, 2019 at 15:42 Geschrieben January 29, 2019 at 15:42 Hi, Been working with the Tinkerforge system as a prototyping platform for a commercial product. Very well designed and easy system to work with but the .Net bindings are tied to some legacy framework versions and quite 'ugly' with the requirement for 'out' variables etc. I have just released a new set of bindings with three big updates. Firstly there is full support for ValueTuple returns on all functions with full property naming. It allows calls like var result = imu.GetAllData(); var accel = result.Acceleration; var angles = result.EulerAngle; rather than having to deal with multiple 'out' variables. There is also a fully async version of every call implemented using the Async/Await pattern. The IPConnection class implements all socket send and receive calls asynchronously and there are async overrides of each available call. The combined effect is that the above example can be written as var resultAsync = await imu.GetAllDataAsync(); var accel = resultAsync.Acceleration; var angles = resultAsync.EulerAngle; This code is properly async and not just wrapping synchronous calls in Task.Run(). The last addition is the use of Reactive.Linq and a full set of extension methods to allow the use of IObservable on every brick or bricklet callback. RX Extensions allow a composable and functional approach to streams of data. Time shifting of sequences, buffering, throttling and all sorts of manipulations become very easy with a Linq based approach. The underlying callback event is converted to an IObservable and the disposal of event handlers is all handled automatically. The example below subscribes to a stream of data coming from the imu but it's 'throttled' to only produce data every 500 milliseconds regardless of the incoming rate from the brick. imu.WhenOrientation() .Sample(TimeSpan.FromMilliseconds(500)) .Subscribe(async v => { Console.WriteLine($"Heading: {v.Heading}"); await Log.WriteAsync($"Roll: {v.Roll}"); }); The nuget package is available at https://www.nuget.org/packages/FiftyOneNorth.Tinkerforge/ (FiftyOneNorth.Tinkerforge) The complete set of bricks and bricklets are covered and I will try and maintain compatibility with future releases. Keen to hear other's experiences and hope it's useful to someone Thanks, Steve Hayles Fifty One North Ltd Zitieren
borg Geschrieben January 30, 2019 at 09:38 Geschrieben January 30, 2019 at 09:38 Sweet, looks good! The design of the C# bindings is indeed quite old by now and it shows in the API. We try to always maintain backwards compatibility, so it often is hard to add new programming language features over time. Maybe it would make sense to have some kind of C# bindings 2.0 and maintain the old C# bindings for legacy applications for a while. Zitieren
stevehayles Geschrieben January 30, 2019 at 10:28 Autor Geschrieben January 30, 2019 at 10:28 Hi, I don't want to 'pollute' your bindings in any way and at present my library is built as a combination of a modified "generate_csharp_bindings.py" python script and then a T4 template to generate all the extension methods. This could all be done entirely within the current python framework but it's a much bigger change. Maybe a completely separate "generate_csharp_bindings_V2.py" script with the original untouched would be the way to go ? Zitieren
borg Geschrieben January 30, 2019 at 10:34 Geschrieben January 30, 2019 at 10:34 Yes, we would make a complete separate v2 version. We also would like to add .NET Core support if we do a major update of the C# bindings. For that we would have to exchange some of the internals with .NET Core compatible stuff too. Zitieren
stevehayles Geschrieben January 30, 2019 at 10:57 Autor Geschrieben January 30, 2019 at 10:57 Great move to go to .Net Core, it's the future ! My bindings work very well in a .Net Core environment and I am currently running them on a Raspberry PI to great effect. I have a custom RPI image running with the .Net Core run-time built in and my next move was to look at the Red Brick and try and do the same there but if you are considering it then I am sure you will do a better job. Zitieren
stevehayles Geschrieben February 4, 2019 at 20:47 Autor Geschrieben February 4, 2019 at 20:47 Updated to version 1.0.2 with following improvements Improved callback/continuous callback documentation Add RemoveCalibration function to Air Quality Bricklet API Zitieren
stevehayles Geschrieben February 9, 2019 at 13:01 Autor Geschrieben February 9, 2019 at 13:01 Updated to version 1.0.3 with following improvements Air quality bricklet - Add API for changing background calibration duration Zitieren
stevehayles Geschrieben May 23, 2019 at 23:33 Autor Geschrieben May 23, 2019 at 23:33 Updated to version 1.0.6 with following improvements Added Laser Range Finder Bricklet 2.0 Added Hall Effect Bricklet 2.0 Added Segment Display 4x7 Bricklet 2.0 Added E-Paper 296x128 Bricklet Added Laser Range Finder Bricklet 2.0 Added Piezo Speaker 2.0 Added Linear Poti Bricklet 2.0 Added Joystick Bricklet 2.0 Added RGB LED Bricklet 2.0 https://www.nuget.org/packages/FiftyOneNorth.Tinkerforge/1.0.6 Zitieren
stevehayles Geschrieben August 26, 2019 at 15:54 Autor Geschrieben August 26, 2019 at 15:54 Updated to version 1.0.7 with following improvements Added Compass Bricklet Added Energy Monitor Bricklet Added XMC1400 Breakout Bricklet Added Distance US Bricklet 2.0 Added Color Bricklet 2.0 Added Rotary Poti Bricklet 2.0 Added Multi Touch Bricklet 2.0 https://www.nuget.org/packages/FiftyOneNorth.Tinkerforge/1.0.7 Zitieren
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.