C# Tutorial – Serial Communication | FoxLearn

39
1



Serial Communication [read serial port example] in C#. The C# Basics beginner course is a free C# Tutorial Series that helps beginning programmers learn the basics of the C# Programming Language. This is the best way to Learn C# for beginners

Visual Studio C# Serial Communication Tutorial
Serial COM Tutorial (Visual Studio C#)
Serial port & C#
How to make a Virtual Serial Port using Visual Studio C# Programming Language
Serial Port Communication with C#
VS C# Serial Com Port Instant Messaging Tutorial
[C#] – SerialPort Connection – Send/Receive through COM Ports
Simple Serial Communication with Microsoft Visual C#
c# – How to Read and Write from the Serial Port
Serial Port Communication Tutorial With C# Examples
Serial Port Programming With .NET
Serial Port Communication In C# – C# Tutorials
Communicating with Serial Port in C#
serial port c#
c# serial port
serial port communication in c#
serial port using c# codeproject
c# serial port programming
c# serial port read

Nguồn:https://wijstaanvooronzegrondrechten.org/

Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe

39 COMMENTS

  1. Im trying this example, but it shows that one error ocurred, like this:
    System.ArgumentOutOfRangeException: 'InvalidArgument=The value of '0' isn't valid for 'SelectedIndex'.

    Nombre del parámetro: SelectedIndex'
    . Help 🙁

  2. 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 BCReader
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    string[] ports = SerialPort.GetPortNames();
    cboPort.Items.AddRange(ports);
    cboPort.SelectedIndex = 0;
    btnClose.Enabled = false;
    }

    private void btnOpen_Click(object sender, EventArgs e)
    {
    btnOpen.Enabled = false;
    btnClose.Enabled = true;
    try
    {
    serialPort1.PortName = cboPort.Text;
    serialPort1.Open();
    }catch(Exception ex)
    {
    MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }

    private void btnSend_Click(object sender, EventArgs e)
    {
    try
    {
    if (serialPort1.IsOpen)
    {
    serialPort1.WriteLine(txtMessage.Text + Environment.NewLine);
    txtMessage.Clear();
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }

    private void btnClose_Click(object sender, EventArgs e)
    {
    btnOpen.Enabled = true;
    btnClose.Enabled = false;
    try
    {
    serialPort1.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }

    private void btnReceive_Click(object sender, EventArgs e)
    {
    try
    {
    if (serialPort1.IsOpen)
    {
    txtReceive.Text = serialPort1.ReadExisting();
    txtMessage.Clear();
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    }
    }

  3. hellow friend
    what type serial port use read smart card?
    and what write information code in visual studio c# to serial port for get data from reader smart card
    thanks

  4. Hi Fox! You are doing a great job, Would you share your source code with us please? My email is: vijayxrajbhar@gmail.com Thank yau

  5. sir one problem ds'nt solve please help me… an error occure when iwrite serialport1.portname…. even i include system.io.ports.

  6. I am working as a project manager, and one of my team members promised a client (who happened to be a bunch of college students), that he would integrate an RFID module into the system. This guy then quit the job suddenly without doing anything. This caused a huge problem. I had no Electronics background and had to do the project by myself in a day. This video was in fact a helping hand from heaven….

    Thank you very much….

  7. Hello, thank you for a such wonderful tutorial,
    I have a question, shall I install the device driver to communicate with instrument using c# ?

  8. Make a video record, work MODBAS Protocol
    Data transmission through serial line RS-485, RS-422, RS-232, and TCP / IP network connection.
    Many thanks. Excellent video. According to them, and learning.

LEAVE A REPLY

Please enter your comment!
Please enter your name here