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.

magarcan's Content

There have been 42 items by magarcan (Search limited from 08-June 23)


By content type

See this member's


Sort by                Order  

#17723 Netduino Serial Port Code Review

Posted by magarcan on 07 September 2011 - 03:38 PM in Project Showcase

I've written a code using your library, but it is not working. can anyone take a look?
using System;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Threading;
using Microsoft.SPOT;
using System.IO.Ports;

namespace SerialPortLearn
{
    public class Program
    {
        static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
        
        static SerialPortHelper serialPortHelper1 = new SerialPortHelper();
        static SerialPortHelper serialPortHelper2 = new SerialPortHelper(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);

        public static void Main()
        {
            while (true)
            {
                string line = serialPortHelper2.ReadLine();
                if (line.Length > 0)
                {
                    led.Write(true);
                    serialPortHelper1.PrintLine("Leido: " + line);
                    Debug.Print("Leido: " + line);
                }
            }
        }
    }
}
I'm able to write in UART, but reading method is not working.
Any idea? Thanks!!



#18984 Netduino Plus Firmware v4.2.0 RC1

Posted by magarcan on 10 October 2011 - 07:24 AM in Beta Firmware and Drivers

Not much, I actually ended up taking regex out because the referenced assemblies were 30k just but themselves

I think this is the big problem with Netduino. If you test the sample codes, for example all code in Getting Started with the Internet of Things, but when you begin making some bigger you will realise that you can't flash your firmware because it is bigger than the amount flash available.



#19005 Netduino Plus Firmware v4.2.0 RC1

Posted by magarcan on 10 October 2011 - 04:47 PM in Beta Firmware and Drivers

I've been developing with Atmel uC for some years, and I had never found this problem. I can tell you that I've developed some big projects, but always using C. My favourite micro use to be AtMega32.



#18761 Netduino Plus Firmware v4.2.0 RC1

Posted by magarcan on 04 October 2011 - 11:22 AM in Beta Firmware and Drivers

How many free ROM is this firmware going to leave for us??? Actually we only have 64KB.



#17915 Byte array to Hexadecimal String

Posted by magarcan on 13 September 2011 - 09:14 AM in General Discussion

I'm receiving via UART some data that are saved into a byte array, the problem is that I want to print this data using Debug.Print one of the ways I've thought is converting this to an Hexadecimal string, but Micro Framework does not support BitConverter.ToString.

Any idea? Thanks!!



#18758 MetaDataProcessor.exe WINE notes

Posted by magarcan on 04 October 2011 - 11:13 AM in Mono

I tried with 3 different libraries and no one is working for me:
jae@newton:~/Desktop/netmfbins$ wine MetaDataProcessor.exe -loadHints mscorlib mscorlib.dll -parse MicroHTTP.dll -minimize -endian le -compile cosa.pe
fixme:heap:HeapSetInformation (nil) 1 (nil) 0
Cannot open 'MicroHTTP.dll'!
MMP: error MMP0000: 0x80070002
jae@newton:~/Desktop/netmfbins$ wine MetaDataProcessor.exe -loadHints mscorlib mscorlib.dll -parse MicroIO.dll -minimize -endian le -compile cosa.pe
fixme:heap:HeapSetInformation (nil) 1 (nil) 0
MMP: error MMP0000: Cannot locate file for assembly 'System.IO'

MMP: error MMP0000: CLR_E_ENTRY_NOT_FOUND
jae@newton:~/Desktop/netmfbins$ wine MetaDataProcessor.exe -loadHints mscorlib mscorlib.dll -parse MicroXBee.dll -minimize -endian le -compile cosa.pe
fixme:heap:HeapSetInformation (nil) 1 (nil) 0
Cannot open 'MicroXBee.dll'!
MMP: error MMP0000: 0x80070002
I think I've installed everything properly.



#18713 Netduino Plus update: 50% more RAM

Posted by magarcan on 03 October 2011 - 02:18 PM in Beta Firmware and Drivers

Is this going to be available in 4.2 final?



#17760 Working with UART

Posted by magarcan on 08 September 2011 - 02:27 PM in Visual Studio

I've a problem working with UART. I'm using SerialPortHelper library. But I can only write, not to write anything.

WTF! This happens when you have not asleep enough, sorry. I want to mean, that I'm able to write in UART (this part of code is working well), but I can't read from there.
I've neither written well the code. This is the real code I'm using:
using System;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Threading;
using Microsoft.SPOT;

namespace SerialPortLearn
{
    public class Program
    {
        static SerialPortHelper serialPortHelper1 = new SerialPortHelper();

        public static void Main()
        {
            serialPortHelper1.PrintLine("Initializing...");
            while (true)
            {
                string line = serialPortHelper1.ReadLine();
                if (line.Length > 0)
                    serialPortHelper1.PrintLine("Readed: " + line);
            }
        }
    }
}
Thanks!!



#17801 Working with UART

Posted by magarcan on 09 September 2011 - 09:22 AM in Visual Studio

Finally I've modified ReadLine() method and now it's working, but I'm still having a problem. I've defined two different objects (one for each port) but there is something that is not working.
using System;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Threading;
using Microsoft.SPOT;
using System.IO.Ports;

namespace SerialPortLearn
{
    public class Program
    {
        static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
        
        /*Defaults to: SerialPorts.COM1 (uses D0 and D1), 9600, Parity.None, 8, StopBits.One*/
        static SerialPortHelper serialPortHelper1 = new SerialPortHelper(SerialPorts.COM1, 9600, Parity.None, 8,StopBits.One);
        static SerialPortHelper serialPortHelper2 = new SerialPortHelper(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);

        public static void Main()
        {
            serialPortHelper1.PrintLine("Starting!");
            while (true)
            {
                string line = serialPortHelper2.ReadLine();
                if (line.Length > 0)
                {
                    led.Write(true);
                    Thread.Sleep(500);
                    serialPortHelper1.PrintLine("Read: " + line);
                    led.Write(false);
                }
            }
        }
    }
}
The problem is that response, serialPortHelper1.PrintLine("Read: " + line);, is sent to port 2 instead of port 1. I think, maybe it's needed to modify constructor in order to work with both ports at simultaneously.



#17749 Working with UART

Posted by magarcan on 08 September 2011 - 11:27 AM in Visual Studio

I've a problem working with UART. I'm using SerialPortHelper library. But I can only write, not to write anything.

Here is my code:
using System;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Threading;
using Microsoft.SPOT;

namespace SerialPortLearn
{
    public class Program
    {
        static SerialPortHelper serialPortHelper1 = new SerialPortHelper();

        public static void Main()
        {
            serialPortHelper1.PrintLine("Initializing...");
            while (true)
            {
                if (line.Length > 0)
                    serialPortHelper1.PrintLine("Readed: " + line);
            }
        }
    }
}

Can anyone help me?? Thanks!!!

Here is the library's code:
using System;
using System.IO.Ports;
using System.Text;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Threading;

namespace SerialPortLearn
{
    public class SerialPortHelper
    {
        static SerialPort serialPort;

        const int bufferMax = 1024;
        static byte[] buffer = new Byte[bufferMax];
        static int bufferLength = 0;

        public SerialPortHelper(string portName = SerialPorts.COM1, int baudRate = 9600, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One)
        {
            serialPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
            serialPort.ReadTimeout = 10; // Set to 10ms. Default is -1?!
            serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
            serialPort.Open();
        }

        private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            lock (buffer)
            {
                int bytesReceived = serialPort.Read(buffer, bufferLength, bufferMax - bufferLength);
                if (bytesReceived > 0)
                {
                    bufferLength += bytesReceived;
                    if (bufferLength >= bufferMax)
                        throw new ApplicationException("Buffer Overflow.  Send shorter lines, or increase lineBufferMax.");
                }
            }

        }

        public string ReadLine()
        {
            string line = "";

            lock (buffer)
            {
                //-- Look for Return char in buffer --
                for (int i = 0; i < bufferLength; i++)
                {
                    //-- Consider EITHER CR or LF as end of line, so if both were received it would register as an extra blank line. --
                    if (buffer[i] == '\r' || buffer[i] == '\n')
                    {
                        buffer[i] = 0; // Turn NewLine into string terminator
                        line = "" + new string(Encoding.UTF8.GetChars(buffer)); // The "" ensures that if we end up copying zero characters, we'd end up with blank string instead of null string.
                        //Debug.Print("LINE: <" + line + ">");
                        bufferLength = bufferLength - i - 1;
                        Array.Copy(buffer, i + 1, buffer, 0, bufferLength); // Shift everything past NewLine to beginning of buffer
                        break;
                    }
                }
            }

            return line;
        }

        public void Print( string line )
        {
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            byte[] bytesToSend = encoder.GetBytes(line);
            serialPort.Write(bytesToSend, 0, bytesToSend.Length);
        }

        public void PrintLine(string line)
        {
            Print(line + "\r");
        }

        public void PrintClear()
        {
            byte[] bytesToSend = new byte[2];
            bytesToSend[0] = 254;
            bytesToSend[1] = 1;
            serialPort.Write(bytesToSend, 0, 2);
            Thread.Sleep(500); // LCD is slow, pause for 500ms before sending more chars
        }
    }
}



#18744 How big is my program

Posted by magarcan on 04 October 2011 - 07:55 AM in General Discussion

What are the errors?

Most of them are "namespace doesn't exist or can't be found..." (this doesn't happen if I select Debug).



#18746 How big is my program

Posted by magarcan on 04 October 2011 - 08:06 AM in General Discussion

After adding (again) the references, and build the solution...
Deploying assemblies for a total size of 120600 bytes
Error	1	An error has occurred.  Please check your hardware

Any other idea???



#18755 How big is my program

Posted by magarcan on 04 October 2011 - 10:50 AM in General Discussion

Error   1       An error has occurred.  Please check your hardware
I've read that this error is showed when you try to write a bigger assembly than allowed...

It's about 117KB when maximum allowed is 64KB.



#18741 How big is my program

Posted by magarcan on 04 October 2011 - 07:35 AM in General Discussion

Well, almost - you'd need to change the active configuration in the combobox in the toolbar from "Debug" to "Release".

The project settings tab you've shown allows you to specify various configuration options, independent of what is selected as active (in the combobox). After you select "Release" in the combobox, you will be actually building it, and you will have "Configuracion: Active (Release)" in the tab (now you have "Active (Debug)").

Edit: Attached picture.

I think this is almost configured, but now I'm having some troubles:
Posted Image

Do you know why is this happening???



#18748 How big is my program

Posted by magarcan on 04 October 2011 - 08:14 AM in General Discussion

TinyCLR (Build 4.1.2821.0)


Starting...

Found debugger!

Create TS.

 Loading start at 14d324, end 162e8c

Attaching file.

Assembly: mscorlib (4.1.2821.0) (3880 RAM - 33236 ROM - 19134 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.Native (4.1.2821.0) (1144 RAM - 6516 ROM - 4479 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.Hardware (4.1.2821.0) (1752 RAM - 11440 ROM - 7371 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.Net (4.1.2821.0) (704 RAM - 5060 ROM - 2452 METADATA)


Attaching file.

Assembly: System (4.1.2821.0) (872 RAM - 5992 ROM - 3206 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.IO (4.1.2821.0) (740 RAM - 4620 ROM - 2522 METADATA)


Attaching file.

Assembly: System.IO (4.1.2821.0) (1548 RAM - 13292 ROM - 5862 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.Hardware.SerialPort (4.1.2821.0) (512 RAM - 3488 ROM - 1543 METADATA)


Attaching file.

Assembly: Microsoft.SPOT.Hardware.Usb (4.1.2821.0) (580 RAM - 3740 ROM - 1844 METADATA)


Attaching file.

Assembly: SecretLabs.NETMF.Hardware (4.1.0.0) (256 RAM - 1108 ROM - 491 METADATA)


Attaching file.

Assembly: SecretLabs.NETMF.Diagnostics (4.1.0.0) (180 RAM - 440 ROM - 166 METADATA)


Loading Deployment Assemblies.

Attaching deployed file.

Assembly: SecretLabs.NETMF.Hardware.Netduino (4.1.0.0) (268 RAM - 796 ROM - 423 METADATA)


Attaching deployed file.

Assembly: MonoNetduinoApp (1.0.0.0) (196 RAM - 384 ROM - 175 METADATA)


Resolving.


Total: (10952 RAM - 90112 ROM - 49668 METADATA)



Total: (10952 RAM - 90112 ROM - 49668 METADATA)


The debugging target runtime is loading the application assemblies and starting execution.
Ready.
I'm working with Micro Framework 4.1 (computer and netduino+'s firmware).



#18714 How big is my program

Posted by magarcan on 03 October 2011 - 02:20 PM in General Discussion

In addition to what CW2 said, you can try the firmware in http://forums.netdui...te-50-more-ram/ to see if that suffices for you.

May main problem is the free ROM space. Having more RAM only be useful if I load assemblies dynamically from an SD card...



#18721 How big is my program

Posted by magarcan on 03 October 2011 - 05:03 PM in General Discussion

You are talking about this, doesn't it?
Posted Image

I've tried with Release, Debug and Debug (Active) and I'm always having the same problem. I've also chosen "Optimize code" inside "Generate".



#18709 How big is my program

Posted by magarcan on 03 October 2011 - 12:00 PM in General Discussion

Checked. My program is around 96KB, but if it is bigger than 64KB compiler gives an error.

What exactly means this???

● Code Storage: 64 KB
without networking: 128 KB


Are there any way to prevent using network and having all 128KB for my program???

Thanks!!!



#18705 How big is my program

Posted by magarcan on 03 October 2011 - 10:40 AM in General Discussion

Hi! I'm having some issues and I think they are related with deployment size. How can I see how big is my program and who is using my free bytes?

I'm using lots of references, are there any way to see how big is each one??

After compiling I can see something like this:
Deploying assemblies for a total size of 1080 bytes

Assembly: mscorlib (4.1.2821.0) (3880 RAM - 33236 ROM - 19134 METADATA)
Assembly: Microsoft.SPOT.Native (4.1.2821.0) (1144 RAM - 6516 ROM - 4479 METADATA)
Assembly: Microsoft.SPOT.Hardware (4.1.2821.0) (1752 RAM - 11440 ROM - 7371 METADATA)
Assembly: Microsoft.SPOT.Net (4.1.2821.0) (704 RAM - 5060 ROM - 2452 METADATA)
Assembly: System (4.1.2821.0) (872 RAM - 5992 ROM - 3206 METADATA)
Assembly: Microsoft.SPOT.IO (4.1.2821.0) (740 RAM - 4620 ROM - 2522 METADATA)
Assembly: System.IO (4.1.2821.0) (1548 RAM - 13292 ROM - 5862 METADATA)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.1.2821.0) (512 RAM - 3488 ROM - 1543 METADATA)
Assembly: Microsoft.SPOT.Hardware.Usb (4.1.2821.0) (580 RAM - 3740 ROM - 1844 METADATA)
Assembly: SecretLabs.NETMF.Hardware (4.1.0.0) (256 RAM - 1108 ROM - 491 METADATA)
Assembly: SecretLabs.NETMF.Diagnostics (4.1.0.0) (180 RAM - 440 ROM - 166 METADATA)
Assembly: NetduinoPlusApplication1 (1.0.0.0) (164 RAM - 264 ROM - 90 METADATA)
Assembly: SecretLabs.NETMF.Hardware.NetduinoPlus (4.1.0.0) (268 RAM - 816 ROM - 423 METADATA)

Total: (10920 RAM - 90012 ROM - 49583 METADATA)
What does RAM and METADATA mean?? What is the ROM amount available in my Netduino Plus?? I seen in specifications it is 64 KB and 128KB without networking. What does it mean?

Thanks!!!



#18716 How big is my program

Posted by magarcan on 03 October 2011 - 04:13 PM in General Discussion

Are there any firmware that gives developer higher RAM amount?? I need networking, but after shrink my code it still is too big. Any idea??



#18718 How big is my program

Posted by magarcan on 03 October 2011 - 04:36 PM in General Discussion

Are you using a debug build or a release build?

I don´t really know. How can I see this??



#18435 .NET Micro Framework 4.2 RC2 released

Posted by magarcan on 26 September 2011 - 03:46 PM in General Discussion

Has new firmware finally released??



#18438 .NET Micro Framework 4.2 RC2 released

Posted by magarcan on 26 September 2011 - 04:53 PM in General Discussion

Hi magarcan,

We're waiting for the final .NET MF 4.2 release. It's supposed to be two weeks behind the RC2 release...will probably be out within a week or so. Then we'll build a series of new firmware releases based on "gold" code.

Chris

Ok, so we will be waiting for this. But... what have we to do in order to update firmware?



#18692 .NET Micro Framework 4.2 RC2 released

Posted by magarcan on 03 October 2011 - 07:22 AM in General Discussion

Any updates?? We can't wait for it :lol:



#18463 .NET Micro Framework 4.2 RC2 released

Posted by magarcan on 27 September 2011 - 07:15 AM in General Discussion

When it's done and all downloads are provided:

- Re-install both SDK's (Microsoft's and Netduino's)
- Flash your tinybootloader (http://wiki.netduino...ep-by-step.ashx)
- Install new firmware (http://wiki.netduino...ep-by-step.ashx)

Thanks!! Now, we only have to wait firmware and new NETMF to be released.




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.