Project - MarathonTP

I just posted MarathonTP on Codeshare. Feel free to discuss and make suggestions here.


glad to see some more vb code

Sounds interesting.
Could you post some more Information about it, like:
Message-Frame-Info (Header, commands, data-format, …
Error checking

Yes, a bit more information wouldn’t hurt. What are the architecture qualities of the protocol / its implementation, besides being simple and open source? How does it compare to MQTT, ZeroMQ, CoAP, etc.?

@ Cuno -

I’m currently working on specification document and I will publish it as soon as available.

Also, I will publish a usage sample soon and will keep people informed.

Quickly, MarathonTP is an Applicaion Layer Protocol and my codeshare is an UDP implementation of the specification.

Due to an issue with .NET Micro Framework, the CRC calculation of message frame could not be coded in VB. I will update my codeshare with the C# Library included soon.

Thread for the issue on Codeplex :

VB Bit Shifting support was removed from VS 2012. However, there is a work around.
Try this it works in VS 2013.

Debug.Print(x \ 2 ^ 8) ' Yeilds the same result as below.
Debug.Print(x >> 8)

I also have implemented a couple of Extension Methods that work as follows:

 <System.Runtime.CompilerServices.Extension> _
    Public Shared Function RightShift(integerToShift As Integer, bitsToShift As Integer) As Integer
        Return CInt(integerToShift / 2 ^ bitsToShift)
    End Function

    <System.Runtime.CompilerServices.Extension> _
    Public Shared Function LeftShift(integerToShift As Integer, bitsToShift As Integer) As Integer
        Return CInt(integerToShift * 2 ^ bitsToShift)
    End Function

Perhaps, I should post my Math Extension Methods Class in codeshare for all of us VB Coders.


@ scardinale -

I will give it a try.

Yes, please.

Save the additional calculation overhead and simply divide by 256. Its the same result. :slight_smile:

the compiler should do that. So the \2^8 is quite more readable

@ scardinale -

If you try something like the snippet below you get different values :

Dim x As UShort = 6789
        Debug.Print(CUShort(Math.Floor((x / 2 ^ 8))))
        Debug.Print(CUShort((x / 2 ^ 8)))

It’s because 6789 / 256 = 26.5195. If you cast this number in a short you will get 27. A bit shift never contain decimal value. So, for my CRC to work properly I have to do something like :

Dim x As UShort = 6789
        Debug.Print(CUShort(Math.Floor((x / 2 ^ 8))))
        Debug.Print((x >> 8))

Thank you for your trick. My CRC calculation is now part of my VB Common Class.

@ jango_jas

If you use the integer division operator \ (backslash) instead of the Double division operator (forward slash), you can skip the Math.Floor function

@ scardinale -
I did not see you wrote \ instead of /. You make my day. :smiley:

@ jango_jas

I looking forward to seeing the usage example update in CodeShare.

I was very surprised by this statement so I quickly tested on VS2012 and VB.NET bit shifting seems to work just fine. Also in VS2013. I double checked the language specification and bit shifting is documented in section 11.18.

@ taylorza -

Try it with Micro Framework Project. Another story.

@ taylorza.

Let me clarify. VB BitShifting support was not removed from the Full Framework, only in the VB implementation of NetMF.

Try it in a Gadgeteer App or Micro Framework Console App in VS 2012 and you will get the error ‘System.Nullable(Of )’ is not defined’…

However, it does not appear to happen in VS 2010.

@ scardinale - Ah, I see, I guess the problem is that the newer compiler generates IL that is not supported by .NETMF, I miss-read your statement as the functionality being removed from the language and not .NETMF specific. Net result no support for bit shifting which is very unfortunate.

Wow, the IL looks fine, no use of generics which I expected from the error that is shown. So that might actually be a IDE integration issue. Very unfortunate.