using UnityEngine;
using System.Collections;
using System.IO.Ports;
using System;
using System.Collections.Generic;
using System.Threading;
<p> public class PortControl : MonoBehaviour {
public GUIText gui;
public string portName = "COM2";
public int baudRate = 9600;
public Parity parity = Parity.None;
public int dataBits = 8;
public StopBits stopBits = StopBits.One;
int[] data = new int[6];//用于存儲6位數(shù)據(jù)
SerialPort sp = null;
Thread dataReceiveThread;
//發(fā)送
string message = "";
//byte[] message=new byte[8];
void Start()
{
OpenPort();
dataReceiveThread = new Thread(new ThreadStart(DataReceiveFunction));
dataReceiveThread.Start();
}
void Update()
{
string str = "";
for(int i=0; i
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。