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.
Photo

netduino plus as controller


  • Please log in to reply
1 reply to this topic

#1 davasquez

davasquez

    Member

  • Members
  • PipPip
  • 16 posts

Posted 03 February 2013 - 03:13 AM

Hi, i have a simple question. i want to send a message from my netduino plus, to my pc. I want [color=rgb(0,0,0);font-family:arial, sans-serif;font-size:13px;font-weight:bold;] to establish my Nd+ as a master and my computer as a slave[/color]. Here is the code, the IP Address Pc is 192.168.1.100. have i an error, or is this possible?. Thanks

 

 

Code ND+:

Public
class Program

  {

Public
static void Main()

  {

OutputPort led = new OutputPort(Pins.ONBOARD_LED,
false);

Socket sck = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

IPEndPoint localEndPoint = new
IPEndPoint(IPAddress.Parse("192.168.1.100"),44818); //Direccion IP del PC

  sck.Connect(localEndPoint);

try

  {

  sck.Connect(localEndPoint);

string Sender_Context = "Conectar";

 

byte[] data = Encoding.UTF8.GetBytes(Sender_Context);


sck.Send(data);

Debug.Print("Sender_Context enviado");

sck.Close();

  }

catch

  {

Debug.Print("imposible conectar con el PC rn");

  }

 

 

  }

 

  }


Code PC:

Class Program

{

Static
void Main(string[] args)

  {

Socket sck = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

IPEndPoint localEndPoint = new
IPEndPoint(IPAddress.Any,
44818);

  sck.Bind(localEndPoint);

  sck.Listen(100);

Socket clientSocket;

while
(true)

  {

  clientSocket = sck.Accept();

 

Byte[] buffer = newByte[100];

 
clientSocket.Receive(buffer);

string
request = newstring(Encoding.UTF8.GetChars(buffer));

//////////////////////////////////////

Console.Write(request);

}

}

}



#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 03 February 2013 - 05:02 AM

Davasquez, you should check the flashed value of the IP in your Netduino.

I had a similar issue time ago, and I realized that the flashed IP mask have to match your network numeration.

 

Proceed as follows:

- start MFDeploy.exe which is located is this path (or something like this): C:Program Files (x86)Microsoft .NET Micro Frameworkv4.2Tools

- Be sure your board is connected to the USB, then select "USB" from the "Device" frame, just in front of you;

- Try "Ping"-ing the board, just for ensure the proper working;

- Select the menu "Target-Configuration-Network", and a dedicated dialog will open;

- Either enabled the "DHCP" (that's for me, for instance), or explicitly set the board IP in the boxes, as you would do for a Windows PC;

- once completed, I suggest to power off-then-on your board, then verify the correct settings.

 

Hope it helps.

Cheers


Biggest fault of Netduino? It runs by electricity.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

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.