일부 감시 프로젝트 수행 중 ... 두 시스템 간의 serialport 데이터 통신을 필요로합니다 ... 여기 내 시스템에서 사용할 수있는 COM 포트를 찾아서 보내고받을 필요가 있습니다 데이터 ... NET Framework 1.1에서 가능합니까? 어떤 옵션이 있습니까?시리얼 포트를 통한 데이터 전송
System.IO.Ports는 .NET 1.1에 제약이 1.1
일부 감시 프로젝트 수행 중 ... 두 시스템 간의 serialport 데이터 통신을 필요로합니다 ... 여기 내 시스템에서 사용할 수있는 COM 포트를 찾아서 보내고받을 필요가 있습니다 데이터 ... NET Framework 1.1에서 가능합니까? 어떤 옵션이 있습니까?시리얼 포트를 통한 데이터 전송
System.IO.Ports는 .NET 1.1에 제약이 1.1
그물을 사용할 수 없습니다? .NET 2.0을 사용할 수있는 경우 SerialPort.GetPortNames 메서드를 사용하여 로컬 호스트의 직렬 포트 목록을 검색 할 수 있습니다. SerialPort 클래스는 System.IO.Ports 네임 스페이스에 있습니다.
System.IO.Ports가 .net 1.1에 없습니다. –
오른쪽. 그에 따라 내 게시물을 편집 할 것입니다. –
.net 1.1에 대해 OpenNETCF.IO.Serial을 사용했습니다. 버전 2.0의 .net에 직렬 지원이 추가 되었기 때문입니다. 그것은 컴팩트 프레임 워크를위한 것입니다. 그러나 컴팩트 장치와 일반 Windows 응용 프로그램 모두에 사용했습니다. 내가 한 일을 스스로 수정할 수 있도록 소스 코드를 얻을 수 있습니다.
기본적으로 kernel32.dll에서 가져온 직렬 함수를 중심으로 C# 래퍼를 만듭니다.
또한 여기 How to capture a serial port that disappears because the usb cable gets unplugged
좀보고 할 수 있습니다 내가 1.1 다시 일부 직렬 포트 작업을 할 필요하면 내가
using OpenNETCF.IO.Serial;
public static Port port;
private DetailedPortSettings portSettings;
private Mutex UpdateBusy = new Mutex();
// create the port
try
{
// create the port settings
portSettings = new HandshakeNone();
portSettings.BasicSettings.BaudRate=BaudRates.CBR_9600;
// create a default port on COM3 with no handshaking
port = new Port("COM3:", portSettings);
// define an event handler
port.DataReceived +=new Port.CommEvent(port_DataReceived);
port.RThreshold = 1;
port.InputLen = 0;
port.SThreshold = 1;
try
{
port.Open();
}
catch
{
port.Close();
}
}
catch
{
port.Close();
}
private void port_DataReceived()
{
// since RThreshold = 1, we get an event for every character
byte[] inputData = port.Input;
// do something with the data
// note that this is called from a read thread so you should
// protect any data pass from here to the main thread using mutex
// don't forget the use the mutex in the main thread as well
UpdateBusy.WaitOne();
// copy data to another data structure
UpdateBusy.ReleaseMutex();
}
private void port_SendBuff()
{
byte[] outputData = new byte[esize];
crc=0xffff;
j=0;
outputData[j++]=FS;
// .. more code to fill up buff
outputData[j++]=FS;
// number of chars sent is determined by size of outputData
port.Output = outputData;
}
// code to close port
if (port.IsOpen)
{
port.Close();
}
port.Dispose();
좋아, 그럼 육즙 부분은 어디있어? (port_DataReceived())? –
를 호출하는 데 사용되는 코드입니다, 내가 발견 MSComm OCX 컨트롤을 사용하는 Noah Coad가 저술 한 기사. 그의 기사는 http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320에 있습니다. 행운을 빕니다!
-1. 질문을 일관된 문장으로 올바로 형식화하지 않아도됩니다. 도움이 필요하면 인간처럼 질문을 표현할 예의를 가져보십시오. – mpen
서식이 이유 인 경우 투표가 불투명합니다. – rahul
영어는 그의 모국어가 될 수 없습니다. – eKek0