Netduino home hardware projects downloads community

Jump to content


Photo

New to Visual Studio and C#


  • Please log in to reply
14 replies to this topic

#1 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 18 January 2012 - 05:11 AM

Hi all, Being new to Netduino, it seems wise to me to ask some very basic questions about how we interact with the device and the language used to program it. I have fired up VS, and looked at a bit of code... It seems that there are all of these libraries, or perhaps just a library with many routines to be called... I have heard that there are *thousands* of routines to access. To me, these routines are fully invisible... the contents and purpose of the libraries a total mystery. How can one get easy, comprehensive visibility of the capabilities and usage of a library while programming? Thank you!

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 18 January 2012 - 08:21 AM

Hi Ryder,

As you are new to all this, I advise to check these 3 tutorials: Getting started with Netduino, Button tutorial and Using event handlers. Most parts of the library are also documented by Microsoft in the API Reference for .NET Micro Framework.

Good luck!
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 OppaErich

OppaErich

    Member

  • Members
  • PipPip
  • 22 posts
  • LocationEssen, Germany

Posted 18 January 2012 - 10:15 AM

and looked at a bit of code...

Scary, isn't it ? I own a netduino for about a year but haven't done anything with it yet. I don't know C# and looking at code snippets posted here, I'm always wondering: "Is this code or a novel ?" :blink: I'm digging into msp430s now, that's plain C. Good luck.

#4 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 18 January 2012 - 11:11 AM

Scary, isn't it ? I own a netduino for about a year but haven't done anything with it yet. I don't know C# and looking at code snippets posted here, I'm always wondering: "Is this code or a novel ?" :blink: I'm digging into msp430s now, that's plain C. Good luck.

Scary? It's another language, like English and Mandarin are different languages. It's up to the user if (s)he wants to learn another language. I found out that it can be very useful to speak multiple languages. English isn't my main language, but I learned to speak it since it's a commonly used language.

You could also try to use Visual Basic by the way, also works on a Netduino :D
And if you really like C or C++, the Netduino can work for you. It can run native code; the firmware is written in it. If you want to go on this track, some useful resources can be found at http://wiki.netduino....ashx?HL=native
Although, in my humble opinion, it would take the .NET out of the Duino. :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#5 OppaErich

OppaErich

    Member

  • Members
  • PipPip
  • 22 posts
  • LocationEssen, Germany

Posted 18 January 2012 - 11:32 AM

You could also try to use Visual Basic by the way, also works on a Netduino :D
And if you really like C or C++

It's not that I really like C, I have just gone a little bit further than Hello World in C already. With C# only Console.WriteLine, well Mono actually... and haven't tried VB yet.

"Scary" was referring to the (novel-like) size of the code. Of course does everything you don't know look strange.

#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 706 posts
  • LocationBerkshire, UK

Posted 18 January 2012 - 12:51 PM

I got into the Netduino after buying the book Getting started with the internet of things.

It leads you through step by step. Based on this I decided to buy a Netduino plus and get started.

There is also Chris's book Getting stated with Netduino. But I don't have a copy myself. (Maybe he'll send me a copy free for recommending it. :) )

The book I bought was not a full .Net / C# course, but it was enough to do the simple stuff and get the confidence to move on.

... looking at code snippets posted here, I'm always wondering: "Is this code or a novel ?" :blink:

I sometimes cringe when I see the great chunks of code people paste into forum posts, but its usually appropriate as to get help you often need to give a lot of detail. Often you will find that the person posting has put a lot of effort into using classes properly to make their code re-usable, had they not done this, there was probably a simple one or two line method they could have used to get started.

Paul

#7 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 January 2012 - 07:09 AM

Hi Ryder,

As you are new to all this, I advise to check these 3 tutorials: Getting started with Netduino, Button tutorial and Using event handlers. Most parts of the library are also documented by Microsoft in the API Reference for .NET Micro Framework.

Good luck!


Thanks ever so much, Stefan... I have already done the entire GSIOT, and even set my 'duino up as a web server, so those tutorials didn't add much...

What I am missing is what I mentioned right from the start... there are, or so I hear, thousands of "functions" or objects or whatever they are, available as part of .NETMF / Netduino. Assuming this is true... they are entirely invisible to me.

When I start Visual Studio, obviously there is what is essentially a "blank page", yet the programming environment seems to somehow know quite a lot about the bazillions of Netduino objects that it so patiently waits for me to use.

This beggs the question... since I am starting from nothing, inside a brilliant programming environment that knows so much about the specific functionality of the Netduino... isn't there some sort of "bridge" or "window" from the vastness of the white empty canvas first presented, to the functionality available to the programmer?

I guess what I am asking, is there any way to convince this brilliant programming environment to share something about what it knows wrt Netduino? It seems to know about syntax... it seems to know about functions and the arguments for each... (or I should probably say objects and methods)

When I select "help" I go to a microsoft page that wants to talk about generic c#, which is not what I need at all.

I need netduino specific functions, so that I can try them. Can I not at least get Visual C# 2010 Express to show me a list of the functions or objects it has that relate directly to Netduino?

If I had a list, at least that would be something... I could select a few things at random, and play with them.

As it stands, I have nothing really. A blank page. I certainly don't want to guess the names of objects or their methods, and I don't want to keep typing in other peoples code verbatim. Time to discover everything... and try it.

I remember using the macro language help in MS Excel, and that help ***rocked*** it gave you lists and summaries of functions based on category, for example. Of course it too was a microsoft product, so I hold out hope.

So again, this specifically relates to the resources *within the programming environment*.

Thank you!

#8 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 January 2012 - 07:44 AM

What I am missing is what I mentioned right from the start... there are, or so I hear, thousands of "functions" or objects or whatever they are, available as part of .NETMF / Netduino. Assuming this is true... they are entirely invisible to me.

Not thousands, and most are part of the .NETMF. Those are all described on the link I gave you; API Reference for .NET Micro Framework
But if it may help you, open a new netduino project, press and hold the Ctrl key, and press W and C. Then release the Ctrl key. A new window 'Class View' pops up. With this window you can browse through all references that are available at that time.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#9 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 January 2012 - 09:01 AM

Holy secret handshakes, Batman! So there IS a 'secret' window to what the IDE knows... amazing. I feel like I was just admitted to an exclusive club. But it's not really a help system so much, is it... hmmm... some of it is pretty cryptic. But I did go to the API Reference, and as I suspected... it really was a massive mound of things that simply don't apply to netduino, with no way to easily tell which do and which don't... example: ----------------------------------------- Microsoft.SPOT.Presentation Namespace Displays and arranges graphical user interface items, such as a window and its child elements. ----------------------------------------- Netduino has no graphical user interface! (unless I suppose you add one)... How do programmers sift through all that stuff, and find what applies to our little board? See, the Netduino is SO small and SO limited, I figured it would be easy to program... like the BASIC Stamp from Parallax or something. I appreciate that .NetMF is a subset of the crazy huge .NetF, but still... I feel looking at the .NetMF like I am learning how to program a NASA rocket, as opposed to a 2 inch square gizmo with an LED on it. For example, I see that programmers regularly use Microsoft.SPOT.Hardware, and it has a BATTERY member... but I seriously doubt that the Netduino can actually do the things that BATTERY says it can do, like measure the temperature of the battery I have attached to it... But... how can I know before wasting any time on it, if it applies to netduino? But let's pretend that BATTERY can tell me the temperature... the API page doesn't really tell you all you need. It says it tells you the current temperature of the battery... but doesn't tell you the unit of measure! C or F? (for example). Anyway, sorry for the newb questions... like I said, I am used to languages where EVERYTHING applies, and there is no sifting process... Thank you!

#10 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 January 2012 - 09:15 AM

Not thousands, and most are part of the .NETMF. Those are all described on the link I gave you; API Reference for .NET Micro Framework
But if it may help you, open a new netduino project, press and hold the Ctrl key, and press W and C. Then release the Ctrl key. A new window 'Class View' pops up. With this window you can browse through all references that are available at that time.



Sorry, one final thing... you said "most" of the objects are in the API

What are the others? How does one discover more about them and their use?

Regards,

Ryder

#11 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 January 2012 - 09:19 AM

Sorry, one final thing... you said "most" of the objects are in the API

What are the others? How does one discover more about them and their use?

The .NETMF documentation only covers the objects in the .NETMF
The key combo I just explained shows them all.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#12 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 20 January 2012 - 02:13 AM

The .NETMF documentation only covers the objects in the .NETMF
The key combo I just explained shows them all.


Ok, just to be sure... everything is seen in the class view window, not just the libraries(?) that are indicated with the "using" command?

How does the IDE know about all of these objects?

Thanks!

#13 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 20 January 2012 - 05:26 PM

Ok, just to be sure... everything is seen in the class view window, not just the libraries(?) that are indicated with the "using" command?

How does the IDE know about all of these objects?

Thanks!

Everything is in libraries. It knows about it since the libraries explains themselves. For example, check out this code (part of a library written by me): Toolbox.NETMF.Hardware.Speaker
I'll put out a few lines:
/// <summary>
/// Generates a sound through your speaker.
/// </summary>
/// <param name="Frequency">The frequency of the sound in hertz; a value in the range 37 through 32,767</param>
/// <param name="Duration">The number of ticks the sound should last; a value in the range 0 through 65,535. There are 18.2 ticks per second.</param>
public void Sound(float Frequency, float Duration)
{
You'll see a method declaration, called Sound. With the XML comments I wrote above it in the source code, the Visual Studio IDE recognises the method and knows which parameters are accepted, and can guide you using them.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#14 Ryder

Ryder

    Member

  • Members
  • PipPip
  • 13 posts

Posted 23 January 2012 - 07:26 AM

Everything is in libraries. It knows about it since the libraries explains themselves. For example, check out this code (part of a library written by me): Toolbox.NETMF.Hardware.Speaker
I'll put out a few lines:

/// <summary>
/// Generates a sound through your speaker.
/// </summary>
/// <param name="Frequency">The frequency of the sound in hertz; a value in the range 37 through 32,767</param>
/// <param name="Duration">The number of ticks the sound should last; a value in the range 0 through 65,535. There are 18.2 ticks per second.</param>
public void Sound(float Frequency, float Duration)
{
You'll see a method declaration, called Sound. With the XML comments I wrote above it in the source code, the Visual Studio IDE recognises the method and knows which parameters are accepted, and can guide you using them.



Ok, I can see how that works *within* a library... but how does Visual Studio even know the library exists? That is what I am getting at.

Thank you!

R

#15 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 January 2012 - 09:04 AM

Ok, I can see how that works *within* a library... but how does Visual Studio even know the library exists? That is what I am getting at.

Because you said so :)
When you start a new project, you'll start with a template, for example "Netduino Application", a few references exist within the template. With this specific template it has a few netduino specific references.

This is not Netduino specific by the way. This is how the C# language works.
Perhaps you should start here if you're not familiar with C#: http://msdn.microsof...y/ms228593.aspx

I mus say, I have the feeling you're trying to comprehend everything at once. Just try a bit, experiment. And learn over time. Nothing, especially not a programming language, can be learned in a few days, and you should just try to use it.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2010-2014 Secret Labs LLC  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.