Click here to Skip to main content
15,917,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generate Word Report fails with System.Runtime.InteropServices.COMException (0x800A1066): Command Failed Pin
tschueggi10-Nov-10 4:42
tschueggi10-Nov-10 4:42 
GeneralRe: Generate Word Report fails with System.Runtime.InteropServices.COMException (0x800A1066): Command Failed Pin
_Erik_10-Nov-10 7:12
_Erik_10-Nov-10 7:12 
QuestionHelp with serial data display Pin
turbosupramk39-Nov-10 1:58
turbosupramk39-Nov-10 1:58 
AnswerRe: Help with serial data display Pin
OriginalGriff9-Nov-10 2:17
mveOriginalGriff9-Nov-10 2:17 
GeneralRe: Help with serial data display Pin
turbosupramk39-Nov-10 2:26
turbosupramk39-Nov-10 2:26 
GeneralRe: Help with serial data display Pin
OriginalGriff9-Nov-10 4:21
mveOriginalGriff9-Nov-10 4:21 
GeneralRe: Help with serial data display Pin
turbosupramk39-Nov-10 6:38
turbosupramk39-Nov-10 6:38 
GeneralRe: Help with serial data display Pin
OriginalGriff9-Nov-10 8:21
mveOriginalGriff9-Nov-10 8:21 
GeneralRe: Help with serial data display Pin
ColinBurnell9-Nov-10 21:41
professionalColinBurnell9-Nov-10 21:41 
GeneralRe: Help with serial data display Pin
turbosupramk310-Nov-10 2:23
turbosupramk310-Nov-10 2:23 
GeneralRe: Help with serial data display Pin
ColinBurnell10-Nov-10 21:20
professionalColinBurnell10-Nov-10 21:20 
AnswerRe: Help with serial data display Pin
Luc Pattyn9-Nov-10 7:26
sitebuilderLuc Pattyn9-Nov-10 7:26 
GeneralRe: Help with serial data display Pin
turbosupramk39-Nov-10 7:42
turbosupramk39-Nov-10 7:42 
AnswerRe: Help with serial data display Pin
Luc Pattyn9-Nov-10 7:50
sitebuilderLuc Pattyn9-Nov-10 7:50 
GeneralRe: Help with serial data display Pin
turbosupramk39-Nov-10 10:31
turbosupramk39-Nov-10 10:31 
GeneralRe: Help with serial data display Pin
Luc Pattyn9-Nov-10 10:52
sitebuilderLuc Pattyn9-Nov-10 10:52 
GeneralRe: Help with serial data display Pin
turbosupramk39-Nov-10 16:24
turbosupramk39-Nov-10 16:24 
GeneralRe: Help with serial data display Pin
Luc Pattyn9-Nov-10 16:48
sitebuilderLuc Pattyn9-Nov-10 16:48 
GeneralRe: Help with serial data display Pin
turbosupramk310-Nov-10 3:03
turbosupramk310-Nov-10 3:03 
GeneralRe: Help with serial data display Pin
NedPat10-Nov-10 19:38
NedPat10-Nov-10 19:38 
GeneralRe: Help with serial data display Pin
ShafiqA11-Nov-10 18:29
ShafiqA11-Nov-10 18:29 
GeneralRe: Help with serial data display Pin
Adam Yonce10-Nov-10 2:50
Adam Yonce10-Nov-10 2:50 
I have had luck writing serial data from a PIC microcontroller to a textbox using the following code in C#:
private void serialPort1_DataReceived_1(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{    
    txtToDisplay = serialPort1.ReadExisting();
    DisplayText();
}
        
public void DisplayText()
{
    if (txtIn.InvokeRequired)
    {
       this.BeginInvoke(new MethodInvoker(DisplayText));
    }
    else
    {
        txtIn.AppendText(txtToDisplay);
    }
}


Also, I set the comm port parameters in the same place I open the port, rather than the receive event:

private void GetComPorts() //populate the comm port list with the available system ports
{
    foreach (string s in SerialPort.GetPortNames() )
    {
        lbPort.Items.Add(s);
    }
}

private void btnOpen_Click(object sender, EventArgs e)
{

     this.lbPort.SelectedIndex = this.lbPort.TopIndex;          // which port?
     this.lbRate.SelectedIndex = this.lbRate.TopIndex;          // baud rate?
     this.lbProtocol.SelectedIndex = this.lbProtocol.TopIndex;  // N,8,1 or N,7,1 (strings in a collection)

     string crlf = Environment.NewLine;                         // this might be the real trick...

     serialPort1.BaudRate = Int32.Parse(lbRate.Text);
     serialPort1.PortName = lbPort.Text;

     serialPort1.Open();

     if (serialPort1.IsOpen)
     {
        btnOpen.Enabled = false;
        btnClose.Enabled = true;

        txtIn.AppendText(string.Format("Port {0} opened successfully." + crlf, serialPort1.PortName));
                
     }
}


Anyway, this seems to work in my situation. Also, my PIC code is using "\r\n" so I am actually sending a {10} and a {13} pair.

Hope this helps,
Adam
GeneralRe: Help with serial data display Pin
turbosupramk310-Nov-10 3:05
turbosupramk310-Nov-10 3:05 
NewsRe: Help with serial data display Pin
turbosupramk310-Nov-10 14:41
turbosupramk310-Nov-10 14:41 
AnswerRe: Help with serial data display Pin
davidwz9-Nov-10 19:04
davidwz9-Nov-10 19:04 

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.