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.

willgeorge

Member Since 09 Jul 2011
Offline Last Active Jul 19 2015 10:51 AM
-----

Posts I've Made

In Topic: Netduino Run Application from PC (pass parameters to. EXE)

15 September 2012 - 08:59 PM

Excuse

Ever have implemented an application to Netduino from a PC, you can?
what happens is that I want to make an application that receives input parameters from the PC (console) and run actions from the Netduino, the Netduino course will always be connected to the PC.

Anyone know, how you could do? because when I create the executable from Visual Studio, not working.

Thank you.



Take a look at this. It may be what you need.
http://forums.netdui...tion-using-usb/

In Topic: Reading & Wriring INI file from SD Micro

06 March 2012 - 08:00 AM

Here is a class for reading & writing INI file from/to Micro SD
It is very simple one... but does the work just fine ;-)
Any feedback will be nice to have.

Here is the source code:


using System;
using System.IO;
using System.Collections;
using System.Threading;

namespace NetduinoPlusMonitor
{
  public class CIni
  {
    public CIni()
    {
      _Sections = new Hashtable();
    }

    /// <summary>
    /// Loads the Reads the data in the ini file into the IniFile object
    /// </summary>
    /// <param name="filename"></param>
    public void Load(string FileName, bool append)
    {
      if (!append)
        DeleteSections();

      string Section = "";
      string[] keyvaluepair;

      using (FileStream inFileStream = new FileStream(Path.Combine("\\SD",FileName), FileMode.Open))
      {
        using (StreamReader inStreamReader = new StreamReader(inFileStream))
        {
          string[] lines = inStreamReader.ReadToEnd().ToLower().Split(new char[] { '\n', '\r' });

          foreach(string line in lines)
          {
            if (line == string.Empty)
              continue;
            if (';' == line[0])
              continue;

            if ('[' == line[0] && ']' == line[line.Length - 1])
              Section = line.Substring(1, line.Length - 2);

            else if (-1 != line.IndexOf("="))
            {
              keyvaluepair = line.Split(new char[] { '=' });
              SetValue(Section, keyvaluepair[0], keyvaluepair[1]);
            }
          }
          inStreamReader.Close();
          inFileStream.Close();
        }
      }

    }

    /// <summary>
    /// Used to save the data back to the file or your choice
    /// </summary>
    /// <param name="FileName"></param>
    public void Save(string FileName)
    {
      using (FileStream outFileStream = new FileStream(Path.Combine("\\SD",FileName), FileMode.Create))
      {
        using (StreamWriter outStreamWriter = new StreamWriter(outFileStream))
        {
          foreach (object Sections in _Sections.Keys)
          {
            outStreamWriter.WriteLine("[" + Sections.ToString() + "]");
            Hashtable keyvalpair = (Hashtable)_Sections[Sections];

            foreach (object key in keyvalpair.Keys)
              outStreamWriter.WriteLine(key.ToString() + "=" + keyvalpair[key].ToString());
          }

          outStreamWriter.Close();
          outFileStream.Close();
        }
      }

    }

    public string GetValue(string Section, string key, string defkey = "")
    {
      key = key.ToLower();
      Section = Section.ToLower();

      Hashtable keyvalpair = (Hashtable)_Sections[Section];

      if ((null != keyvalpair) && (keyvalpair.Contains(key)))
        defkey = keyvalpair[key].ToString();

      return defkey;
    }
    public float GetValue(string Section, string key, float defkey)
    {
      try { defkey = (float)double.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public double GetValue(string Section, string key, double defkey)
    {
      try { defkey = double.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public UInt64 GetValue(string Section, string key, UInt64 defkey)
    {
      try { defkey = UInt64.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public UInt32 GetValue(string Section, string key, UInt32 defkey)
    {
      try { defkey = UInt32.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public UInt16 GetValue(string Section, string key, UInt16 defkey)
    {
      try { defkey = UInt16.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public byte GetValue(string Section, string key, byte defkey)
    {
      try { defkey = byte.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public Int64 GetValue(string Section, string key, Int64 defkey)
    {
      try { defkey = Int64.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public Int32 GetValue(string Section, string key, Int32 defkey)
    {
      try { defkey = Int32.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }
    public Int16 GetValue(string Section, string key, Int16 defkey)
    {
      try { defkey = Int16.Parse(GetValue(Section, key, defkey.ToString())); }
      catch (Exception) { }
      return defkey;
    }

    public void SetValue(string Section, string key, string value)
    {
      key = key.ToLower();
      Section = Section.ToLower();

      if (!_Sections.Contains(Section))
        _Sections.Add(Section, new Hashtable());

      Hashtable keyvalpair = (Hashtable)_Sections[Section];

      if (keyvalpair.Contains(key))
        keyvalpair[key] = value;
      else
        keyvalpair.Add(key, value);
    }
    public void SetValue(string Section, string key, float value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, double value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, byte value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, Int16 value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, Int32 value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, Int64 value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, char value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, UInt16 value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, UInt32 value)
    {
      SetValue(Section, key, value.ToString());
    }
    public void SetValue(string Section, string key, UInt64 value)
    {
      SetValue(Section, key, value.ToString());
    }

    public void DeleteSection(string Section)
    {
      Section = Section.ToLower();

      if (_Sections.Contains(Section))
        _Sections.Remove(Section);
    }
    public void DeleteSections()
    {
      _Sections.Clear();
    }

    private Hashtable _Sections = null;

  }
}


Thank You..

I was just looking for some of my old code in order to use an ini file.. I will not bother looking further..

Strange.. I was looking for my old code and by chance.. I need to look no further... Yours looks to be more compact than what I remember of mine.

In Topic: Building a circuit with the EasyDriver

05 March 2012 - 09:39 AM

Hi,

Does anyone have a schematic or preferrably a graphical instructable on how to build the circuit to connect up to the EasyDriver, and also connect the stepper motor?

I've seen a portugese tutorial (with no circuit help) and some other code-related examples but nothing for the actual connections...

Thanks!



Not sure if it will help but I found this link.. I do not have the easy driver hardware.

http://www.schmalzhaus.com/EasyDriver/

In Topic: Delay or getting stuck at deployment "Preparing to deploy assemblies to t...

02 March 2012 - 11:16 AM

My solution is to disconnect USB and reconnect.. Mine also.. I have had this problem since day one but I have learned not to let it get to me. Now it is part of the 'fun' of coding the Netduino. I do have to admit that the USB connector on the Netduino is of the best quality based upon the amount of times I have had to unplug and plug it back in ;>). I also have occasional restarting of the Microsoft Visual Express 2010 (Sort of re-boots itself) as in the visual express application closes itself and restarts. It does restart with the Netduino application I was working with. The only thing I know for sure that causes it is having something running in a tight loop as Magpie has noted.

In Topic: Unique identifier for netduino boards: Is there a serial no burned in?

07 February 2012 - 08:22 AM

Maybe I am way out in left field for what you want do do? Why not just add a number or message in your Netduino code that is returned to the external application when asked? Yes, you would have to always be sure that this code is included when changing your Netduino's application but it would be simple to implement.

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.