• RSS
  • Add To My MSN
  • Add To Windows Live
  • Add To My Yahoo
  • Add To Google

MQTT & Eclipse Paho : new releases for M2Mqtt client and GnatMQ broker !! 

Posted by Paolo Patierno Saturday, March 28, 2015 2:20:33 PM
Rate this Content 0 Votes

Finally the new M2Mqtt 4.1 version is out !

In the last months, my library was under pressure thanks to my friends Olivier Vigliengo (from Adeneo) and Nicolas Besson (Microsoft MVP on Windows Embedded, from Adeneo). They used the MQTT client for their hobbistic projects and stressed it a lot !

After exchanging a lot of emails with log traces, I fixed some bugs and added some improvements to the library :

  • Exposed IsPublished flag in the published event to know if message is published or not due to timeout;
  • Internal changes for event management;
  • Fixed bug on negative timeout;
  • Improved stability on not reliable network;
  • Fixed bug on session management;
  • Added trace on queueing operations;

Of course, all changes had a great impact on the GnatMQ broker project related to M2Mqtt. The MQTT broker is still in Beta but I’d like to release it as Stable : I hope that people using it give me a feedback. It seems that XSocket team is using it to support MQTT in their platform. Smile

As always you can find M2Mqtt under Eclipse Paho project, CodePlex and Nuget. GnatMQ is available only on CodePlex. Finally, I updated the M2Mqtt4CE (for Windows Embedded Compact 2013 OS) on CodePlex as well.

CDays 2015 – IoT & Azure 

Posted by Mirco Vanini Wednesday, March 11, 2015 3:53:44 PM
Rate this Content 0 Votes

Anche quest’anno mi sarà data la possibilità di partecipare come speaker ai Community Days, in dettaglio nella giornata di martedì 24 marzo terrò una sessione dal titolo: IoT con Azure:

In questa sessione verranno analizzate e discusse le problematiche legate alla pubblicazione dei dati da devices in un tipico scenario IoT. Vedremmo come il servizio Event Hub di Microsoft Azure gestisce l'inserimento per pubblicazione e sottoscrizione offrendo una scalabilità flessibile, adattabile a profili di carico variabile e ai picchi provocati dalla connettività intermittente

Eccovi una piccola anticipazione dei devices che saranno coinvolti durante la presentazione:

NETMF 4.4 Beta 

Posted by Mirco Vanini Wednesday, March 11, 2015 3:23:41 PM
Rate this Content 0 Votes

Inizia a delinearsi la prossima versione di. .NET Micro Framework, Con questo rilascio Microsoft ha spostato il progetto da CodePlex a GitHub, il nuovo indirizzo è http://netmf.github.io. Solo la release corrente è stata spostata mentre le vecchie versioni rimarranno su CodePlex. In questa versione la novità principale è la riscrittura dello stack di rete per migliorare sensibilmente la stabilità delle connessioni. Oltre a questo le altre aree di intervento riguardano: la parte di distribuzione, stabilità del fw e le funzionalità di debug. Sempre in questa release iniziamo a vedere il supporto per AllJoyn, VS2015 e le API WinRT.

String “interning” mechanism in the .Net Micro Framework 

Posted by Paolo Patierno Sunday, February 22, 2015 10:59:12 AM
Rate this Content 0 Votes

Consider the following simple console application in C # ...

   1: static void Main(string[] args)
   2: {
   3:     string s1 = "Hello world";
   4:     string s2 = "Hello world";
   5:  
   6:     Console.WriteLine(s1.Equals(s2));
   7:     Console.WriteLine(ReferenceEquals(s1, s2));
   8:     Console.WriteLine(s1 == s2);
   9:  
  10:     string s3 = String.Intern(Console.ReadLine());
  11:  
  12:     Console.WriteLine(s1.Equals(s3));
  13:     Console.WriteLine(ReferenceEquals(s1, s3));
  14:     Console.WriteLine(s1 == s3);
  15:  
  16:     Console.ReadKey();
  17: }

who has the following output …

string_intern_net

As we know the Equals() method and the "==" operator check if the two strings contain the same value while having a different reference (s1 and s2), for which it is obvious the result "True". Why does the ReferenceEquals() provides "True" instead of "False" considering that the two references are different ?

Okay ! They are not different in reality !

The .Net Framework provides a mechanism of "string interning" and a pool who contains strings that have the same value and avoid unnecessarily memory allocation. For this reason, s1 and s2 are actually the same reference !

It 'obvious that, when a string is acquired from the outside it doesn’t happen and you need to explicitly ask the framework to search for the string acquired before the internal pool and possibly allocate a new one if it does not exist ... that is the goal of the String.Intern() method.

Let's try to run the same code (unless some changes) on the .Net Micro Framework ...

   1: static void Main(string[] args)
   2: {
   3:     string s1 = "Hello world";
   4:     string s2 = "Hello world";
   5:  
   6:     Console.WriteLine(s1.Equals(s2));
   7:     Console.WriteLine(ReferenceEquals(s1, s2));
   8:     Console.WriteLine(s1 == s2);
   9:  
  10:     string s3 = String.Intern(Console.ReadLine());
  11:  
  12:     Console.WriteLine(s1.Equals(s3));
  13:     Console.WriteLine(ReferenceEquals(s1, s3));
  14:     Console.WriteLine(s1 == s3);
  15:  
  16:     Console.ReadKey();
  17: }

with the following output …

string_intern_netmf

In this case the ReferenceEquals() confirms that the two reference are different in the first case but also using String.Intern() ... why ?

The reason is simple ... the .Net Micro Framework does not support the mechanism of "string interning" and does not provide an internal pool of strings and the answer is as always in the native implementation. Looking into the String.cs file, we find :

   1: public static String Intern(String str)
   2: {
   3:     // We don't support "interning" of strings. So simply return the string.
   4:     return str;
   5: }
   6:  
   7: public static String IsInterned(String str)
   8: {
   9:     // We don't support "interning" of strings. So simply return the string.
  10:     return str;
  11: }

An explicit comment tells us that this feature is not supported !

Regex portability between .Net and .Net Micro Framework … pay attention !! 

Posted by Paolo Patierno Saturday, February 14, 2015 11:53:19 AM
Rate this Content 0 Votes

Developing on all versions of the .Net Framework (full, compact and micro) I have always the portability problem and I avoid to use methods that are not available in one of three framework or using directives for precompilation.

It never happened a case where the method exists in all the frameworks but the parameters have a different meaning ... are even reversed !!

The method in question is the overload Regex.Split(String, String, RegexOptions) !

The signature is practically the same comparing the .Net Framework and .Net Micro Framework .... but with a significant difference in the first two parameters.

From the MSDN documentation of the .Net Framework we can read that the first parameter is the string to split while the second is the pattern to be applied.

 

01

Conversely, in the MSDN documentation of the .Net Micro Framework we can read that the first is the pattern and the second is the input string !!

 

02

To be sure that the error is not in the documentation, I searched the source code of the .Net Micro Framework that implement this method but unfortunately came the confirmation !

   1: /// <summary>
   2: /// Splits the input string at the positions defined by a specified regular expression pattern. Specified options modify the matching operation.
   3: /// </summary>
   4: /// <param name="pattern">The pattern to match against</param>
   5: /// <param name="split">The string to split</param>
   6: /// <param name="options">The options to utilize during matching</param>
   7: /// <returns>The result of splitting the input string against the pattern</returns>
   8: public static string[] Split(string pattern, string split, RegexOptions options)
   9: {
  10:     return new Regex(pattern, options).Split(split);
  11: }

Absolutely strange ... this time I decided to open an issue on the official website of the .Net Micro Framework on CodePlex !

Page 1 of 47 1 2 3 4 5 6 7 8 9 10 20 > >>