主题 : 分享mini2440 簡單架環境+串口實現 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 110412
精华: 0
发帖: 7
金钱: 35 两
威望: 7 点
贡献值: 0 点
综合积分: 14 分
注册时间: 2014-11-24
最后登录: 2016-01-05
楼主  发表于: 2015-09-07 12:02

 分享mini2440 簡單架環境+串口實現

分享mini2440 簡單架環境+串口實現

1.安裝VS2008  pro版
2.安裝.NET Compact Framework 3.5
3.直接用串口控件寫串口程序

簡易自發自收,將RS232  pin2 3腳短路,按下發送按鈕  送出12345 會收到12345
修改後這樣就能控制外部單晶片做IO等一些工作

實測通過程序如下:  
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SmartDeviceProject3;
using System.IO;
using System.Text;
namespace SmartDeviceProject2
{
    public partial class Form1 : Form
    {   private static int a = 1;
        byte[] data;
        byte[] buffer = new byte[5];
        byte[] buffer2 = new byte[5];

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (!serialPort1.IsOpen)
            {
                serialPort1.Open();
            }

            buffer[0]=1;
            buffer[1]=2;
            buffer[2]=3;
            buffer[3]=4;
            buffer[4]=5;
            serialPort1.Write(buffer, 0, 5);
            serialPort1.Read(buffer2, 0, 5);
            serialPort1.DiscardInBuffer();
            serialPort1.Close();
            for (a = 0; a < 5; a++)
            {
                listBox1.Items.Add(buffer[a]);
                listBox2.Items.Add(buffer2[a]);            
            }
    }

    }
}