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.

mcinnes01's Content

There have been 82 items by mcinnes01 (Search limited from 20-February 18)


By content type

See this member's


Sort by                Order  

#59477 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 30 July 2014 - 10:08 PM in Project Showcase

Hi Valkyrie

 

Sorry its took so long for me to get back and thanks for the TCP example!

 

The problem I am having is that the M2Mqtt library uses System.Net.Sockets and as I have a very limited understanding of how TCP works I am struggling to identify the parts of mIP I need to use to replace the TCP class (MqttNetworkChannel) in the M2Mqtt project and how to go about implementing them.

 

In your example you clearly show a way of creating a socket, but I don't understand how you achieved this or how it can be extended to cover the scenarios required in the Mqtt TCP class.

 

For example System.Net.Sockets provides:

 

.Send()

.Recieve()

.Available()

.Connect()

.Close()

 

Which are used in the MqttNetworkChannel or TCP class.

 

It also seems that the Send, Receive and Available methods return an int value of the number of bytes sent, left in the buffer or available to be received.

 

What I would like to know is, is there any way I can achieve this with mIP?

 

I would very much like to implement your mIP library with mqtt and appreciate any help you can provide :)

 

Thanks again for your help and I hope with your assistance I can give people using any type of netduino or other boards the ability to use pub sub messaging.

 

Andy




#58881 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 24 June 2014 - 08:59 PM in Project Showcase

Hi Hanz,

 

Just a quick update, I have confirmation from Paolo who wrote the M2Mqtt library that the network library in his project uses sockets over tcp. There is a TCP class in the mIP library but I wondered if you or anyone else has any ideas or examples of how to implement TCP sockets with mIP. There are great examples of http and UDP but any pointer as to TCP would be greatly appreciated.

 

I guess in regards to my previous post the questions still remain in terms of extending mIP to provide similar structure to System.Net.Sockets in terms of returning int for send, receive and data available?

 

Thanks as ever,

 

Andy




#58871 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 23 June 2014 - 10:09 PM in Project Showcase

Hi Hanz,

 

Just wondered if you could give me a few pointers...

 

I am trying to determine what the equivalent mIP method of the following would be:

public int Send(byte[] buffer)
        {
            return this.socket.Send(buffer, 0, buffer.Length, SocketFlags.None);
        } 

And

        public int Receive(byte[] buffer)
        {
            // read all data needed (until the buffer is full)
            int idx = 0;
            while (idx < buffer.Length)
            {
                idx += this.socket.Receive(buffer, idx, buffer.Length - idx, SocketFlags.None);
            }
            return buffer.Length;
        } 

 this.socket.Send is derived from the System.Net.Sockets method:

public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags);

and this.socket.Receive is from:

public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags);

From what I can tell nothing seems to expose a send or receive method that returns a int, my only conclusion would be that this response is returned until the buffer is empty. I guess this would need some adaptation or extension of the mIP methods?

 

 

And finally the only other method I can't work out the mIP equivalent of is as follows, however it may require some extension if its possible:

public bool DataAvailable
{
   get
   {
      return (this.socket.Available > 0);
   }
}

Again drawing from System.Net.Sockets:

public int Available { get; }
 Your guidance would be greatly appreciated :)
 
Many thanks
 
Andy



#58416 Ethernet Module Update

Posted by mcinnes01 on 27 May 2014 - 08:54 AM in Netduino Go

Well that's up to you :) I know its frustrating waiting ages and comms could definitely been handled differently by secret labs, but this is the situation which I'm sure is fairly common when developing new transport protocols especially with netmf ever evolving and having to work around the bugs that are inherited with it.

The suggestion of mip + an enc28j60 is a good cheap alternative or at least stop gap. It is from what I understand the same chip on the ethernet board we are all waiting on. Plus it uses spi, so you only really lose 1 pin for chip select if you use other spi modules and the multi spi library, so not much of a sacrifice. I got it working sharing spi with a gpio expander so I actually gained pins as opposed to lost pins. Also in terms of plug and play, bar a resistor and not having a 10 pin connector or shield format, its not far off. At least this way you can move on with your code and project in the mean time, then when the ethernet module lands, fingers crossed this year, you can simply switch out the mip code for the native network code.

Hth

Andy



#58371 Ethernet Module Update

Posted by mcinnes01 on 23 May 2014 - 09:34 PM in Netduino Go

Sigh, why don't you just get a cheap ass ENC28J60 module off ebay for < 3 and use the mIP library?

 

At least this is something that WILL get ethernet to the GO without doubt.

 

Module: http://www.ebay.co.u...=item20d966b102

 

mIP: http://mip.codeplex.com/

 

I'm currently trying to get mIP working with M2Mqtt so I can get GO working with Mqtt, it would be cool to have a few other people helping explore this route :)




#58370 I Think I Found a bug in SPI

Posted by mcinnes01 on 23 May 2014 - 09:15 PM in Netduino 2 (and Netduino 1)

Hi Chris,

 

Is this a hint towards a beta 4.3 for netduino 1?

 

Cheers,

 

Andy




#57688 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 22 April 2014 - 04:41 PM in Project Showcase

Hi Hanz,

 

I am trying to create an interface between mIP and M2Mqtt, as I understand I need to replace the MqttNetworkChannel with my own implementation that inherits IMqttNetworkChannel and reference my implementation in the MqttClient class. Also I need to replace the dnsLookup in the client class.

 

The IMqttNetworkChannel looks like this:

/// <summary>
    /// Interface for channel under MQTT library
    /// </summary>
    public interface IMqttNetworkChannel
    {
        /// <summary>
        /// Data available on channel
        /// </summary>
        bool DataAvailable { get; }

        /// <summary>
        /// Receive data from the network channel
        /// </summary>
        /// <param name="buffer">Data buffer for receiving data</param>
        /// <returns>Number of bytes received</returns>
        int Receive(byte[] buffer);

        /// <summary>
        /// Send data on the network channel to the broker
        /// </summary>
        /// <param name="buffer">Data buffer to send</param>
        /// <returns>Number of byte sent</returns>
        int Send(byte[] buffer);

        /// <summary>
        /// Close the network channel
        /// </summary>
        void Close();

        /// <summary>
        /// Connect to remote server
        /// </summary>
        void Connect();
    }

Would I be correct in saying that the connect and close methods would come from mIP's Networking class?

 

And Send and Receive from the HttpRequest and HttpResponse classes?

 

I remember reading in the mIP class that it tries to stay away from sockets to make things simpler, would I be right in saying that the mqtt library is using sockets?

 

If so would there be some particular methods I should use instead of the Http ones?

 

Also would you say that Start() in mIP is Connect in M2Mqtt? Stop() relates to Close() ?

 

I have no idea in terms of DataAvailable?

 

Any help would be much appreciated :)

 

Andy




#57441 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 08 April 2014 - 10:51 PM in Project Showcase

Hi Hanz,

 

Good news, with no amendments to mIp bar the fix in the dhcp.cs and just tweaking your MCP23S17 library to run on the MultiSPI manager, I have been able to get both devices working together.

 

I am still playing with the web server on the netduino in terms of creating input fields and handling the requests as this is my first attempt. If I get something up and running I will post a video.

 

I may see if I can get the neonmika web server running on a standard netduino, any way thanks again for the help.

 

Andy




#56919 Netduino - WiFi

Posted by mcinnes01 on 19 March 2014 - 07:03 PM in Project Showcase

Hi,

 

Does anyone still have the code that was on this thread or any code to get the gainspan module working?

 

Many thanks

 

Andy




#56914 Gainspan WiFi module

Posted by mcinnes01 on 19 March 2014 - 02:11 PM in General Discussion

Hi Hanz,

 

I wonder if you have made any progress with your RAK410/411 wifi module class library?

 

The problem I have with writing drivers is I don't really know where to start, and although I have been through the datasheets and command guides a few times I'm a little unsure as to where to approach it from.

 

I wonder if you have perhaps started the lib for your module, if I could see the code so far I can try to follow your approach to and see if I can do the same for my module?

 

Thanks again for all your help,

 

Andy




#56823 Extensive driver for the MCP23S17 I/O expander

Posted by mcinnes01 on 15 March 2014 - 06:41 PM in Project Showcase

Hi,

 

I have done a little testing and my adjustments seem to work in terms of implementing the standard multi SPI class as per the netmf toolbox.

 

Please see amendments attached.

 

Next task is to create a wrapper to handle the scenario of creating cross chip groups that leverage the bus functionality where possible.

 

Many thanks,

 

Andy

 

http://1drv.ms/OlgfGw

Attached Files




#56819 Extensive driver for the MCP23S17 I/O expander

Posted by mcinnes01 on 15 March 2014 - 04:43 PM in Project Showcase

Hi Hanz,

 

No offence taken, I am taking your advice and investigating a little more before I repost. I have made a better test subject with a load of leds and am just reworking my changes to the code to get a proper test in. I should have some findings shortly so I will post back when I have something more substantial.

 

Many thanks,

 

Andy




#56761 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 12 March 2014 - 12:01 AM in Project Showcase

Sorry post to wrong thread.




#56740 NeonMika.Webserver

Posted by mcinnes01 on 10 March 2014 - 07:12 PM in Project Showcase

Hi 

 

Just wondered if this could work with the MiP library in order to use it on N GO! and standard netduino 1?

 

Also would it be possible to use MQTT with it?

 

Many thanks

 

Andy




#56629 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 04 March 2014 - 05:53 PM in Project Showcase

I've managed to get all the examples working except the UDP one, do you know what is meant to happen with this one? Does it receive UDP messages and if so how do I test it?

 

My next step is to incorporate MQTT, not sure if anyone has managed this with mIp yet?

 

Many thanks

 

Andy




#56592 Extensive driver for the MCP23S17 I/O expander

Posted by mcinnes01 on 02 March 2014 - 11:10 PM in Project Showcase

Carrying the multi SPI conversation on here...

 

Do you think it is possible to incorporate Steffan's multi spi mgr in to your MCP23S17 driver?

 

Thus making it possible to share with MIP without modifying MIP?

 

On another topic...

 

I was considering the use of the bus.

 

If I wanted to dynamically group pins/ports and abstract this further to allow me to create groups or "buses" across chips do you think this is possible.

 

Let me elaborate...

 

Am I correct in saying the use of a bus is to allow for multiple port changes to be made in one write, thus increasing speed and efficiency?

 

If this is correct, then I also understand that I can't make a bus spanning multiple chips, however if for example I wanted to change the state of 10 pins 5 on each chip, then I could create a class that identifies which pins are on which bus and perform 2 writes one for each bus?

 

This is obviously going to be more efficient than 10 separate writes and gives me the ability, for example to "turn off all lights" or "turn off everything".

 

Many thanks,

 

Andy




#56591 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 02 March 2014 - 10:35 PM in Project Showcase

Ahh that makes sense now, that would be great I would definitely be interested in that :) 




#56589 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 02 March 2014 - 10:13 PM in Project Showcase

Yep already on it on codeplex :)

 

My router is Thomson TG582n

 

I am running my own DHCP and DNS servers in server 2012.

 

TCP/IP is up and running, now just to see if it is possible to get the multi SPI to share with my MCP23S17s... Do you think it is possible?

 

Thanks for all help :)

 

Andy




#56584 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 02 March 2014 - 09:23 PM in Project Showcase

Hi Hanz,

 

When I dig in to the payload that is used to populate the options hash table.

 

I see that for options._buckets[6].value there is an 8 byte array containing the values for both IP addresses.

 

This mean that in this line where bucket 6 is assigned to the ns, there is an invalid ip address being assigned.

 

I updated the packet handler, so I could see what was going on and it seems to now work correctly, so I think this is a bug?

 

        /// <summary>
        /// Take care of a packet of DHCP stuff
        /// </summary>
        /// <param name="payload"></param>
        public static void HandlePacket(byte[] payload)
        {
            //Debug.WriteLine("Handling DHCP packet");
            
            // Check Transaction ID!
            if (transactionID == null || payload[46] != transactionID[0] || payload[47] != transactionID[1] || payload[48] != transactionID[2] || payload[49] != transactionID[3]) return;
            
            // To determine the type, we need to find the magic cookie, then find option 0x35h
            // 02 == Offer, 05 == ACK, 06 = NAK
            var options = ParseOptions(payload);


            //Debug.WriteLine("DHCP PKT");


            if (options.Contains("53"))
            {
                //Debug.WriteLine("Rec'd DHCP OFFER - 1");


                if (((byte[])(options["53"]))[0] == 0x02)  // Offer
                {
                    //Debug.WriteLine("Rec'd DHCP OFFER");


                    ushort ipHeaderLength = (ushort)((payload[14] & 0x0f) * 4);
                    PendingIpAddress = Utility.ExtractRangeFromArray(payload, ipHeaderLength + 38, 4);
                    if (options.Contains("54")) Adapter.Gateway = (byte[])options["54"];  // DHCP Server
                    if (options.Contains("6")) Adapter.DomainNameServer = Utility.ExtractRangeFromArray((byte[])options["6"], 0, 4); //DNS Server
                    if (options.Contains("6")) Adapter.DomainNameServer2 = Utility.ExtractRangeFromArray((byte[])options["6"], 4, 4); //Secondary DNS Server
                    if (options.Contains("1")) Adapter.SubnetMask = (byte[])options["1"];  // Subnet
                    if (options.Contains("3")) Adapter.Gateway = (byte[])options["3"];  // Router
                    if (options.Contains("58")) RenewTimer.Change((int)(((byte[])options["58"]).ToInt() * 1050), TwoHoursInMilliseconds); // Got a Renew time
                    if (options.Contains("51")) RenewTimer.Change((int)(((byte[])options["51"]).ToInt() * 750), TwoHoursInMilliseconds); // Got a Lease Time (I am using 750, so we renew after 75% of lease has been consumed)
                    Adapter.GatewayMac = Utility.ExtractRangeFromArray(payload, 6, 6);  // Initial gateway MAC.  Will get confirmed/updated by an ARP Probe


                    SendMessage(DHCP.Request);
                }
                else if (((byte[])options["53"])[0] == 0x05)  // ACK or Acknowledgement
                {
                    // Parse out the Gateway, DNS Servers, IP address, and apply set all the variables with it...


                    //Debug.WriteLine("Rec'd DHCP ACK");


                    if (options.Contains("54")) Adapter.Gateway = (byte[])options["54"];  // DHCP Server
                    if (options.Contains("6")) Adapter.DomainNameServer = Utility.ExtractRangeFromArray((byte[])options["6"], 0, 4); //DNS Server
                    if (options.Contains("6")) Adapter.DomainNameServer2 = Utility.ExtractRangeFromArray((byte[])options["6"], 4, 4); //Secondary DNS Server
                    if (options.Contains("1")) Adapter.SubnetMask = (byte[])options["1"];  // Subnet
                    if (options.Contains("3")) Adapter.Gateway = (byte[])options["3"];  // Router
                    if (options.Contains("58")) RenewTimer.Change((int)(((byte[])options["58"]).ToInt() * 1050), TwoHoursInMilliseconds);  // Got a Renew time
                    if (options.Contains("51")) RenewTimer.Change((int)(((byte[])options["51"]).ToInt() * 750), TwoHoursInMilliseconds);  // Got a Lease Time (I am using 750, so we renew after 75% of lease has been consumed)
                    Adapter.GatewayMac = Utility.ExtractRangeFromArray(payload, 6, 6);  // Initial gateway MAC.  Will get confirmed/updated by an ARP Probe


                    transactionID = null;
                    Adapter.AreRenewing = false;
                    Adapter.IPAddress = PendingIpAddress ?? Adapter.IPAddress;


                    Adapter.startupHold.Set();  // This will release the Adapter.Start() Method!  (if waiting)


                    Debug.WriteLine("DHCP SUCCESS!  We have an IP Address - " + Adapter.IPAddress.ToAddress() + "; DNS Server: " + Adapter.DomainNameServer.ToAddress() + "; Gateway: " + Adapter.Gateway.ToAddress());


                    ARP.SendARP_Probe(Adapter.Gateway);  // Confirm Gateway MAC address
                }
                else if (((byte[])options["53"])[0] == 0x06)  // NACK or Not Acknowledged!
                {
                    Debug.WriteLine("DHCP N-ACK");
                    transactionID = null;
                    Adapter.AreRenewing = false;


                    // We have failed to get an IP address for some reason...!
                    Adapter.IPAddress = null;
                    Adapter.Gateway = null; 
                    Adapter.GatewayMac = null;
                }
            }
        }



#56565 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 09:56 PM in Project Showcase

Server:  UnKnown
Address:  192.168.1.1
 
Name:    www.google.com
Addresses:  2a00:1450:400c:c03::67
 173.194.67.147
 173.194.67.103
 173.194.67.99
 173.194.67.104
 173.194.67.105
 173.194.67.106
 
Tried the first IP and it worked :)
 
Although this is great in terms of my netduino project, it means my network config has gone a little wrong. :(



#56559 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 08:24 PM in Project Showcase

Hmm, same issue with google?

 

Erm does that mean my dns server isn't working correctly? I don't seem to have an issue on my laptop? Is there anything I can do to check/resolve this on a network level or could it be an issue with the driver?

 

One interesting thing I noticed was that when I edit the debug info to print out my dns server, it printed out the value of both the primary and secondary in one strange output:

 

Link is now up :)
Setting IP Address to 192.168.1.51
DHCP SUCCESS!  We have an IP Address - 192.168.1.51; DNS Server: 192.168.1.1.192.168.1.254; Gateway: 192.168.1.254
Updating Gateway Mac from ARP
 
This value came from:
 
Adapter.DomainNameServer.ToAddress()



#56556 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 05:59 PM in Project Showcase

I think that error was an issue with the address odata.netflix.com not returning a dns entry.

 

I managed to get an IP from my DHCP server:

 

Link is now up :)
Setting IP Address to 192.168.1.51
DHCP SUCCESS!  We have an IP Address - 192.168.1.51; Gateway: 192.168.1.254
Updating Gateway Mac from ARP
 

 

but get this error:

 

An unhandled exception of type 'System.Exception' occurred in NetworkingService.dll
 
Additional information: Domain Name lookup for odata.netflix.com failed. 
 
 
Dropping 0 packet(s)
Packet Count is3: 0
1*** ERXRDPT: 0
1*** ERXWRPT: 1062
2*** ERXRDPT: 0
2*** ERXWRPT: 1062
Packet Count is4: 0
Packet Count is5: 0
3*** ERXRDPT: 0
3*** ERXWRPT: 1062
4*** ERXRDPT: 0
4*** ERXWRPT: 1062
4*** Setting Next Packet Pointer to: 0
A first chance exception of type 'System.Exception' occurred in NetworkingService.dll
An unhandled exception of type 'System.Exception' occurred in NetworkingService.dll
Additional information: Domain Name lookup for odata.netflix.com failed. 
 



#56555 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 05:48 PM in Project Showcase

I have the boards connected as follows:

 

(left netduino / right ENC28)

 

Gnd = gnd

3.3v = vcc

Reset = reset

D13 = SCK

D12 = MISO

D11 = MOSI

D10 = CS

D8 = INT (D8 also has a 10K resistor going to ground)

 

The board is from ebay... http://www.ebay.co.u...=item35c89fc698

 

I have added in SecretLabs.NETMF.Hardward.Netduino, so my profile is as follows:

 

case InterfaceProfile.Netduino1:
                    // MOSI(D12), SCK(D13), MISO(D11), INT(D8), CS(D10) 
                    Start(MacAddress, name, SPI.SPI_module.SPI1, SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D8, SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D10);
                    break;

My interrupt method is as follows:

irq = new InterruptPort(irqPin, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLevelLow);

I now get the error:

 

Error: a3000000
 
Waiting for debug commands...
 
The program '[19] Micro Framework application: Managed' has exited with code 0 (0x0).
 



#56552 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 05:24 PM in Project Showcase

I'm pretty sure, the answer is in the error... "Check the interface profile"

 

I think it comes back to my confusion over the values in other profiles of the (Cpu.Pin).

 

I guess that D8 does not equal (Cpu.Pin)8 in reference to a standard netduino 1?

 

Would this be 62 at a guess?

 

And D10 would be 64?

 

Many thanks

 

Andy




#56551 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 01 March 2014 - 04:57 PM in Project Showcase

Ok, that seemed to get me a little further but now I get the following exception in the Start() method:

 

The thread '<No Name>' (0x2) has exited with code 0 (0x0).
A first chance exception of type 'System.Exception' occurred in NetworkingService.dll
An unhandled exception of type 'System.Exception' occurred in NetworkingService.dll
Additional information: Unable to Communicate to the Ethernet Controller.  Check the InterfaceProfile in your Adapter.Start()
 

Which breaks on line:

if (loopMax <= 0) throw new Exception("Unable to Communicate to the Ethernet Controller.  Check the InterfaceProfile in your Adapter.Start()");

From the code:

/// <summary>
/// Starts up the driver and establishes a link
/// </summary>
public void Start()
{
byte i;


var loopMax = 100;  // about 10 seconds with a 100 ms sleep


// Wait for CLKRDY to become set.
// Bit 3 in ESTAT is an unimplemented bit.  If it reads out as '1' that
// means the part is in RESET or there is something wrong with the SPI 
// connection.  This loop makes sure that we can communicate with the 
// ENC28J60 before proceeding.
// 2.2 -- After a Power-on Reset, or the ENC28J60 is removed from Power-Down mode, the
//        CLKRDY bit must be polled before transmitting packets
do
{
i = ReadCommonReg(ESTAT);
loopMax--;
Thread.Sleep(100);
} while(((i & 0x08) != 0 || (~i & ESTAT_CLKRDY) != 0) && loopMax > 0);


            if (Adapter.VerboseDebugging) Debug.WriteLine("ESTAT: " + ReadCommonReg(ESTAT).ToString());


if (loopMax <= 0) throw new Exception("Unable to Communicate to the Ethernet Controller.  Check the InterfaceProfile in your Adapter.Start()");


            regCheckTimer = new Timer(new TimerCallback(CheckRegisters), null, checkDelay, checkDelay);
            watchdog = new Timer(new TimerCallback(WatchDogCheck), null, 10000, 3000);


Restart();
            //Init();
}




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.