Serial communication with FTDI Breakout Reloaded V1.1
Started by inxtremo, Feb 10 2012 05:31 PM
27 replies to this topic
#21
Posted 15 February 2012 - 10:34 AM
It was the code. 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
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
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
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
Posted 29 March 2012 - 10:32 AM
I'm using it in my 4.2 project, so no it's not been pulled as far as I can tell.
string line = System.Text.Encoding.UTF8.GetString(bytes);This method does not exist under NMF 4.2. Did they pull it?
Did you set the target framework in Project Properties (Application tab)?
#26
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
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
Posted 29 March 2012 - 12:52 PM
My mistake, sorry. I'm using GetBytes()
I'm using it in my 4.2 project, so no it's not been pulled as far as I can tell.
string line = System.Text.Encoding.UTF8.GetString(bytes);
This method does not exist under NMF 4.2. Did they pull it?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users