Netduino home hardware projects downloads community

Jump to 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.
Photo

hardware interrupt


  • Please log in to reply
3 replies to this topic

#1 skywalker

skywalker

    New Member

  • Members
  • Pip
  • 4 posts

Posted 28 January 2011 - 03:35 PM

Get Error "no overload for port_OnInterrupt matches delegate 'Microsoft.Spot.Hardware.NativeEventHandler

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");

            }


        }

Edited by Chris Walker, 29 January 2011 - 06:48 PM.
moderator added [code][/code] tags


#2 Jim Davies

Jim Davies

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts
  • LocationBrighton & Hove, UK

Posted 28 January 2011 - 05:06 PM

Hi 'Sky',

You can just define your interrupt method like this:

protected void MyInterrupt(uint data1, uint data2, DateTime time)
        {
                // do stuff...

        }
and use:

port.OnInterrupt += MyInterrupt;
HTH
Jim

#3 Miha Markic

Miha Markic

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationNova Gorica, Slovenia

Posted 29 January 2011 - 11:37 AM

Get Error "no overload for port_OnInterrupt matches delegate 'Microsoft.Spot.Hardware.NativeEventHandler


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");

}


}


port_OnInterrupt should have exactly these arguments (like Jim wrote):
uint data1, uint data2, DateTime time
It doesn't matter whether you write
port.OnInterrupt += new NativeEventHandler(port_OnInterrupt);
or
port.OnInterrupt += port_OnInterrupt;
becaue they are equivalent.

Miha Markic, Microsoft MVP C#
Righthand .net consulting and software development
http://blog.rthand.com/


#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 29 January 2011 - 06:50 PM

skywalker, What does your port_OnInterrupt method look like? Do you have the three parameters in it? If you can attach the project in a zip file, we can look at it really quick to help diagnose. Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.