Thanks everyone for the thoughtful responses. It does appears GHI is the market leader in .Net, I’d like to use the USBizi chipset on my board. Gus you may remember we’ve spoken a few times. I flew to Seattle for the weekend to work with a friend moving our code from the Digi Connect ME .net over to the Domino wih external WizNet 5100 on an Arduino shield. I did the pin jumper debug switch bypass, no big deal there though we later realized we could do that in code if we got that right.
We are having issues getting the ethernet to work at all. It won’t do ethernet.enable, or WIZnet_W5100.Enable(); The shield I have is a DFRobot Arduino, pretty standard. I think bought it from you directly in the version 3.5 timeframe.
We want to set up the device for DHCP, or a static IP, and if we have to manually assign the MAC that’s no problem. We just need it to have connectivity so we can try to get some work done today.
If we do if(!Ethernet.IsEnabled) to enable the ethernet we get a “system.notsupported” exception. A number of things below are commented out, but this gives an idea what we are trying to do.
using System;
using System.IO.Ports;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.Sockets;
using GHIElectronics.NETMF.Net.NetworkInformation;
namespace FezDominoReader
{
public class Program
{
public static void Main()
{
try
{
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, Cpu.Pin.GPIO_Pin10, Cpu.Pin.GPIO_Pin9, true);
if(!Ethernet.IsEnabled)
{
Ethernet.Enable();
}
byte[] mac = NetworkInterface.PhysicalAddress;
byte[] mac = { 0x00, 0x26, 0x1C, 0x7B, 0x29,0xE8 };
//byte[] ip = { 192, 168, 0, 180 };
//byte[] subnet = { 255, 255, 255, 0 };
//byte[] gateway = { 192, 168, 0, 1 };
//NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
//byte[] dns = { 192, 168, 0, 1 };
//NetworkInterface.EnableStaticDns(dns);
Dhcp.EnableDhcp(mac, "192.168.0.1");
string testReq = RequestWebPage(@ "www.yahoo.com", 80, "", "");
Debug.Print(testReq);
while(true)
{
Thread.Sleep(500);
}
}
finally
{
}
}
static Socket ConnectSocket(String server, Int32 port)
{
// Get server's IP address.
IPHostEntry hostEntry = Dns.GetHostEntry(server);
// Create socket and connect to the server's IP address and port
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(new IPEndPoint(hostEntry.AddressList[0], port));
return socket;
}
static string RequestWebPage(String server, int port, string pageUrl, string content)
{
const Int32 c_microsecondsPerSecond = 1000000;
// Create a socket connection to the specified server and port.
using(Socket serverSocket = ConnectSocket(server, port))
{
string request = "POST " + pageUrl + " HTTP/1.1\r\n" +
"Host: " + server + "\r\nConnection: Close\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: " + content.Length.ToString() + "\r\n\r\n" +
content + "\r\n";
Byte[] bytesToSend = Encoding.UTF8.GetBytes(request);
serverSocket.Send(bytesToSend, bytesToSend.Length, 0);
// Allocate a buffer that we'll keep reusing to receive HTML chunks
Byte[] buffer = new Byte[1024];
// 'page' refers to the HTML data as it is built up.
String page = String.Empty;
// Poll for data until 30 second time out - Returns true for data and connection closed
while(serverSocket.Poll(30 * c_microsecondsPerSecond, SelectMode.SelectRead))
{
// Read a buffer-sized HTML chunk
Int32 bytesRead = serverSocket.Receive(buffer);
// If 0 bytes in buffer, then connection is closed
if(bytesRead == 0)
break;
// Append the chunk to the string
byte[] justDataBytes = buffer;
if(bytesRead != buffer.Length)
{
justDataBytes = new byte[bytesRead];
Array.Copy(buffer, justDataBytes, bytesRead);
}
page += new string(Encoding.UTF8.GetChars(justDataBytes));
}
return page; // Return the complete string
}
}
}
}
/Joe: I fixed the mac address