Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Bainesbunch's Content

There have been 54 items by Bainesbunch (Search limited from 15-May 23)


By content type

See this member's


Sort by                Order  

#22808 SD Card With 4.2 firmware not working

Posted by Bainesbunch on 15 January 2012 - 07:31 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Bainesbunch,

If you're not seeing any directories (including no '\SD'), that means that your SD card is not mounting.

Did this work with the v4.1.1 beta release? It may be an issue with the SD cards, with your board, or with the firmware. Let's narrow it down.

[We do test SD on every board that ships...but perhaps it was damaged in shipping.]

Chris




Hi Chris,

I have never tried it using the 4.1 firmware, vb is not supported ;). I can get a root folder of '\SD' from it but it will not give me a file list.

if you want to post me a bit of diagonstic code i am happy to load it up and run it to test for the error. C# or VB either is OK.


Whilst i have you attention, I am also trying the find the namespace for the "onewire" class. Where is it hiding in 4.2 ?

Cheers Pete.



#22826 SD Card With 4.2 firmware not working

Posted by Bainesbunch on 16 January 2012 - 11:27 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris,

I have never tried it using the 4.1 firmware, vb is not supported ;). I can get a root folder of '\SD' from it but it will not give me a file list.

if you want to post me a bit of diagonstic code i am happy to load it up and run it to test for the error. C# or VB either is OK.


Whilst i have you attention, I am also trying the find the namespace for the "onewire" class. Where is it hiding in 4.2 ?

Cheers Pete.



PROBLEM SOLVED


OK so you know how sometimes in life you do really stupid things ..... well I am so embarrassed to have to report that this is one of them.

I have several developments going on with the netduinos at the moment and all of them except 1 are netduinos, the last is a netduino plus. I have been re-flashing them to the latest firmware and ... yeah you guesed it I flashed the plain netduino firmware onto the netduino plus.

Having worked out my stupid mistake I thought I would share my embarrassment with the community as a cautionary tale for all others.

The SAMBA tool and the MF Loader tool both remember your last file location and also the firmware is called the same for both the normal and plus versions of the netduino .... well you can work out the rest.


But .... Chris if you or anyone else is still following this thread after my confession of stupidity I still need to know the DLLs and namespaces for the onewire class.


Cheers Pete.



#22828 SD Card With 4.2 firmware not working

Posted by Bainesbunch on 16 January 2012 - 01:42 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Pete,

Glad you got that sorted out :)

There is no OneWire support in the .NET MF 4.2 beta firmware (it's too big), but once the firmware goes to RTM we'll work with CW2 to incorporate his OneWire extensions into it...

Chris



Hi Chris,

well that explains why I can’t find it :)

Can you then please point me to CW2's libs so I can use them until they get implemented into the release.


Following on from my Netduino plus issues. I am having a lot of problems getting the software deployed onto the device and even more problems actually getting into debug mode. Almost every time I "run" the application from the IDE my VB 2010 Express crashes. When is does not crash it hangs about for a long time and then tells me it cannot communicate to the device, finally it sometimes just sits there saying it is rebooting... this does not happen with my other Netduinos (non Plus).


Cheers Pete



#22830 SD Card With 4.2 firmware not working

Posted by Bainesbunch on 16 January 2012 - 02:07 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Pete,

The OneWire feature needs to be compiled into the firware because it has a native code component which lives deep in the hardware layer.

For the VB crash...can you post a bug report for that on netmf.codeplex.com? We can also ping someone on the VB team and see if they have any ideas... That's no fun at all!

Chris



Hi Chris,

OK will do thanks.

For now until I can get this sorted I will have to roll back to Netduino non plus and add an external SD reader. I don’t have the time to faf about with it. I have deadlines to meet.

The USB driver is the same for both plus and no plus boards right ?

Do we have any ETA for the next revision of the firmware including the onewire stuff.

Cheers Pete



#22832 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 03:12 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello Folks,

I am having some issues converting a string into a double using the CDbl(...) method. It is throwing a System.NotImplementedException.

How do we convert a string into a double without this method ?

I have a configuration file stored on the SD card where i save and retrieve values in an eye readable format so that the user can "edit" them in notepad etc. I.E. 100,10.000,2.5,6 these need to be read back into the application and converted into either bytes integers doubles etc. any help gratefully received.

the offending code looks like this


dim ErectParkDecerlationPoint as double = CDbl("10.000")


Here is the output trace for the call.



Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetCultureInfo'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.CurrentUICulture.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.CurrentUICulture.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetCultureInfo'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.NumberFormat.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Resources.ResourceManager.GetObjectFromId'
Step into: Stepping over non-user code 'System.Resources.ResourceManager.GetObjectFromId'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToHalfwidthNumbers'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'double.Parse'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.GetDoubleNumber'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
A first chance exception of type 'System.NotImplementedException' occurred in mscorlib.dll
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.VisualBasic.dll
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'System.InvalidCastException.InvalidCastException'
Step into: Stepping over non-user code 'System.SystemException.SystemException'
Step into: Stepping over non-user code 'System.Exception.Exception'
Step into: Stepping over non-user code 'System.Exception.Exception'
Step into: Stepping over non-user code 'System.SystemException.SystemException'
Step into: Stepping over non-user code 'System.InvalidCastException.InvalidCastException'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.StreamReader.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.Array.IndexOf'
Step into: Stepping over non-user code 'System.Array.IndexOf'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.StreamReader.Dispose'
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Dispose'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError'




#22841 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 07:51 PM in Netduino Plus 2 (and Netduino Plus 1)

CDbl works for me in MF 4.2 RC1

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Module Module1
    Sub Main()
        Dim ErectParkDecerlationPoint As Double = CDbl("10.000")
        Debug.Print("ErectParkDecerlationPoint = " & ErectParkDecerlationPoint.ToString) '--> ErectParkDecerlationPoint = 10
        Dim a As Double = CDbl("12345.6789")
        Debug.Print("a = " & a.ToString) 'a = 12345.678900000001
        Dim b As Double = CDbl("166511.001e9")
        Debug.Print("b = " & b.ToString) 'b = 166511.00099999999
    End Sub
End Module
I have not experienced many of the problems reported for RC3 using RC1. It might be worthwhile to revert back until these problems are solved.

Baxter


OK so where do I get 4.2 RC1 from for the plus for me to try this out please

A link would be good if you have one.

Cheers Pete



#22843 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 08:11 PM in Netduino Plus 2 (and Netduino Plus 1)

Actualy the plot thickens. This code works on the emulator but NOT on the device .. what is going on here ????



Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Module Module1
    Sub Main()
        Dim ErectParkDecerlationPoint As Double = CDbl("10.000")
        Debug.Print("ErectParkDecerlationPoint = " & ErectParkDecerlationPoint.ToString) '--> ErectParkDecerlationPoint = 10
        Dim a As Double = CDbl("12345.6789")
        Debug.Print("a = " & a.ToString) 'a = 12345.678900000001
        Dim b As Double = CDbl("166511.001e9")
        Debug.Print("b = " & b.ToString) 'b = 166511.00099999999
    End Sub
End Module



#22845 Plus no deploying any projects with 4.2 rc3

Posted by Bainesbunch on 16 January 2012 - 09:05 PM in Beta Firmware and Drivers

Hello Folks,

I have a mystery to solve.

I have just got my first plus and flashed it to 4.2 rc3 and since then it has refused to deploy any projects at all in either vb or c#.

So as a little experiment I re-flashed it with the 4.2 rc3 for non plus Netduinos. Now it will allow me to deploy projects in both vb and c#.

Just to be sure I was not going completely crazy I then flashed the 4.2 rc3 for plus back onto it and once again it refused to deploy any projects at all.

This is driving me crazy, can someone point me to the 4.1 release firmware so I can try rolling it back to see what happens please.

Cheers Pete.



#22866 Plus no deploying any projects with 4.2 rc3

Posted by Bainesbunch on 17 January 2012 - 10:45 AM in Beta Firmware and Drivers

Thank you all folks,

This morning I woke up all full of hope for my plight.

I flashed the 4.1 firmware and ... yes my Netduino will now allow me to deploy again.

So the villain looks like being 4.2 rc4 for the plus.

Does anyone else have the same problem.

For all the test I used the same Hardware (Netduino Plus rev. b board) re-flashing the boot loader and the firmware each time ....

  • 4.2 rc4 Plus firmware will not allow deployment of applications.
  • 4.2 rc4 Non Plus firmware will allow deployment of applications.
  • 4.1 Plus firmware will allow deployment of applications.


Edit : Thanks to Baxter i also tried it with the 4.2 rc1. This brought me more success. This time I was able to deploy a vb application BUT the device would just sit there saying rebooting. I have to unplug and reconnect the device to emulate a re-boot before it will continue EVERY time. Coincidently the string to double problem (in another thread I have started) is also not present in the rc1.

Cheers Pete.



#22880 Plus no deploying any projects with 4.2 rc3

Posted by Bainesbunch on 17 January 2012 - 06:08 PM in Beta Firmware and Drivers

Pete,

I think you need both the RC1 firmware and the MF4.2 RC1 SDK to get going smoothly. As I noted in my post I could not upload the SDK because of its size. I searched on CodePlex, but it does not seem to be available. It is very strange that the various release candidates are not archived somewhere in case someone wants to revert. If you wish to PM me, I can try to send it to you via email.

Baxter




Hi Baxter,

I tried to send you a PM, but it is telling me you can't use it .. Very odd ..

You can sent it to me on Skype if you have it. My Skype address id LPDR.Miers. It is very fast as it is P2P. I am online 24/7 just ask to be a contact i will add you then you can send it through by dragging and dropping it into the typing window.

Chris, if you are still following this thread, can you say when we are going to be seeing the next release candidate and will it also have the string to double conversion and do you intend to do a Release candidate with the onewire bit in soon ?



Cheers Pete.



#22886 Plus no deploying any projects with 4.2 rc3

Posted by Bainesbunch on 17 January 2012 - 08:20 PM in Beta Firmware and Drivers

Pete,

My email address was hidden. I unchecked it so try again if you still want the SDK.

Baxter



Nope still not working see screen shot :)

Untitled.png

Cheers Pete



#22887 How to Create a VB Netduino DLL with CIL/IL

Posted by Bainesbunch on 17 January 2012 - 08:24 PM in Visual Basic Support

Hi Baxter,

Can this not simply be done by setting the application Type in the Netduino project properties in a c# or vb project to "Class library" this will then create a DLL that can be used for the MF, you need to be sure you are targeting the correct .NET version.


The steps I use

  • Right click in the solution explorer on the Netduino project name and select Properties (alt+Enter)
  • In the application Tab go to the dropdown for the application type and select "Class Library"
  • Build the application
  • Now go and look in the "bin" folder under the source folder and then into either "debug" or "release" folder depending on your build
  • This is your DLL. It is best left here and referenced from your project. If you want to move it into your new project folder then I suggest you create a folder called LIBS and copy ALL THREE items the DLL and the two folders that are with it called "be" and "le" you do not need the .PDB file.

I often use libraries that are in the public domain but written in c# i compile them into DLLs and then reference them in my VB application. this can be useful if you only want part of a public library. You can remove the stuff you don’t want and then only compile the bits that you need. This is useful if memory is getting short.


Cheers Pete.



#22891 Plus no deploying any projects with 4.2 rc3

Posted by Bainesbunch on 17 January 2012 - 10:17 PM in Beta Firmware and Drivers

Well Pete,

I guess I don't know how private email works on the forum. I am reluctant to openly post my email address for fear of it getting hijacked.

Baxter



OK no worries, I am sure it would only serve to further cloud the situation anyway :)

Cheers Pete



#22950 Mifare RFID Example Code With I2C LCD Output

Posted by Bainesbunch on 18 January 2012 - 05:15 PM in Visual Basic Support

Hello Folks, Here we have another piece of code that may be of use to other developers. It is basically a class that abstracts the basic functionality of an Mifare RFID reader. The device I have used (YHY502CTG) is self-contained and talks using UART level serial data and reads/writes to all Mifare cards. I have included the data sheet in the zip for reference. The sample application that it is a part of the download simply connects to the reader and requests its software revision and reader ID. It also uses the card present pin to trigger an interrupt that causes the device to start to read the present card. The class raises events when a card id read passing the card ID as a parameter. It also raises events for other things like error trapping and data transfer. It displays the data is reads onto 3 lines of a 4x20 LDC with the adafruites backpack attached talking via the I2C bus. I have used a re-compiled cut down version of the "MicroLiquidCrystal" library that I have included for completeness. It uses the "MCP23008LcdTransferProvider" to interface to tee LCD. The reader I have chosen has a lot more functionality than I have included in my abstraction. I only exposed the bits I needed. Please feel free to use this and if you have a need expand on the additional functions of the reader like electronic purse etc. and post it back. If you have any question please ask me and I will try and answer. Cheers Pete.

Attached Files




#22966 Mifare RFID Example Code With I2C LCD Output

Posted by Bainesbunch on 18 January 2012 - 11:30 PM in Visual Basic Support

Hi Pete,

Thanks for the post I was looking into an RFID project myself!

Can you tell me how you found programming in VB on the mircro framework? I still torn between learning C# and just going ahead an using VB which I'm more familiar with?

Thanks

Logicalstep


Hi Logicalstep,

firstly let us start be dispelling a few misunderstandings about VB.

  • VB dates back over 15 years and has been about a lot longer than c#.
  • C and C++ however have been about almost the same time.
  • When MS included it in their first manifestation of Visual Studio it suddenly became accessible to more people.
  • You can create Dlls in VB just search for my other posts where I added to Baxters original post on the CLR.

I am a dedicated VB programmer in the .net arena from asp.net to windows application .NET to .net Compact framework and finally to .NET Micro Framework.

There is very little that you cannot do in VB that you can in c# after all they both compile down to the CLR.

If you need help or pointer on how to do things feel free to drop me a PM or post to this thread.

Cheers Pete.



#22992 IMU Fusion Board

Posted by Bainesbunch on 19 January 2012 - 10:33 AM in Netduino Plus 2 (and Netduino Plus 1)

Hy,
I have a problem with my IMU Fusion Board. I am able to communicate with the gyro and the acc but my problem is that I only get positve values back. So I can not differ the direction of the movment.
It would be nice if somebody could help me



Hi Rich,

I am not sure why you are receiving only positive values from the Gyro but I have another question in the way of offering you some advice.

Why are you instantiating and then disposing of the I2C object in every write and read ?

Would you not be better declaring them in the class as variables. Instantiating them on the class creation and then cleaning up in a class dispose call.

This would be far more efficient than doing it the way you are. It also is a fair bit quicker and would also make lighter work for the garbage collector.

Cheers Pete.



#23027 How to control 220V stuff

Posted by Bainesbunch on 19 January 2012 - 10:57 PM in Netduino 2 (and Netduino 1)

I realy have nothing to add to this thread other than to say that I am NOT Dutch :D :D Pete.



#23029 Debugging stops

Posted by Bainesbunch on 19 January 2012 - 11:05 PM in General Discussion


public static void Main()
{
   while (true)
   {
      System.Threading.Thread.Sleep(1000);
   }
}




This is interesting then what happens if you create and instantiate a new thread. Do all threads terminate when the main loop exits ?

Should you terminate any threads you create after exiting the main loop before the application exits.

Cheers Pete.



#23051 Debugging stops

Posted by Bainesbunch on 20 January 2012 - 10:37 AM in General Discussion

It is my understanding that everything will terminate when the main thread exits. That's why you need to keep it alive for the lifetime of your application run.

That's not to say it has to DO anything. Like I said, it can sleep the whole time and not take up any execution time. In this case, all the work would be done using other threads and events. This approach of event-based programming means your system might go into low power mode because there is nothing that needs attention right at this second. As soon as some interrupt or event is fired, the system will process the instructions then fall back to sleep.

This contrasts with the design of having a single thread that just loops instructions forever. In this case, unless you insert sleep states, you will be using power checking for changes rather than waiting for them to occur and run down your battery very quickly.

-Erik



OK lets separate the principles of threads from events.

Events as we know are raised by several methods, a transition of state on an input pin, a byte arriving at the UART, a timer rolling over of even a user generated event.

Threads are the individual program paths that can run contemporaneously on the device.

Putting the main thread into a sleep is not suspending the CPU and reducing power requirements. The underlying OS is beavering away waiting for events tiding up memory (Garbage collection) etc etc.

So I have some questions.

Are all events in the MF thread safe. In the CF and ordinary frameworks we usually use delegates to handle cross threading events. This does not seem to exists in the MF.

If we do a thread.sleep with a child thread it is blocking sibling threads or the parent thread as well as the thread it is executed on. Take the snippet of code here …



   Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino

Module Module1

    Private HeartBeatThread As Thread
    Private StatusLEDThread As Thread
    Private watchdogTimer As Timer
    Private StatusLEDTimer As Timer
    Private LED_1 As New OutputPort(Pins.GPIO_PIN_D5, False)
    Private LED_2 As New OutputPort(Pins.GPIO_PIN_D6, False)

    Sub Main()

        ' create 2 new threads

        HeartBeatThread = New Thread(AddressOf StartHeartBeatThread)
        StatusLEDThread = New Thread(AddressOf StartStatusLEDThread)

        'Start them up
        HeartBeatThread.Start()
        StatusLEDThread.Start()

        'enter main loop and loop forever
        While True
        End While

    End Sub

    Private Sub StartHeartBeatThread()
        Dim HeartBeatDelegate As New TimerCallback(AddressOf LED1)
        watchdogTimer = New Timer(HeartBeatDelegate, Nothing, 1000, 1000)
        'enter endless loop in thread
        While True
        End While
    End Sub

    Private Sub StartStatusLEDThread()
        Dim StatusLEDDelegate As New TimerCallback(AddressOf LED2)
        StatusLEDTimer = New Timer(StatusLEDDelegate, Nothing, 250, 250)
        'enter endless loop in thread
        While True
        End While
    End Sub

    Private Sub LED1(ByVal stateInfo As Object)
        LED_1.Write(Not LED_1.Read)
        HeartBeatThread.Sleep(500)
    End Sub

    Private Sub LED2(ByVal stateInfo As Object)
        LED_2.Write(Not LED_2.Read)
    End Sub


End Module



So we create two new threads point them at some code and start them. Within the code of each we create a timer and point the event handler at another method. Then in each thread we enter an endless loop. Now in theory each timer is operating within its own thread and the thread is looping endlessly.


Now some questions.

  • When we exit the main loop does the system kill the two threads we have created for us [No the threads we have created continue to run even after the main loop has exited, they need to be explicitly stopped in the main thread with a HeartBeatThread.Abort() and StatusLEDThread.Abort()]
  • No matter what blocking we have on thread "HeartBeatThread" we should expect the LED2 method on thread "StatusLEDThread" to be called every 250ms. [This does NOT work calls to the Sleep on method in the "HeartBeatThread" thread (HeartBeatThread.Sleep(500) or Thread.CurrentThread.Sleep(500)) cause the whole program to sleep, this is not good as it means that threads can become application blocking, this negates the whole point of threads]



You can also get rid of the infinite loop in te main thread if you wish by executing the following Thread.Sleep(Threading.Timeout.Infinite) Oddly enough however this does not seem to block unlike a sleep in another thread.




Code attached to play with.

Cheers Pete.

Attached Files




#23053 Debugging stops

Posted by Bainesbunch on 20 January 2012 - 12:19 PM in General Discussion

OK I have tried using just threads in my second test and it seems that the problem is with timers potentially not running in the thread they are created in or interfering with each other.

In the attached code I have removed the timers from the code path and just toggle the LED states within a loop in the individual threads. This seems to work a treat with NO blocking issues. Now i have to re-think my code and instead of timers in threads simply loop with a sleep.

Cheers Pete.

Attached Files




#23077 Multiple SD card readers on SPI

Posted by Bainesbunch on 20 January 2012 - 08:29 PM in General Discussion

Hi Croswired. I believe that on the Plus you don’t need to mount the SD card as it is already done when booting the device. I am not sure you can "un-mount" it . On a non Plus device there is no reason why you could not put two card on the bus via some logic to switch them in and out using an additional IO Pin, But to keep things clean you would have to mount and un-mount between switching cards. I hope this is some help. Cheers Pete.



#23967 Multiple i2C Devices with VB

Posted by Bainesbunch on 08 February 2012 - 01:48 PM in Visual Basic Support

Hi, I don't know if this is any use but I have two accelerometers connected using the Love electronics libs written in c#. What I did was to compile the resource lib into a dll and reference it in my vb project. this allows multiple I2C devices connected at the same time using the SharedI2CDevice method. The source is available from Love electronics. If all that fails then attached is my compilation Attached File  LoveElectronics.Resources.zip   38.76KB   37 downloads of their dll for you to use. Cheers Pete.



#24291 thread starts thread but 2nd thread does not finish

Posted by Bainesbunch on 16 February 2012 - 02:03 PM in General Discussion

Why does this code loop in a "while" creating new instances of the thread and then starting them. Surely if you re instantiate a thread using the same object variable it will mess with the thread created the first time through the loop. I am not a c# coder so i could be getting it all wrong. Cheers Pete.



#24292 NetDuino C# or VB

Posted by Bainesbunch on 16 February 2012 - 02:10 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Stari A few too many variables here. Try eliminating the browsers first. If it work on your PC does it work in all browsers. If the answer to that is yes then it could be a browser compatibility issue with your android tablet device. If the answer is no only some of the browsers then you have cross browser compatibility issues. Try a VERY simple HTML only hello world page and see if that work. Basically eliminate as many possibilities as you can and you will eventually get to the problem. Cheers Pete.



#24534 LCD EA_DIP_204_4

Posted by Bainesbunch on 21 February 2012 - 09:26 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi, It could be that the timers are interfering with each other calling the function whilst it is being called by another timer. This would definitely mess it up. ;) You could try putting a synclock on the method (that drives the LCD) you are calling to prevent it being entered whilst servicing another timer. Cheers Pete.




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.