Error 1 0x80131700 C:\Documents and Settings\Administrator\my documents\visual studio 2010\Projects\NetduinoApplication1\NetduinoApplication1\MMP NetduinoApplication1
I'm a total newb to C# and visual studio so maybe I'm doing something stupid but I don't know what the issue is. My code is:
using System; using System.IO.Ports; using System.Text; // UTF Encoding using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoApplication1 { public class Program { static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); //instantiate the serial port connection static SerialPort MyserialPort = new SerialPort("COM1",19200); public static void Main() { MyserialPort.Open(); if (MyserialPort.IsOpen) { Debug.Print("Serial Port is open."); } InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); button.OnInterrupt += new NativeEventHandler(button_OnInterrupt); Thread.Sleep(Timeout.Infinite); } static void button_OnInterrupt(uint data1, uint data2, DateTime time) { // Set the led led.Write(data2 == 0); // Encode to UTF8 UTF8Encoding enc = new UTF8Encoding(); // Encode Byte array string tempString = "Button Press"; byte[] tempData = enc.GetBytes(tempString); // Write to Serial Port int bytesWritten = MyserialPort.Write(tempData, 0, tempData.Length); Debug.Print("Bytes Written" + bytesWritten.ToString()); } } }
I did look at the document on adding the reference to Microsoft.SPOT.Hardware.SerialPort and I think I did it correctly. Do I need to add a Using statement for Microsoft.SPOT.Hardware.SerialPort as well? I tried it and it didn't like it so I left it out
Oh and I boosted the code from someone else on here so if it was you don't get mad
Thanks