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.

Mati

Member Since 30 Apr 2011
Offline Last Active Oct 17 2012 04:31 PM
-----

Posts I've Made

In Topic: string to int's

06 June 2011 - 08:51 PM


Would not expect too much in the way of performance though - there are two expensive operations there, the Split and the Parse.


Well, I was bored. Here's an alternative ugly way to do this without using Split and Parse. Probably faster though.


            string mystring = "1234,34,26,6,1,205";

            // An array list allows easy management of it items, especially when you 
            // don't know their type or initial amount
            ArrayList numList = new ArrayList();

            // Assign a variable to store the sum for the current number
            int currSum = 0;

            // Run over each character in the string plus one extra for the tailing digit
            // (there are a lot of ways of handling the last digit, I chose this one)
            for (int i = 0; i < mystring.Length + 1; i++)
            {
                // Check that we didn't reached a comma (which means move to next number) OR
                // that it isn't the last digit.
                if (i != mystring.Length && mystring[i] != ',')
                {
                    // Multiply the current sum by ten to add the digit into it's right place.
                    // (For the first digit of each number, this multiplication is useless)
                    currSum *= 10;

                    // Add the current digit - subtract 48 to convert the ASCII char to number
                    currSum += (int)mystring[i] - 48;
                }
                else
                {
                    // We have reached a ',' or the last char - add the current sum
                    numList.Add(currSum);

                    // Reset the current sum to handle the next number
                    currSum = 0;
                }
            }


I would recommend you Mark's way. That's how I would implement it too normally. But if you are bored like me or
very performance greedy, you can do it my way too :). This one can be optimized even more (I'm not that bored)

In Topic: Netduino 1 Firmware v4.1.1 BETA 1

30 May 2011 - 05:43 PM

Hi Chris!

I've got myself into troubles today with my Netduino.

Got the 4.1.1 b1 firmware. The Echo app worked well, so I moved to the Keyboard sample.
I think I've followed all the steps as posted, but for some reason it didn't work.

I got the message that I should reconnect the USB. After reconnecting, it still was stuck in the
status polling loop. I never got a "Running" PortState, got "Attached" and then it turned to "Suspended" for some
reason.

After that problem, I couldn't deploy via serial anymore. Each attempt would get VS stuck (I did had external AC and all
the requirements as posted here). MFDeploy also couldn't ping the device through Serial or USB.

My only solution was to use the erase pad and reprogram with SAM-BA.

Didn't tried it again though, hope it won't reproduce. I'll be glad if someone could
explain what happened to my board. Is it a common faulty behavior?

I've noticed that in the "Safely Remove Hardware" (win xp sp3) I had a device called
"USB Serial Converter" - trying to remove it caused my OS to stuck for a while. Also, trying disabling it through the
Device manager - made the mmc console to crash lol. Hard reset solved everything :). I'm wondering if that device could
make the netduino not recognized as a HID? I'm thinking that the "converter device" mentioned above is related to my FTDI 3.3v basic breakout board which required special VCP drivers. After restarting it didn't appeared again and everything was back to normal.

I wish the MSDN could be more informative about that PortState enumeration. Here you can see how funny it's documented.

In Topic: Best way to convert string to number

30 May 2011 - 02:55 PM

Does the .NETMF have the TryParse method?


No it doesn't as far as I've seen. You should try/catch it if there's a chance that it's input
is not always numeric

In Topic: Driverless PC<->Netduino communication using USB

30 May 2011 - 01:10 PM

Hey, Why an AC Brick / External power is required? Though the USB cable should provide the voltage. I am planning to implement a custom HID device. My question is, will I require an external power source to run my device in order to enjoy USB communication? When I attach the Netduino, it won't recognize the device unless it's plugged to an AC brick, the echo console app tells me the same

In Topic: System.Collections.Generic missing?

29 May 2011 - 09:39 AM

From what I've seen in .NET MF, there are no Generic collections. However, there are basic collections in the System.Collections namespace : ArrayList, Hashtable, Queue and Stack. Also, there are regular .NET arrays (someObject[] and Array static members). I've tried to implement a generic class, but it won't compile. Didn't find any interesting assembly to reference to, so I guess we'll have to use what we got.

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.