|
发表于 2013-10-14 08:26:51
|
显示全部楼层
liuviking 发表于 2013-5-24 21:06
看这里:
【机器人创意工作室教程八】WIFI/蓝牙智能小车机器人操控平台双向数据引擎与功能拓展 http://www ...
自己也写了一段上位机串口测试程序(很简单的哪一种),wifi那边用串口助手,上位机这边发送数据,串口助手可以接收到;可是串口助手发送数据,上位机这边接受不到,希望得到帮助……
private void NetSeriesThread()
{
byte[] read = new byte[1024];
byte[] write = new byte[1024];
//创建服务器
TcpClient tcpc = new TcpClient();
//请求连接服务器
int iPort = System.Int32.Parse(TB_PORT.Text);
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(TB_IP.Text), iPort);
tcpc.Connect(ipep);
//建立网络数据流
NetworkStream s = tcpc.GetStream();
while(true)
{
//发送信息
//write[0] = 0xfe;
//write[1] = 0x01;
//write[2] = 0x01;
//write[3] = 0x02;
//write[4] = 0x16;
//s.Write(write, 0, write.Length);
//获取流(接收信息)
int bytes = s.Read(read, 0, read.Length);
string strInf = Encoding.ASCII.GetString(read);
MessageBox.Show(strInf);
}
s.Close();
tcpc.Close();
} |
|