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.

rchelicopter's Content

There have been 18 items by rchelicopter (Search limited from 19-April 23)


By content type

See this member's

Sort by                Order  

#50449 WebserverHelloWorld on Netduino Plus 2

Posted by rchelicopter on 12 June 2013 - 09:35 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

Try adding these namespaces to the beginning of the webserver.cs

 

using System;

using Microsoft.SPOT;

using System.Net.Sockets;

using System.Text;

using System.Net;

using System.Threading;

using Microsoft.SPOT.Hardware;

using SecretLabs.NETMF.Hardware.Netduino;




#44199 Netduino Plus 2 network question

Posted by rchelicopter on 25 January 2013 - 11:21 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

 

I have a Netduino Plus and a Plus 2, when I power up the Netduino Plus I also power up my dhcp router and it always seemed to wait for the router to obtain an IP address from it via DHCP.

With the Netduino Plus 2 when powered up it times out with a System.Net.Sockets.SocketException.

What was the netduino plus doing that the plus 2 is not, is there a way around this without going to a static address?




#43503 Netduino Plus Socket Server Help

Posted by rchelicopter on 15 January 2013 - 11:31 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

I to would love to learn how to use the events for connection and disconnection rather than the while loop I'm currently using.  I have looked around a bit over the last few months and I havent found a good example to learn from.

 

Thanks.




#43137 Trying to use string.Contains

Posted by rchelicopter on 11 January 2013 - 04:25 AM in Netduino Plus 2 (and Netduino Plus 1)

Is there a string.Contains alternative in .netmf.  I want to check if a string contains a certain substring

 

Like

 

string abc = 1234

 

if (abc.Contains("1234"))

{

do stuff

}




#42400 Cannot connect to Netduino Plus 2 socket without debugging

Posted by rchelicopter on 29 December 2012 - 04:17 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello again,

 

I'm sorry to ask this question because I know its been asked a bit on thhis forum but I'm still having problems.

 

If I want to assign a static Ip address in 4.2 do i need to turn off DHCP in MFDeploy?  Also I've seen this code around as well

 

var interf = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];

interf.EnableStaticIP("<staticIP>", "<subnetmask>", "<gateway>");

interf.EnableStaticDns(new string[] { "<primaryDNS>", "<secondaryDNS>" });

 

Can someone help me out here a bit.




#42373 Cannot connect to Netduino Plus 2 socket without debugging

Posted by rchelicopter on 29 December 2012 - 03:11 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris,

Yes I'm using DHCP. When you say default IP what do you mean, is there an arbitrary address it uses?




#42371 Cannot connect to Netduino Plus 2 socket without debugging

Posted by rchelicopter on 29 December 2012 - 02:53 AM in Netduino Plus 2 (and Netduino Plus 1)

Hello, I have been playing around with the Plus 2 and 4.2.1.2 and I just noticed that i can't connect to the socket if the usb "and" debugger are not running.  It works fine otherwise.   Can someone please have a look at this and see if I'm just doing something wrong.
using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using System.Text; namespace Socket_Server{    public class Program    {        public static void Main()        {            using (System.Net.Sockets.Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))            {                socket.Bind(new IPEndPoint(IPAddress.Any, 10100));                socket.Listen(1);                {                     while (true)                    using (Socket NetduinoSocket = socket.Accept())                    {                        byte[] buffer = Encoding.UTF8.GetBytes("You Are Now Connected.....");                        NetduinoSocket.Send(buffer, 0, buffer.Length, 0);                         bool keepAlive = true;                         while (keepAlive)                        {                            if (NetduinoSocket.Poll(1, SelectMode.SelectRead))                            {                                byte[] bytes = new byte[10];                                int count = NetduinoSocket.Receive(bytes);                                 char[] chars = Encoding.UTF8.GetChars(bytes);                                string position = new string(chars, 0, count);                                Debug.Print(position);                            }                        }                    }                }            }        }    }}



#42267 Netduino servo class

Posted by rchelicopter on 27 December 2012 - 03:43 PM in Netduino 2 (and Netduino 1)

Hello,

 

I've been playing around trying to get the PWM and analog Input stuff working on .netmf 4.2 and have been running into some problems.  So I thought I would post this to help someone else possibly, keep in mind I'm pretty new to this stuff.

I wasn't able to get any PWM output until I added servo.Start(); at the end of public Servo(Cpu.PWMChannel channelPin). Like Below

 

public Servo(Cpu.PWMChannel channelPin) { // Init the PWM pin servo = new PWM((Cpu.PWMChannel)channelPin, 20000, 1500,PWM.ScaleFactor.Microseconds, false); servo.DutyCycle = 0;

servo.Start();

// Typical settings range[0] = 1000; range[1] = 2000;

{

 

P.S.  Thank you Chris Seto for originally writing this, it has been a great deal of help to me.




#41499 Going from Netduino Plus to non Plus

Posted by rchelicopter on 13 December 2012 - 06:50 PM in Netduino 2 (and Netduino 1)

That worked great, thank you.



#41497 Going from Netduino Plus to non Plus

Posted by rchelicopter on 13 December 2012 - 06:00 PM in Netduino 2 (and Netduino 1)

Hello, Is there a way to use a project that was started on a Netduino Plus on a regular Netduino (non plus). I'm not using any networking in my current project but visual studio keeps looking for the Plus that the project was originally created for. Thanks.



#41237 Connecting an analog joystick to a netduino

Posted by rchelicopter on 08 December 2012 - 08:41 PM in Project Showcase

Hello Fabien, I know this is an old post but I just stumbled upon it. I've downloaded your source for the Analog Joystick test but I'm kind of a newb when it comes to C#. What I dont understand is how to use the class, is it possable that you could give me a small example of how to use AnalogInput Xinput and AnalogInput Yinput in a project?



#32660 Passing Servo's to another thread.

Posted by rchelicopter on 25 July 2012 - 02:13 PM in Netduino Plus 2 (and Netduino Plus 1)

You're starting one thread to which you pass two servos. The thread then uses these servos in order to adjust the angles by a 100 degrees respectively. Then the thread terminates.

Is this what you want do do?


Hello and thanks again,

It's not exactly what I want to do but its a good start. I just wanted to know if thats the correct way to pass the servos to a thread and it sounds like it will work. I'm going to play with it a bit and i really appreciate your help.

Thanks.



#32636 Passing Servo's to another thread.

Posted by rchelicopter on 24 July 2012 - 10:34 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for you help on this, I'm currently at work and dont have access to my Netduino Plus hardware and as a result the Servo_API will not run in the emulator. Can you please look at the following and see if this aproach will work. // create a new thread with the integer value 1 as parameter Thread t = new Thread(new param(Throttle, Steering).worker); // start it t.Start(); class param { private Servo Throttle; private Servo Steering; public param(Servo Throttle, Servo Steering) { // store the param this.Throttle = Throttle; this.Steering = Steering; } public void worker() { Throttle.Degree = 100; Steering.Degree = 100; } }



#32574 Passing Servo's to another thread.

Posted by rchelicopter on 23 July 2012 - 09:39 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi!

Interesting project. If you mean passing parameters to a thread, this thread ;-) discusses just that:

http://forums.netdui...able-in-the-mf/



Thanks for the reply hanzibal, I'm not quite sure thats what I'm looking for as I'm trying to use the initialized PWM port as opposed to using just a parameter.



#32560 Passing Servo's to another thread.

Posted by rchelicopter on 23 July 2012 - 06:47 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello all, I wonder if someone could help me with some code to pass a servo (Servo Servo1 = new Servo(Pins.GPIO_PIN_D5); from the Main method to another thread (ProcessClientRequest), here is the code that I'm playing with at the moment. using System; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using Microsoft.SPOT; using SecretLabs.NETMF.Hardware.NetduinoPlus; using Servo_API; namespace Threaded_Project { public static class Program { public static void Main() { Servo Servo1 = new Servo(Pins.GPIO_PIN_D5); Servo Servo2 = new Servo(Pins.GPIO_PIN_D6); Socket Server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Server.Bind(new IPEndPoint(IPAddress.Any, 10100)); Server.Listen(1); while (true) { Socket clientSocket = Server.Accept(); new ProcessClientRequest(clientSocket); } } } internal sealed class ProcessClientRequest { private Socket NetduinoSocket; public ProcessClientRequest(Socket clientSocket) { NetduinoSocket = clientSocket; new Thread(ProcessRequest).Start(); //new Thread(ReadTester).Start(); } private void ProcessRequest() { using (NetduinoSocket) { byte[] buffer = Encoding.UTF8.GetBytes("Connected"); NetduinoSocket.Send(buffer, 0, buffer.Length, 0); while (true) { if (NetduinoSocket.Poll(1, SelectMode.SelectRead)) { byte[] bytes = new byte[NetduinoSocket.Available]; int count = NetduinoSocket.Receive(bytes); string request = new String(Encoding.UTF8.GetChars(bytes)); Debug.Print(request); //Servo1.Degree = 100; //Servo2.Degree = 100; } } } } } }



#31912 Netduino Plus Socket Server Help

Posted by rchelicopter on 12 July 2012 - 05:06 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi

I would look at Stefan's excellent netmf toolbox particularly at the terminal server and simple socket classes. Typically with a socket I would use the events for connection and disconnection rather that the while loop you are currently using for detecting a connection. As it allows you greater control over the handling of such events.

Nak.


Thanks for your reply Nakchak,

I have played around with Stefan's terminal server and it is awesome to say the least. I was modifying it to better suit my needs (removing some functionality) and then I realised that I still have a problem that when the client "loses" connection unexpectedly the server still thinks its connected and I cannot connect again. Eventually i would like to end up with a solution that will take action as soon as the client drops out (wireless router).

Could you please elaborate a bit more on the "events for connection and disconnection" you eluded to? Perhaps you could point me to some documetation that helps explain this a bit more.

And thank you for your earlier comments.



#31835 Netduino Plus Socket Server Help

Posted by rchelicopter on 10 July 2012 - 09:34 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello Netduino Community, I have been playing with programming the Netduino Plus for a few months now trying to get a robust TCP server up and running. I have also been working on a windows form client to send data to the server. I am using message framing and I can detect when clients close the socket intentionally but I removed that for simplicity. It actually works suprisingly well considering I know very little about .net and ,netMF. My problem is that the Netduino Plus is on a wireless router and sometimes it loses connection to the client (basically the client loses connection unexpectedly), I have looked and looked and cannot find a method for the Netduino to detect when the client goes south on me. The client is basically pushing data to the server and so anything Ive tried in the while (true) loop stops when the client stops sending data so any code that runs in that loop to detect disconnects stops when data stops coming in (example, sending data to the client and getting a responce). I would like to be able to send data to the client outside the using loop at a slower interval than what I'm receiving but I cannot figure out how to do it. I would be more than happy to post my client and server projects if that would help. here is the code I originally started with and now I've returned to for learning using System; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace Socket_Testing { public class Program { public static void Main() { using (System.Net.Sockets.Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { socket.Bind(new IPEndPoint(IPAddress.Any, 10100)); socket.Listen(1); { while (true) using (Socket NetduinoSocket = socket.Accept()) { byte[] buffer = Encoding.UTF8.GetBytes("You Are Now Connected"); NetduinoSocket.Send(buffer, 0, buffer.Length, 0); while (true) { if (NetduinoSocket.Poll(1, SelectMode.SelectRead)) { byte[] bytes = new byte[10]; int count = NetduinoSocket.Receive(bytes); char[] chars = Encoding.UTF8.GetChars(bytes); string position = new string(chars, 0, count); Debug.Print(position); } } } } } } } }



#31821 Detect if Ethernet Cable is Connected

Posted by rchelicopter on 10 July 2012 - 03:49 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello, I am also desperately trying to detect network disconnects on a tcp socket (half open sockets) but I have not as of yet figured out how to do it. For me I don't not need to know at startup but rather after a connection has been established. DrJaymz - could you pleas elaborate on the usage of NetworkChange.NetworkAvailabilityChanged, perhaps a sample bit of code to help me a bit. Thanks.




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.