none
Winform a SeriovyPort RRS feed

  • Dotaz

  • Zdravim,

    ve winform chci, aby se mi po stisknutí tlačítka načetl řetězec, který je do pc posílán přes Seriový port. Odesíllání mi jde, ale příjem zpráv mi hází hlášku "Časový limit vypršel." Tak kdyby někoho něco napadlo, tak dejte vědět. Dík

    kod:

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.ComponentModel;

    using

     

    System.Data;

    using

     

    System.Drawing;

    using

     

    System.Linq;

    using

     

    System.Text;

    using

     

    System.Windows.Forms;

    using

     

    System.Threading;

    using

     

    System.IO.Ports;

     

     

    namespace

     

    WinForms_PrijemZrobota

    {

     

    public partial class Form1 : Form

    {

     

    static bool _continue;

     

     

    public Form1()

    {

    InitializeComponent();

     

    }

     

    private void button1_Click(object sender, EventArgs e)

    {

     

    string message;

    _continue =

    true;

     

    serialPort16.Open();

     

    while(_continue)

    {

     

    try

    {

    message = serialPort16.ReadLine();

    textBoxVystup.SelectedText = message;

     

    if (message != "")

    {

    _continue =

    false;

    }

    }

     

    catch (TimeoutException)

    {

     

    }

    }

     

    serialPort16.Close();

     

    }

    }

    }

    čtvrtek 22. dubna 2010 0:47

Odpovědi