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.

twinnaz

Member Since 09 Nov 2012
Offline Last Active Feb 23 2017 05:18 PM
-----

Topics I've Started

Playing with neopixels

24 November 2014 - 11:40 PM

Playing around with a Neopixel library I wrote 

 

Fading 

https://onedrive.liv...E84D56B35!15115

 

Pulse fade

https://onedrive.liv...E84D56B35!15118

 

Will post code when I add a couple more functions 


Netduino and Xsockets.net Led blink example

13 August 2014 - 02:45 AM

Just sharing an example of Xsockets.net running on Netduino Plus 2 , browser and console application with full duplex communication.

 

Controls the on-board LED from the browser also by pressing the on-board button, the netduino will send the chat message to the browser and the Console client application.

 

All files can be found here : https://github.com/X...ockets.Netduino

Lets see what we can create with the new Xsockets.Net 4.0 framework :)


C# implementation of the GoBus transport layer ??

30 June 2014 - 02:45 AM

I was just wondering if this was still in the works for the Neutrino Plus line of boards.

 

We'll also be sharing a fully-C# implementation of the GoBus transport layer which can be used on regular Netduinos.

 

 


Multithread Problem 3 blinking LED's

19 March 2014 - 07:55 PM

I have this code that blinks 3 LED's at the same time and also counts a value in each thread.

The problem is when I deploy the project and everything starts running the LED's are out of sync and i get pauses whenever a value is reached until I push the reset button on the Netduino then everything runs as expected, but then I lose the ability to monitor the values in the debugger. Am I missing something or is this a glitch in .NETMF

Code Below 

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

Module Module1

    Dim led1 As New OutputPort(Pins.GPIO_PIN_D0, False)
    Dim led2 As New OutputPort(Pins.GPIO_PIN_D1, False)
    Dim led3 As New OutputPort(Pins.GPIO_PIN_D2, False)
    Dim led4 As New OutputPort(Pins.GPIO_PIN_D3, False)
    Public led1done As Boolean = False
    Public led2done As Boolean = False
    Public led3done As Boolean = False
    Sub Main()

        Dim x As New Thread(AddressOf led1t)
        Dim y As New Thread(AddressOf led2t)
        Dim z As New Thread(AddressOf led3t)
        Dim Done As New Thread(AddressOf DBit)

        x.Start()
        y.Start()
        z.Start()
        Done.Start()

    End Sub
    Sub led1t()

        Dim x As Integer = 0

        While x < 30
            x += 1
            led1.Write(True)
            Thread.Sleep(25)
            led1.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led1 Blink Count = " & x.ToString)
            If x = 30 Then led1done = True
        End While
    End Sub
    Sub led2t()

        Dim y As Integer = 0

        While y < 15
            y += 1
            led2.Write(True)
            Thread.Sleep(25)
            led2.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led2 Blink Count = " & y.ToString)
            If y = 15 Then led2done = True
        End While
    End Sub
    Sub led3t()

        Dim z As Integer = 0

        While z < 55
            z += 1
            led3.Write(True)
            Thread.Sleep(25)
            led3.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led3 Blink Count = " & z.ToString)
            If z = 55 Then led3done = True
        End While
    End Sub
    Sub DBit()
        While True
            If led1done And led2done And led3done = True Then
                led4.Write(True)
                Thread.Sleep(Timeout.Infinite)


            End If
        End While
    End Sub
End Module


SocketServer No response

03 February 2014 - 01:29 AM

So I have got it to work but it only does it once then throws exception target machine is actively refusing it .I guess now I need to set up  a loop to continuously send and listen between both programs , but how would I get that done. Kind of a newb exploring waters for something bigger :)

Netduino App  

Imports System.NetImports System.Net.SocketsImports Microsoft.SPOTImports Microsoft.SPOT.HardwareImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoImports System.TextModule Module1    Dim rawData As String = Nothing    Dim cdat As String = "done"    Dim dataco As Byte() = Encoding.UTF8.GetBytes(cdat)    Sub Main()        Try            Using socket As System.Net.Sockets.Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                socket.Bind(New IPEndPoint(IPAddress.Any, 8080))                socket.Listen(10)                Using commSocket As Socket = socket.Accept()                    If commSocket.Poll(-1, SelectMode.SelectRead) Then                        Dim bytes As Byte() = New Byte(commSocket.Available - 1) {}                        Dim count As Integer = commSocket.Receive(bytes)                        rawData = (New String(Encoding.UTF8.GetChars(bytes)))                    End If                End Using            End Using            Debug.Print(rawData)        Catch ex As SocketException            Debug.Print(ex.ToString)        End Try        Try            Using socket2 As System.Net.Sockets.Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                Dim ipSelect As String = "192.168.1.231"                Dim portSelect As Integer = 8080                Dim remoteIPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(ipSelect)                Dim remoteEndPoint As New System.Net.IPEndPoint(remoteIPAddress, portSelect)                socket2.Connect(remoteEndPoint)                socket2.Send(dataco)                socket2.Close()            End Using        Catch e As SocketException            Debug.Print(e.Message)        End Try        Thread.Sleep(Timeout.Infinite)    End SubEnd Module

Windows Form App 

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Windows.FormsImports System.Net.SocketsImports System.NetPublic Class Form1    Private Sub sendbtn_Click(sender As Object, e As EventArgs) Handles sendbtn.Click        Dim cdat As String = Nothing        cdat = value1.Text        Dim Client As Socket        Dim data As Byte() = Encoding.ASCII.GetBytes(cdat)        Dim data2 As String = Nothing        Try            Client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)            Dim ipSelect As String = ipadd.Text            Dim portSelect As Integer = Convert.ToInt16(port.Text)            Dim remoteIPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(ipSelect)            Dim remoteEndPoint As New System.Net.IPEndPoint(remoteIPAddress, portSelect)            Client.Connect(remoteEndPoint)            Client.Send(data)        Catch [error] As SocketException            MessageBox.Show([error].Message)        End Try        Try            Using Client2 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                Client2.Bind(New IPEndPoint(IPAddress.Any, 8080))                Client2.Listen(1)                Using commSocket As Socket = Client2.Accept()                    If commSocket.Poll(-1, SelectMode.SelectRead) Then                        Dim bytes2 As Byte() = New Byte(commSocket.Available - 1) {}                        Dim count As Integer = commSocket.Receive(bytes2)                        data2 = (New String(Encoding.UTF8.GetChars(bytes2)))                    End If                    MessageBox.Show(data2)                End Using            End Using        Catch ex As SocketException            MessageBox.Show(ex.SocketErrorCode)        End Try    End SubEnd Class

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.