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.

<Jeremy>'s Content

There have been 31 items by <Jeremy> (Search limited from 28-April 23)


By content type

See this member's


Sort by                Order  

#18033 Sockets

Posted by <Jeremy> on 15 September 2011 - 07:52 AM in Netduino 2 (and Netduino 1)

Hi there CoolComponents is the supplier I use - I've found they're very quick to deliver any time I've used them. Are these the components you mean? http://www.coolcompo...products_id=348 http://www.coolcompo...products_id=347 I hope this helps - they're probably best if you're based in Europe, if you're somewhere else I'm sure another person on the forum can recommend a supplier :) Cheers, Jeremy



#18015 HMC5883L Magnetometer Netduino Code

Posted by <Jeremy> on 14 September 2011 - 09:54 PM in Project Showcase

Hey everyone I just bought a HMC588CL magnetometer, and after a bit of googling I haven't found any records of existing Netduino code for getting started with it. So since I've got mine working, I've attached my code. Let me know if there's any bugs in my code, but hopefully not - you'll see that it's very simple code - the application doesn't really do anything except output the X and Y readings, but it gets you started with the device. You can use these readings to calculate your bearing from North. I hope someone out there in the community finds a use for it in a project! Cheers, Jeremy

Attached Files




#17851 Reading data chunks from a COM port question

Posted by <Jeremy> on 11 September 2011 - 11:39 AM in Netduino 2 (and Netduino 1)

Hey liqdfire and Mario Thank you so much for this help and information - I've been getting through it this weekend and think I've got a better (and more object oriented) solution to my problem with your help. Thanks again, Jeremy



#17836 Working with UART

Posted by <Jeremy> on 10 September 2011 - 06:17 PM in Visual Studio

Hi magarcan

I've been having a look at the problem you've described (since I've been working on some serial port things myself).

First, I'm assuming you've got D0 (COM1 Rx) connected to D3 (COM2 Tx), and D1 (COM1 Tx) connected to D2 (COM2 Rx) here.

Given that, if you look in the SerialPortHelper.cs class, the serialPort variable is declared as static (as are buffer and
bufferlength). I think what's happening is that since you've instantiated two separate ports in your class, you're actually sharing
resources between them. So when an event is fired to say "data has been written to COM1", the code reacts to that event
by trying to read from COM2. If you leave the serialPort variable as static, and change the serialPort_DataReceived
method to look like the code below, you'll see what i mean:

private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    // i expect these to both return the same port
    // if serial port is static, i find they're different.
    Debug.Print("serial port name = " + serialPort.PortName);
    Debug.Print("sender name = " + ((SerialPort)sender).PortName);
    lock (buffer)
    {
        if (serialPort.BytesToRead > 0)
        {
            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.");
            }
        }
    }
}

So basically I think if you use the method above, and remove the static modifier from the serialPort variable, you
should make some progress. You might want to remove static from the other two member variables too.

I guess you'll also have noticed I added a little bit to that code to check if there's at least one byte to read from serialPort.
Stepping through your program slowly in debug mode gives me different behaviour to when I just run it
without breakpoints - I found there was an exception in this method because whereas we've been notified that data has
been received, when I actually look at the serialPort.BytesToRead property I find that there's nothing there. I couldn't
work out why the event was being fired, if you have an answer I would be really interested to know!

But this looks like a great library, it's interesting to me as well.

I hope this helps - let me know how it works out.

Jeremy



#17784 Reading data chunks from a COM port question

Posted by <Jeremy> on 08 September 2011 - 10:14 PM in Netduino 2 (and Netduino 1)

Hey Stefan and Liqdfire Thank you for the assists - it sounds like the answer for me is to develop a custom solution, like you say maybe have a unique "end of packet" sequence. Liqdfire - If you do get a chance to post some code that would be really great - in the meantime, I'll spend a bit of time coding up a solution and post my code when I'm done. Hopefully this thread will help someone else out if they hit the same problem. Thanks again, Jeremy



#17758 Reading data chunks from a COM port question

Posted by <Jeremy> on 08 September 2011 - 01:58 PM in Netduino 2 (and Netduino 1)

Hi everybody I've got a question about Serial port communication using the netduino. This is the first time I've built something like this - my first week with a Netduino - but I hope this isn't a dumb question!!!. Where I've got to so far: I'm using a barebone FTDI USB to Serial mini adapter - I open COM1 at 115200, and repeatedly send a byte array (each packet being 16 bytes long) from my netduino. I also have a C# client application which reads from the com port at 115200, and successfully sees the stream of bytes that I'm sending from the netduino. So far so good. Where I'm hitting the problem: The client application isn't able to determine where my packets of 16 bytes start and end. I mean if I tell the my client app to read 16 bytes from the port, I find that it's possible it'll pick up the last 7 bytes of one packet and then the first 9 bytes of the second. I think this is probably expected behaviour. My current workaround is a bit of code that looks for a certain byte pattern in what comes in from COM1 - when it finds that, then read the next 16 bytes of data and assume it's a valid packet of my data - and I just repeat that. But do you guys know if there's a more elegant or robust solution to my problem, or if there's a protocol I should look into using to tokenise my data stream? Thanks in advance for any help! Jeremy




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.