using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using System.Text; using System.IO.Ports; namespace Netduinoser { public class Program{ private static SerialPort s1; private static string s; public static void Main() { InterruptPort port = new InterruptPort(Cpu.Pin.GPIO_Pin10, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); port.OnInterrupt += new NativeEventHandler(port_OnInterrupt); s1 = new SerialPort("COM1", 115200, Parity.None,8,StopBits.One); s1.DataReceived += new SerialDataReceivedEventHandler(s1_DataReceived); s1.Open (); byte[] OutBuf=Encoding.UTF8.GetBytes("All right?\r"); byte[] InBuf=new byte[2]; byte[] temp2 = new byte[] { 0xFE, 0x01 };//clrs while(true) { s1.Write(OutBuf, 0, OutBuf.Length); Thread.Sleep(500); // s1.Write (temp2, 0, temp2.Length); // Debug.Print("OK"); } }
- Netduino Forums
- → skywalker's 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.
skywalker's Content
There have been 4 items by skywalker (Search limited from 29-March 23)
#8616 hardware interrupt
Posted by skywalker on 28 January 2011 - 03:35 PM in Netduino 2 (and Netduino 1)
Get Error "no overload for port_OnInterrupt matches delegate 'Microsoft.Spot.Hardware.NativeEventHandler
#6128 Serial datarecieved event
Posted by skywalker on 15 December 2010 - 07:17 PM in Netduino Mini
Having trouble fireing the serial datareceived event. I use com2 for programming. Then I stop debugging, Use putty
on the same port to send characters. The receive event should blink an led.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoMini;
using System.Text;
using System.IO.Ports;
namespace blink
{
public class Program
{
public static SerialPort port2 = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One);
public static OutputPort outpt=new OutputPort(Pins.GPIO_PIN_5,false);
public static void Main()
{
port2.Open();
port2.DataReceived += new SerialDataReceivedEventHandler(ReceiveData);
Thread.Sleep(Timeout.Infinite);
}
public static void ReceiveData(object sender, SerialDataReceivedEventArgs e)
{
outpt.Write(true);
Thread.Sleep(500);
outpt.Write(false);
Thread.Sleep(500);
}
}
}
#6004 ttl serial port
Posted by skywalker on 11 December 2010 - 03:10 PM in Netduino Mini
I apologize for stupidty. I am new to this.
I must be missing a reference. The project automaticaly added
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoMini;
namespace NetduinoMiniApplication1
{
public class Program
{
public static void Main()
{
// write your code here
SerialPort s1 = new SerialPort("COM1", 115200);
}
}
}
I still get an error"missing a reference". When I look at the Microsoft.spot.hardware.system.io.ports.
I dont see SerialPort, although there is a serial class listed.
#5975 ttl serial port
Posted by skywalker on 10 December 2010 - 07:14 PM in Netduino Mini
I got the chip running using rs232 port for download. I would like to use the usart for talking to a serial display at the same time.
Can this be done? I tried some netduino code. "s1=new(serialports(com1)); " but got an error.
- Netduino Forums
- → skywalker's Content
- Privacy Policy