Visual Studio C# Serial Communication (Serial Port) tutorial 1.Send Data (1/6)

20
1



This is a continuance tutorial video about Visual C# serial communication. This is very useful when you want to interface your PC to external devices. This continuance tutorial video, talk about how to create your own Serial Terminal.

This first video explain how to add several serial parameters such as COM PORT name, BAUD RATE, DATA BITS, STOP BITS, and PARITY BITS. I also add a control to handle serial data transmission.

Hope you enjoy this, thanks for watching :). Please keep watching for my next video.

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

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

20 COMMENTS

  1. i am getting error for Parity that Requsted value "none" was not found even i changed for odd and even i am getting same problem
    What to do??????????

  2. mpu6050 spi arduino, sda will get roll pitch and yaw values how to split that data in to 3 textboxes in visual studio c#

  3. You can have him do the following

    Communication between the host computers and the game occurs through a serial data link that operates to

    19.2 kbit in a "wake up" mode. The 11-bit data packet consists of a start bit, eight data bits, a ninth 'wake up' bit, and a

    stop bit.

  4. hi , how can i receive data from a serial port device and save database after that i have to print . please help me . advance thanks

  5. Is it possible can we read and write data on same port?
    I'm asking because after writing a data not able to get acknowledgement DataReceived not fire
    Basically i'm trying to send command to patlite device. You can see the command list from this pdf document(https://drive.google.com/file/d/1ZVIWYLJz28DEeN6-NSsLExEpJI4ZJ4pq/view?usp=sharing)
    For Example:-
    private void PORTOPEN(byte[] data)
    {
    mSerialPort = new SerialPort();
    if (mSerialPort.IsOpen)
    {
    mSerialPort.Close();
    }
    mSerialPort.DataReceived += SerialPort_DataReceived;
    mSerialPort.ErrorReceived += MSerialPort_ErrorReceived;
    mSerialPort.ReadBufferSize = 10240;
    mSerialPort.PortName = "COM5";
    mSerialPort.BaudRate = 9600;
    mSerialPort.StopBits = (StopBits)1;
    mSerialPort.DataBits = 8;
    mSerialPort.Parity = Parity.None;
    //mSerialPort.ReceivedBytesThreshold = 9;
    //mSerialPort.RtsEnable = true;
    mSerialPort.DtrEnable = true;
    mSerialPort.Handshake = Handshake.RequestToSend;
    //mSerialPort.ReadTimeout = 5000;
    //mSerialPort.WriteTimeout = 5000;
    mSerialPort.Open();
    //{ 0x40,0x3F,0x3F,0x4D,0x21 }; // //{ 0x40, 0x35, 0x36, 0x30, 0x32, 0x21 };
    //string s = "@ ?? 1 3 2 !";
    //byte[] data = Encoding.ASCII.GetBytes(s);
    mSerialPort.Write(data, 0, data.Length);
    string read=mSerialPort.ReadExisting();
    }
    private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {

    }
    private void MSerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
    {

    }

LEAVE A REPLY

Please enter your comment!
Please enter your name here