Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length



Pages: [1]
  Print  
Author Topic: SerialPort  (Read 153 times)
John_April
Newbie
*
Posts: 29


View Profile
« on: April 19, 2010, 04:22:58 AM »

Hello,

I'm trying to use the serial port of Embedded Master, and for this, I took an example from :
http://www.tinyclr.com/downloads/Beginners%20guide%20to%20NETMF.pdf ,page 76/144

My code is the following one

Code:
using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using System.IO.Ports;

namespace SerialPort
{
    public class SerialPort
    {
        public static void Main()
        {
            SerialPort UART = new SerialPort("COM1", 115200);
            int counter=0;
            UART.Open();
            while (true)
            {
                // create a string
                string counter_string = "Count: " + counter.ToString() + "\r\n";
                // convert the string to bytes
                byte[] buffer = Encoding.UTF8.GetBytes(counter_string);
                // send the bytes on the serial port
                UART.Write(buffer, 0, buffer.Length);
                // increment the counter;
                counter++;
                //wait...
                Thread.Sleep(100);
            }
        }
    }
}

You can see my references in the picture that I had (References) and there is a picture of my code too (Code). As the picture shows it, I have a problem with the creation of a new object in relation with "SerialPort", but I don't understand why... If someone can light me please ?

Thanks, John.
Logged
John_April
Newbie
*
Posts: 29


View Profile
« Reply #1 on: April 19, 2010, 04:43:37 AM »

Hello,

I found my problem and it's a real stupid thing of my own :
I made an other class with the "SerialPort" name so there was a confusion.

Thanks, John.
Logged
Pages: [1]
  Print  
 
Jump to: