NetduinoGo - PC Serial Communication
#1
Posted 18 May 2012 - 09:41 AM
#2
Posted 18 May 2012 - 10:14 PM
#3
Posted 19 May 2012 - 05:55 AM
In the meantime, I use the Sytech USB Serial Gadgeteer Module with mine. It takes up a whole channel (4 sockets), but it works great. I then open either COM1 (sockets 1-4) or COM2 (sockets 5-8) from my Netduino Go app...and can chat back and forth to the PC.
You could also break out the socket with an FTDI chip, cables, etc.
Chris
#4
Posted 20 May 2012 - 03:31 PM
#5
Posted 20 May 2012 - 05:45 PM
I used this board : FOCA Board v2.1
Connections
NetduinoGo gobus (Socket#1) pin 4 (Rx) to FOCA Board Tx
NetduinoGo gobus (Socket#1) pin 5 (Tx) to FOCA Board Rx
NetduinoGo gobus (Socket#1) pin 10 (Grd) to FOCA Board Grd
Here is the code :
Imports System.IO.Ports Imports Microsoft.SPOT Imports Microsoft.SPOT.Hardware Imports SecretLabs.NETMF.Hardware Imports SecretLabs.NETMF.Hardware.NetduinoGo Imports System.Text Imports Microsoft.VisualBasic.Constants Module Module1 Dim IncomingText As String = "" Dim reading As Boolean = False Dim count As Integer Dim readLength As Integer Dim InTray As Byte() Public WithEvents SerialPort As New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One) Sub Main() SerialPort.Open() AddHandler SerialPort.DataReceived, New SerialDataReceivedEventHandler(AddressOf serialPort_Datareceived) AddHandler SerialPort.ErrorReceived, New SerialErrorReceivedEventHandler(AddressOf serialPort_ErrorReceived) Thread.Sleep(Timeout.Infinite) End Sub Sub serialPort_ErrorReceived(ByVal sender As Object, ByVal e As SerialErrorReceivedEventArgs) Debug.Print(e.ToString) End Sub Sub serialPort_Datareceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) 'Debug.Print("Data Received") 'Incoming Bytes Dim IncomingBytes As Integer = SerialPort.BytesToRead ' Create a new temporary store Dim DataStore(IncomingBytes) As Byte 'Read in the bytes SerialPort.Read(DataStore, 0, IncomingBytes) 'Convert Bytes to String IncomingText = System.Text.Encoding.UTF8.GetChars(DataStore) 'Check for CarrageReturn and trim If IncomingText.IndexOf(vbCrLf) > 0 Then IncomingText = IncomingText.Trim Debug.Print(IncomingText & " Len: " & IncomingText.Length) IncomingText = "" Else Debug.Print(IncomingText & " Len: " & IncomingText.Length) End If 'Send Data back 'SerialPort.Write(Encoding.UTF8.GetBytes(strDataStore), 0, strDataStore.Length) 'Do something with the data CheckRecievedData(IncomingText) End Sub 'Do something with the data Sub CheckRecievedData(ByVal strData As String) Select Case strData Case "" Case "ON" Case "OFF" End Select End Sub End Module
I will post the code of the Windows Application which accepts and send data from/to NetduinoGo probably tomorrow.
I hope that somebody will find it usefull.
- Gutworks likes this
#6
Posted 22 May 2012 - 06:48 PM
#7
Posted 17 July 2012 - 08:59 AM
Thank you for posting this, Phillip. It was a huge help.I would like to share my experience so far.
<snip>
I hope that somebody will find it usefull.
#8
Posted 12 February 2013 - 10:08 PM
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;font-size:12px;font-weight:bold;]PhillipMorris, thanks for your explanation. I believe I followed it but am unable to achieve IO. Here's my current setup:[/color]
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;font-size:12px;font-weight:bold;]- Foca v2.2[/color]
- Netduino Go and shield base
Connections
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin 0 (Rx) to FOCA Board Txd[/color]
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin 1 (Tx) to FOCA Board Rxd[/color]
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin GND or 14 (Grd) to FOCA Board Grd[/color]
using System;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.NetduinoGo;using System.IO.Ports;using System.Text;namespace _4._2{ public class Program { public static void Main() { //NetduinoGo.ShieldBase sb = new NetduinoGo.ShieldBase(GoSockets.Socket1); SerialPort p = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One); p.ReadTimeout = 10; p.DataReceived += new SerialDataReceivedEventHandler(p_DataReceived); p.ErrorReceived += new SerialErrorReceivedEventHandler(p_ErrorReceived); p.Open(); while (true) { p.WriteByte(40); p.Write(Encoding.UTF8.GetBytes("test"), 0, 4); Thread.Sleep(100); } } static void p_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { throw new NotImplementedException(); } static void p_DataReceived(object sender, SerialDataReceivedEventArgs e) { throw new NotImplementedException(); } }}
The foca module has rx and tx micro led lights signalling data flow. Tx lights up when I send data to device from pc. The netduino is unable to capture any inbound data nor send outbound data. I tried every permutation of netduino pins 0 - 5, 10 and standard gnd to the foca rx/tx/gnd pins. I'm not sure how Phillip arrived at using pins 4,5 and 10 vs 0,1 and gnd. Hari uses pins 0 and 1 though he's using a standard netduino.
Any thoughts welcome.
#9
Posted 18 February 2013 - 12:00 AM
Wanted to report I solved my own problem. Being a newb, I interpreted pins 4,5 and 10 as the same as the shield base pins when in actuality, PhillipMorris was referring to the raw GoBus socket 1 bus of 10 pins. I wasn't aware people were "hacking" the sockets to achieve serial IO. Also, Chris released new firmware for the shield-base which let me use the digital io pins as intended. Together with this update and the handy pin-out picture illustrated by Gutworks, I've successfully communicated between PC and MCU in both directions using the Foca v2.2. Very excited to move forward thanks to the community. Cheers
- Arron Chapman likes this
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users