I’ve started porting some of our old NETMF stuff to tinyCLROS but network initialization is giving me problems. I simply can’t find info on how to do it. In our old applications we use the NetworkInterface class to configure IP parameters or select dhcp. I also use SPOT to monitor changes in availability. Writing my own monitoring thread is no problem but how do i set the IP configuration?
In essence what i need to do is to get configuration from a file on SD card and set up network. What’s your sugested workflow / how would you go about to
find interface (is it allocated automatically like in MF4.3 so it’s enough to use GetAllIntefaces?)
enable DHCP
set static IP
set dns addr
It’s a custom hardware but network design was ripped of FezCobra II schematic
TinyCLR OS currently has all major features minus built-in-networking/usb-host/IFU.
However, we have wrappers for networking ready so devices with built in TCP/IP, like the WiFi module we use on FEZ, can be utilized with a common “.NET-like” interface.
Yes we have a custom board based on the Fez Cobra II design as a reference. I.e G120 SoC with ENC28J60 Ethernet controller on SPI. Also uses SD card directly connected to G120.
I’m trying to move from .NETMF-4.3 to TinyCLROS
In .NET i instansiate driver from GHI library like
var eth0 = GHI.Networking.EthernetENC28J60(
SPI.SPI_module.SPI2,
G120.P1_10, // chip select
G120.P2_11, // external interrupt
G120.P1_9 // reset
);
I’m also having trouble using SD card. StorageController SDController = StorageController.GetDefault(); throws a nullpointer exception as does every “Name” that i can come up with including @“GHIElectronics.TinyCLR.NativeApis.STM32F4.SdCardStorageController\0” from your tutorial.
Yes it’s on a plain G120. As i mentioned the nullpointer exception is thrown immediately when calling StorageControler.GetDefault(). Hardware adaption class starts with:
Complete test program, still throws at first line on my G120 board:
using System;
using System.Threading;
using System.Diagnostics;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Devices.Pwm;
using GHIElectronics.TinyCLR.Pins;
using GHIElectronics.TinyCLR.Devices.Storage;
using GHIElectronics.TinyCLR.IO;
namespace TinyCLRApplication1
{
class Program
{
static void Main()
{
StorageController SDController = StorageController.GetDefault();
IDriveProvider SDDrive = null;
GpioController GPIO = GpioController.GetDefault();
GpioPin SDDetect = GPIO.OpenPin(G120.GpioPin.P1_8);
SDDetect.SetDriveMode(GpioPinDriveMode.InputPullUp);
PwmController pwm1 = PwmController.FromName(G120.PwmChannel.Controller1.Id);
pwm1.SetDesiredFrequency(1500);
var R = pwm1.OpenChannel(G120.PwmChannel.Controller1.P3_26);
R.Start();
var G = pwm1.OpenChannel(G120.PwmChannel.Controller1.P3_24);
G.Start();
var B = pwm1.OpenChannel(G120.PwmChannel.Controller1.P3_25);
B.Start();
R.SetActiveDutyCyclePercentage(0.2);
G.SetActiveDutyCyclePercentage(0.2);
B.SetActiveDutyCyclePercentage(0.0);
while (true)
{
try // If SD card was removed while mounting, it may throw exceptions
{
// make sure it is fully inserted and stable
if (SDDetect.Read() == GpioPinValue.Low)
{
if (SDDrive == null)
{
SDDrive = FileSystem.Mount(SDController.Hdc);
Debug.WriteLine("Mounted: " + SDDrive.Name);
R.SetActiveDutyCyclePercentage(0.0);
G.SetActiveDutyCyclePercentage(0.8);
B.SetActiveDutyCyclePercentage(0.0);
}
}
else
{
if (SDDrive != null)
{
FileSystem.Unmount(SDController.Hdc);
SDDrive = null;
R.SetActiveDutyCyclePercentage(0.8);
G.SetActiveDutyCyclePercentage(0.0);
B.SetActiveDutyCyclePercentage(0.8);
}
}
}
catch (Exception e)
{
Debug.WriteLine(e.ToString());
R.SetActiveDutyCyclePercentage(0.8);
G.SetActiveDutyCyclePercentage(0.0);
B.SetActiveDutyCyclePercentage(0.0);
}
Thread.Sleep(100);
}
}
}