PDA

View Full Version : [HELP] Chuyển dữ liệu qua RS232


chymnon
23-04-2010, 05:05 AM
Em dùng phần mềm tạo cổng COM ảo và mô phỏng trên Proteus như file đính kèm.
Sau đây là code C# của em:

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.IO.Ports;

namespace testCOM
{
public partial class MainForm : Form
{
SerialPort serialPort = new SerialPort("COM4", 9600, Parity.None, 8);
byte[] data;
public MainForm()
{
InitializeComponent();
serialPort.Open();

}

private void btSend_Click(object sender, EventArgs e)
{
serialPort.Write(txtSendingText.Text);

}

private void btExit_Click(object sender, EventArgs e)
{
Close();
}
}
}


Dạ xin hỏi là vì sao trên màn hình Virtual Terminal nó lại hiện ra các ký tự kia khi em send số 1? Có phải là do hàm "Write" chuyển dữ liệu ra COM là chuyển string nên bị lỗi? Và cách giải quyết như thế nào? Em xin cảm ơn :D

chymnon
23-04-2010, 12:01 PM
không ai giúp em ạ :-<

dtvtb
26-04-2010, 05:27 PM
Ku chỉnh lại tốc độ CPU cho tương thích với khai báo trong ccs hay trình biên dịch tương ứng

pakaquang
22-07-2010, 10:54 PM
đây là do bạn thiết lập tốc độ buad không tương thích với nhau!

quangvy87
23-07-2010, 07:06 PM
chuot phai vao vitur tẻminal chon lai toc do baud la ok