Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
AnswerRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Luc Pattyn16-Jul-12 10:39
sitebuilderLuc Pattyn16-Jul-12 10:39 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Big Daddy Farang16-Jul-12 10:45
Big Daddy Farang16-Jul-12 10:45 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Dave Kreskowiak16-Jul-12 10:54
mveDave Kreskowiak16-Jul-12 10:54 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
BobJanova17-Jul-12 0:12
BobJanova17-Jul-12 0:12 
Generalamd Pin
sayem_sam16-Jul-12 2:18
sayem_sam16-Jul-12 2:18 
AnswerRe: a module Pin
Wes Aday16-Jul-12 2:22
professionalWes Aday16-Jul-12 2:22 
AnswerRe: a module Pin
Luc Pattyn16-Jul-12 4:02
sitebuilderLuc Pattyn16-Jul-12 4:02 
GeneralMessage Removed Pin
16-Jul-12 4:11
professionalN_tro_P16-Jul-12 4:11 
AnswerRe: a module Pin
Luc Pattyn16-Jul-12 4:57
sitebuilderLuc Pattyn16-Jul-12 4:57 
GeneralRe: a module Pin
Wes Aday16-Jul-12 5:40
professionalWes Aday16-Jul-12 5:40 
GeneralRe: a module Pin
Pete O'Hanlon16-Jul-12 4:34
mvePete O'Hanlon16-Jul-12 4:34 
Questioncrystal report in C# using dataset and datatable Pin
rohitatcp15-Jul-12 21:07
rohitatcp15-Jul-12 21:07 
Question[SOLVED] GUI Problem - Added Forms To Tab Control Pin
AmbiguousName15-Jul-12 20:40
AmbiguousName15-Jul-12 20:40 
AnswerRe: [SOLVED] GUI Problem - Added Forms To Tab Control Pin
Obaid ur Rehman15-Jul-12 23:25
Obaid ur Rehman15-Jul-12 23:25 
AnswerRe: [SOLVED] GUI Problem - Added Forms To Tab Control Pin
AmbiguousName16-Jul-12 0:54
AmbiguousName16-Jul-12 0:54 
Generalwhat info is needed to detect a HtmlElement in WebBrowser Pin
linuor15-Jul-12 19:47
linuor15-Jul-12 19:47 
GeneralRe: what info is needed to detect a HtmlElement in WebBrowser Pin
Richard MacCutchan15-Jul-12 22:20
mveRichard MacCutchan15-Jul-12 22:20 
GeneralRe: what info is needed to detect a HtmlElement in WebBrowser Pin
linuor16-Jul-12 3:15
linuor16-Jul-12 3:15 
GeneralRe: what info is needed to detect a HtmlElement in WebBrowser Pin
Richard MacCutchan16-Jul-12 3:57
mveRichard MacCutchan16-Jul-12 3:57 
GeneralSerial Port Read Timeout Problem Pin
Richard Andrew x6415-Jul-12 18:21
professionalRichard Andrew x6415-Jul-12 18:21 
GeneralRe: Serial Port Read Timeout Problem Pin
Peter_in_278015-Jul-12 19:30
professionalPeter_in_278015-Jul-12 19:30 
GeneralRe: Serial Port Read Timeout Problem Pin
Richard Andrew x6415-Jul-12 19:55
professionalRichard Andrew x6415-Jul-12 19:55 
GeneralRe: Serial Port Read Timeout Problem Pin
SoMad15-Jul-12 20:45
professionalSoMad15-Jul-12 20:45 
GeneralRe: Serial Port Read Timeout Problem Pin
glennPattonWork315-Jul-12 22:38
professionalglennPattonWork315-Jul-12 22:38 
Umm probably preaching to the choir (i.e. you know this but...) ReadLine() is a blocking method ReadExisting() is not if you use some thing like the below code:
C#
Pause.Elapsed += new System.Timers.ElapsedEventHandler(OnTimeOutPause);
    NoDataAtPort = new System.Timers.Timer(25000);
    NoDataAtPort.Elapsed += new ElapsedEventHandler(OnTimeOut);
    myComPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(port_DataReceived);

 }

private void OnTimeOut(object sender, ElapsedEventArgs e)
{
    Reply_Status = (int)REPLY.TIMEOUT_REPLY;
}

private void OnTimeOutPause(object sender, ElapsedEventArgs e)
{
    MessageBox.Show("Something Broke!");
}

private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    Reply_Status = (int)REPLY.YES_REPLY;
    InputData = myComPort.ReadExisting();
    if (InputData != String.Empty)
    {
        this.BeginInvoke(new SetTextCallback(SetText), new object[] { InputData });
    }
}
private void SetText(string text)
{
   //
    this.rtbIncomingData.Text += text;

    if (this.rtbIncomingData.Lines.Length > 0)
    {
        lbIncomingData.Items.AddRange(rtbIncomingData.Lines);
    }


    if (text.StartsWith("S") && text.EndsWith(">"))
    {
        text = text.Substring(3, (text.Length - 6));
        txtSerialNumber.Text = text;
        rtbIncomingData.Text = "";
    }

    myComPort.DiscardInBuffer();
}

using the Reply_Status as pre-defined Enum list:
enum REPLY : int { NO_REPLY, TIMEOUT_REPLY, YES_REPLY }

is either a work around or the correct way of doing it, as I had a board that was spewing data, waiting, vomiting again at odd times (it was an RF board) much confusion
also try using a listBox as this tends to cope with odd amounts of data better.
(Jan Axelsons Serial Port Complete 2nd Edition is quite a good reference ISBN 978-1-931448-06-2)
Glenn

modified 16-Jul-12 5:13am.

QuestionStart Debugger "from running program" Pin
Tomerland15-Jul-12 9:12
Tomerland15-Jul-12 9:12 

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.