Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Writing an Application to get DSR, CD and CST pin Status of Serial Port but i am getting as false always whereas with the same device module i am able to get the things in VB but not in C#.
here is Code Snippet:

_serialPort = new SerialPort();

_serialPort.Open();

if (!_serialPort.IsOpen)
{
Console.WriteLine("Unable to open COM1, returning");
return;
}
else
{
Console.WriteLine("COM1 Opened");
_serialPort.RtsEnable = true;
}

_serialPort.PinChanged += new SerialPinChangedEventHandler(_serialPort_PinChanged);


static void _serialPort_PinChanged(object sender, SerialPinChangedEventArgs e)
{
Console.WriteLine("Pin Changed");
//throw new NotImplementedException();
}


I Have tried it manually checking in while loop as:

while (_continue)
{

try
{
if (SerialPinChange.DsrChanged.Equals(true))
{
Console.WriteLine("DSR Changed"); //Just to Check

}

if (_serialPort.DsrHolding != bDSRStatus )
{
if (_serialPort.DsrHolding)
{
Console.WriteLine("DSR UP");
bDSRStatus = _serialPort.DsrHolding;
}
else
{
Console.WriteLine("DSR Down");
bDSRStatus = _serialPort.DsrHolding;
}
}
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900