나는 winforms를 가정 할 것입니다. 그렇지 않다면 이것은 도움이되지 않을 것입니다.
먼저 도구 상자에서 양식에 직렬 포트를 추가하십시오. 그런 다음 다음과 같이 데이터를 배열로 가져옵니다.
string tempStr;
int size = serialPort1.BytesToRead;
//runs as long as there are bytes in the serial buffer to be read,
//you may need to change the way it runs to get all of your data depending upon
//how the device is sending data to the serial port
while (size != 0)
{
//store incoming byte
int b1 = serialPort1.ReadByte();
//converts byte to character
char c = Convert.ToChar(b1);
//puts the character into a string
tempStr = c.ToString();
//append it to Rx (output string)
Rx += tempStr;
}
//you'll may need to do some messing around with the character you use to split
string[] results = Rx.Split(new Char[] {'\r' });
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다