Click here to Skip to main content
15,892,697 members
Home / Discussions / C#
   

C#

 
AnswerRe: Visual Studio Add-in 2012 Pin
Eddy Vluggen4-Oct-13 0:25
professionalEddy Vluggen4-Oct-13 0:25 
GeneralRe: Visual Studio Add-in 2012 Pin
Shankarcodebase5-Oct-13 16:28
Shankarcodebase5-Oct-13 16:28 
GeneralRe: Visual Studio Add-in 2012 Pin
Eddy Vluggen6-Oct-13 0:41
professionalEddy Vluggen6-Oct-13 0:41 
SuggestionRe: Visual Studio Add-in 2012 Pin
Richard Deeming4-Oct-13 0:48
mveRichard Deeming4-Oct-13 0:48 
GeneralRe: Visual Studio Add-in 2012 Pin
Shankarcodebase4-Oct-13 4:07
Shankarcodebase4-Oct-13 4:07 
GeneralRe: Visual Studio Add-in 2012 Pin
Richard MacCutchan4-Oct-13 4:22
mveRichard MacCutchan4-Oct-13 4:22 
GeneralRe: Visual Studio Add-in 2012 Pin
Shankarcodebase5-Oct-13 16:29
Shankarcodebase5-Oct-13 16:29 
QuestionSerial Port communication in C# Pin
alfie.max153-Oct-13 5:59
alfie.max153-Oct-13 5:59 
I am trying to start with serial port communication using C# for my project. So even though i am familiar with the C# language i am new into I/O Port communication and i seem to be having some problem with my code

C#
using System;
using System.IO.Ports;

class Program
{
	public static void Main ()
	{
		string portName = @"\\.\COM10";
		_serialPort = new SerialPort (portName);
		_serialPort.Close ();
	}
}



i am getting an error :
Error	1	The name '_serialPort' does not exist in the current context	c:\users\alfie\documents\visual studio 2012\Projects\serial\serial\Serial_port.cs



Someone pls help me get started with this. .

Also i have tested with the following code and verified that the COM10 port is working and is of type "char"

C#
class Program
{
    static void Main (string[] args)
    {
        string portName = @"\\.\COM10";
        IntPtr handle = CreateFile (portName, 0, 0, IntPtr.Zero, 3, 0x80, IntPtr.Zero);
        if(handle == (IntPtr) (-1))
        {
            Console.WriteLine ("Could not open " + portName + ": " + new Win32Exception ().Message);
            Console.ReadKey ();
            return;
        }

        FileType type = GetFileType (handle);
        Console.WriteLine ("File " + portName + " reports its type as: " + type);

        Console.ReadKey ();
    }

    [DllImport ("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern IntPtr CreateFile (string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr SecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);

    [DllImport ("kernel32.dll")]
    static extern FileType GetFileType (IntPtr hFile);

    enum FileType : uint
    {
        UNKNOWN = 0x0000,
        DISK = 0x0001,
        CHAR = 0x0002,
        PIPE = 0x0003,
        REMOTE = 0x8000,
    }
}

AnswerRe: Serial Port communication in C# Pin
Big Daddy Farang3-Oct-13 6:16
Big Daddy Farang3-Oct-13 6:16 
GeneralRe: Serial Port communication in C# Pin
alfie.max153-Oct-13 6:18
alfie.max153-Oct-13 6:18 
AnswerRe: Serial Port communication in C# Pin
OriginalGriff3-Oct-13 6:17
mveOriginalGriff3-Oct-13 6:17 
GeneralRe: Serial Port communication in C# Pin
alfie.max153-Oct-13 6:36
alfie.max153-Oct-13 6:36 
GeneralRe: Serial Port communication in C# Pin
OriginalGriff3-Oct-13 6:53
mveOriginalGriff3-Oct-13 6:53 
GeneralRe: Serial Port communication in C# Pin
alfie.max153-Oct-13 6:57
alfie.max153-Oct-13 6:57 
GeneralRe: Serial Port communication in C# Pin
OriginalGriff3-Oct-13 8:54
mveOriginalGriff3-Oct-13 8:54 
AnswerRe: Serial Port communication in C# Pin
David Knechtges3-Oct-13 9:38
David Knechtges3-Oct-13 9:38 
GeneralRe: Serial Port communication in C# Pin
OriginalGriff4-Oct-13 0:03
mveOriginalGriff4-Oct-13 0:03 
QuestionRead/write directly to a specific sector in a hard disk Pin
ptvce3-Oct-13 3:13
ptvce3-Oct-13 3:13 
AnswerRe: Read/write directly to a specific sector in a hard disk Pin
Richard MacCutchan3-Oct-13 3:27
mveRichard MacCutchan3-Oct-13 3:27 
GeneralRe: Read/write directly to a specific sector in a hard disk Pin
ptvce3-Oct-13 3:34
ptvce3-Oct-13 3:34 
GeneralRe: Read/write directly to a specific sector in a hard disk Pin
Richard MacCutchan3-Oct-13 3:37
mveRichard MacCutchan3-Oct-13 3:37 
Questionpleaase can any one help me how to resolve this Auto generated code... for first Record It Takes 1 But for second record it takes 13,14 number Pin
Likhith.S3-Oct-13 2:38
professionalLikhith.S3-Oct-13 2:38 
AnswerRe: pleaase can any one help me how to resolve this Auto generated code... for first Record It Takes 1 But for second record it takes 13,14 number Pin
Eddy Vluggen3-Oct-13 7:46
professionalEddy Vluggen3-Oct-13 7:46 
AnswerRe: pleaase can any one help me how to resolve this Auto generated code... for first Record It Takes 1 But for second record it takes 13,14 number Pin
Abhinav S3-Oct-13 17:19
Abhinav S3-Oct-13 17:19 
QuestionHow to build up a teamviewer like windows application Pin
Arun kumar Gautam3-Oct-13 0:02
Arun kumar Gautam3-Oct-13 0:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.