Hi,
I'm porting an application from Arduino's C library to NetDuino's .Net Micro Framework's C Sharp.
Is anyone able to give me a leg up on how the following Arduino sketch would look in Netduino environment?
#include <SoftwareSerial.h>
SoftwareSerial GPS = SoftwareSerial(2,3);
void setup()
{
GPS.begin(4800);
Serial.begin(115200);
}
void loop()
{
Serial.print(GPS.read(), BYTE);
}
On my Arduino, this code takes a single serial tx input from a GPS module on pin 2 at 4800 baud (I don't use the rx side on 3) and outputs is straight to the Arduino IDE console at 115200 baud, what I want to do is output the same to the Visual Studio Output window using Debug.print("Pin 2 Tx Yardy Yardy");
Any helpers out there
Hey Peeps, I solved it myself, but for fellow newbies here is the solution:
using System;
using System.IO;
using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
namespace XQuirrel
{
public class Program
{
public static void Main()
{
SerialPort serialPort = new SerialPort("COM1", 4800, Parity.None, 8, StopBits.One);
serialPort.Open();
while (true)
{
int bytesToRead = serialPort.BytesToRead;
if (bytesToRead > 0)
{
byte[] buffer = new byte[bytesToRead];
serialPort.Read(buffer, 0, buffer.Length);
Debug.Print(new String(System.Text.Encoding.UTF8.GetChars(buffer)));
}
}
}
}
Here's some example output (which is exactly what I expected ... also note that as I am indoors that the lattitude and longitude show up as V (corrupted data).
$GPGGA,221619.166,,,,,0,00,,,M,0.0,M,,0000*58
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,31,00,000,,27,00,000,*7C
$GPGSV,3,2,12,19,00,000,,07,00,000,,04,00,000,,
24,00,000,*76
$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,*78
$GPRMC,221619.166,V,,,,,,,171011,,*26
$GPGGA,221620.163,,,,,0,00,,,M,0.0,M,,0000*57
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,221620.163,V,,,,,,,171011,,*29
You can find out what it all means by Googling NMEA for the global GPS standard.
The module I used is the EM-408 GPS, which I got from CoolComponents here in the UK.
What is this Arduino Code in Netduino
Started by XQuirrel, Oct 22 2011 01:31 PM
No replies to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users