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.
Photo

Serial communication with FTDI Breakout Reloaded V1.1


  • Please log in to reply
27 replies to this topic

#21 inxtremo

inxtremo

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 15 February 2012 - 10:34 AM

:huh: :angry: It was the code. :angry: Now all is working fine here. I try to find the wrong stuff in my code. If i find something i will post it here as help for others. @dave & @hanzibal Many many thanks for your awesome help. I learned much. :) Best regards, Daniel

#22 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 15 February 2012 - 01:02 PM

The one I purchased from SparkFun worked great and I've read about many people using it. I think they are in the USA but maybe you can find another distributor closer. Glad to hear you made some discoveries and some progress.

#23 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 15 February 2012 - 01:04 PM

That's really weird since it would mean that the FTDI board is ok too. It would be interesting to know what happens if you keep the exact same setup as when bridging both the N+ and the FTDI board, but instead of actually bridging both ends, you go back to basics and tie rx-tx, tx-rx and gnd-gnd. Remeber the N+ has two different UARTs, one on pins 0-1 and the other on pins 2-3. Have you tried/tested both of them? EDIT: Sorry, delayed post - Glad it works for you now!

#24 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 28 March 2012 - 10:21 PM

A little off topic but... the following line of code was posted in the example... string line = System.Text.Encoding.UTF8.GetString(bytes); This method does not exist under NMF 4.2. Did they pull it?

#25 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 29 March 2012 - 10:32 AM

string line = System.Text.Encoding.UTF8.GetString(bytes);
This method does not exist under NMF 4.2. Did they pull it?

I'm using it in my 4.2 project, so no it's not been pulled as far as I can tell.

Did you set the target framework in Project Properties (Application tab)?

#26 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 29 March 2012 - 10:59 AM

Maybe you forgot to add references to certain assemblies? I don't know if there is a System.Text assembly but there might be and if so, it's probably required for the stuff you're trying to do.

#27 inxtremo

inxtremo

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 29 March 2012 - 11:24 AM

A little off topic but...

the following line of code was posted in the example...

string line = System.Text.Encoding.UTF8.GetString(bytes);

This method does not exist under NMF 4.2. Did they pull it?


Hey,

as far as i know the GetString method does not exist in .NET MF. Try instead the GetChars method.

The sample you seen does not run on the Netduino. It is a class who sends the message to the Netduino. The class works with the full .NET 4 Framework.

Here is a code example how i do it.

private static void serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            // wait a bit for filling the buffer
            System.Threading.Thread.Sleep(100);

            // message string
            string msg = null;

            // allocate a byte array
            byte[] bytes = new byte[_serial.BytesToRead];

            // read bytes
            _serial.Read(bytes, 0, bytes.Length);

            // send bytes back for error checking
            _serial.Write(bytes, 0, bytes.Length);

            // encode bytes to a string message 
            msg = new string(System.Text.Encoding.UTF8.GetChars(bytes));

            // split message
            if (msg != null)
            {
                // split parameter
                splittedMsg = msg.Split(',');

                // allocate array for the parameters
                int[] param = new int[splittedMsg.Length];

                // write parameter to the array
                for (int i = 0; i < splittedMsg.Length; i++)
                {
                    param[i] = System.Int32.Parse(splittedMsg[i]);
                }

                // do something
                switch (param[0])
                {
                    case 0:
                       blaaa ....
                       break;
                    default:
                        break;
                }
            }
        }

Best regards,
Daniel

#28 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 29 March 2012 - 12:52 PM


string line = System.Text.Encoding.UTF8.GetString(bytes);

This method does not exist under NMF 4.2. Did they pull it?

I'm using it in my 4.2 project, so no it's not been pulled as far as I can tell.

My mistake, sorry. I'm using GetBytes()




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.