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.

segu239

Member Since 05 Mar 2013
Offline Last Active Mar 05 2013 02:23 PM
-----

Posts I've Made

In Topic: First chance exception on serialport open

05 March 2013 - 10:41 AM

Hi, people Im Luis from argentina,

First I apologize for me english, in my country speek spanish.

 

I have the same problem that bryant. Can you help me ?. thanks

 

using

 

 

System;

 

using

 

 

System.Net;

 

using

 

 

System.Net.Sockets;

 

using

 

 

System.Threading;

 

using

 

 

Microsoft.SPOT;

 

using

 

 

Microsoft.SPOT.Hardware;

 

using

 

 

SecretLabs.NETMF.Hardware;

 

using

 

 

SecretLabs.NETMF.Hardware.NetduinoPlus;

 

//using Microsoft.SPOT.IO;

 

using

 

 

System.IO.Ports;// el libro esta mal antes usaba SPOT ahora usa este, pero igual hay que agregar el ...SPOT.HARDWARE.SerialPort.

 

?

 

?

 

namespace

 

 

puerto_serie_netduino

 

{

 

 

 

public class Program

 

{

 

 

 

public static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

 

 

 

static SerialPort serial1;

 

 

 

 

 

 

 

public static void Main()

 

{

 

 

 

try

 

{

 

 

 

SerialPort serial1 = new SerialPort("com2", 9600, Parity.None, 8, StopBits.One);

 

serial1.Open();

 

serial1.DataReceived +=

 

new SerialDataReceivedEventHandler(serial1_DataReceived);

 

}

 

 

 

catch (Exception ex)

 

{

 

 

 

string msg = ex.Message;

 

}

 

 

 

 

 

 

 

 

 

Thread.Sleep(Timeout.Infinite);

 

}

 

 

 

static void serial1_DataReceived(object sender, SerialDataReceivedEventArgs e)

 

{

 

 

 

byte[] buffer = new byte[3];

 

 

 

if (serial1.BytesToRead > 0)

 

{

 

led.Write(

 

true);

 

}

 

}

 

 

 

 

 

}

 

}

 

 


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.