2017-12-28 9 views
0

직렬 포트로 IP로 변환하기위한 tibbo 장치가 있습니다. 퍼티와 같은 프로그램을 사용하면 장치를 성공적으로 연결할 수 있으며 장치가 작동 중입니다.C# 직렬 포트 변환기 IP를 통해 데이터 읽기

이 장치를 듣기 위해 거의 C# Windows 양식 응용 프로그램을 개발하고 싶지만 어떤 방법으로도 찾을 수 없습니다. 응용 프로그램은 IP 변환 장치를 통해 tibbo 직렬을 통해 ip를 통해 직렬 포트에서 데이터를 가져옵니다. 내가 어떻게 해 ?

답변

0

Tibbo Device Server Toolkit을 설치하고 tibbo 장치를 COM 포트에 연결하십시오.

using System; 
using System.IO.Ports; 
using System.Windows.Forms; 

namespace SerialPortExample 
{ 
    class SerialPortProgram 
    { 
    // Create the serial port with basic settings 
    private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); 

    [STAThread] 
    static void Main(string[] args) 
    { 
     // Instatiate this class 
     new SerialPortProgram(); 
    } 

    private SerialPortProgram() 
    { 
     Console.WriteLine("Incoming Data:"); 

     // Attach a method to be called when there 
     // is data waiting in the port's buffer 
     port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); 

     // Begin communications 
     port.Open(); 

     // Enter an application loop to keep this thread alive 
     Application.Run(); 
    } 

    private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) 
    { 
     // Show all the incoming data in the port's buffer 
     Console.WriteLine(port.ReadExisting()); 
    } 
    } 
} 
: 당신이 필요로하는 경우하여 SerialPort 통신에 더 많은 도움이 문서 Serial Port Communication for beginners

예제 코드를 읽고