nxt에서 pc로 블루투스 문자 메시지를 보내고 PC에서 읽을 수있는 방법은 무엇입니까?NXT to pc bluetooth text 메시지
나는 이것을 사용 :
byte[] byteOut = new byte[65];
int i = 0;
try
{
byteOut[0] = (byte)(TextBox1.TextLength + 5);
//number bytes in output message
byteOut[1] = 0x0;
//should be 0 for NXT
byteOut[2] = 0x00;
//&H0 = reply expected &H80 = no reply expected
byteOut[3] = 0x9;
//Send Bluetooth
byteOut[4] = 0x0;
//Box Number - 1
byteOut[5] = (byte)(TextBox1.TextLength + 1);
//message size with null terminator
//copy bytes into output array
for (i = 1; i <= TextBox1.TextLength; i++)
{
byteOut[(i + 5)] = Convert.ToByte(Asc(TextBox1.Text.Substring((i - 1), 1)));
}
byteOut[TextBox1.TextLength + 6] = 0x0;
//add null terminator
SerialPort1.Write(byteOut, 0, TextBox1.TextLength + 7);
//send message
// I try to use this for reading but it doesn't work good. It gets a lot of numbers and no text.
char[] read1 = new char[65];
SerialPort1.Read(read1, 0, TextBox1.TextLength + 7);
string box1 = "";
for (int i1 = 0; i1 < read1.Length; ++i1)
{
box1 += read1[i1];
}
MessageBox.Show(box1);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
내가 읽는이를 사용하려고하지만 잘 작동하지 않습니다. 숫자가 많고 문자가 없습니다.
어떻게해야합니까?