小R科技-WIFI机器人网·机器人创意工作室

 找回密码
 立即注册
查看: 8975|回复: 2

C#上位机,wifi板就是接不到指令,求指导

[复制链接]
发表于 2013-4-20 12:41:45 | 显示全部楼层 |阅读模式
打算用用C#写上位机,直接复制例程的代码,觉得没问题啊,可是wifi板就是接不到指令,但是我用第一代的CommandEngine,wifi板就能收到指令,求指导。。。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO.Ports;
using WIFIRobotCMDEngineV2;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string ControlIp = "192.168.1.1";
        string Port = "2001";
        public WifiRobotCMDEngineV2 RobotEngine2;
        static IPAddress ips;
        static IPEndPoint ipe;
        static Socket socket = null;
        string CMD_Forward = "FF0000FF";



        public Form1()
        {
            InitializeComponent();
            RobotEngine2 = new WifiRobotCMDEngineV2((Object)this.button1);
        }
        bool ret = false;
        private bool InitWIFISocket(String controlIp, String port)
        {
            ips = IPAddress.Parse(controlIp.ToString());
            ipe = new IPEndPoint(ips, Convert.ToInt32(port.ToString()));
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.Connect(ipe);
            RobotEngine2.SOCKET = socket;
            RobotEngine2.IPE = ipe;
            ret = RobotEngine2.SocketConnect();
            return ret;

        }


        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            InitWIFISocket(ControlIp, Port);
            label1.Text = ret.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SerialPort comm = new SerialPort();
            RobotEngine2.SendCMD(0, CMD_Forward, comm);
        }
    }
}


回复

使用道具 举报

发表于 2013-4-20 17:20:38 | 显示全部楼层
有些程序 需要配置吧?直接复制肯定不行的
回复 支持 反对

使用道具 举报

发表于 2013-4-20 21:16:17 | 显示全部楼层
你用哪个版本的引擎?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

新品特惠推荐上一条 /2 下一条

QQ|QQ技术咨询1|QQ技术咨询2|商务合作微信1:xiaorgeek001|商务合作微信2:XiaoRGEEK|诚聘英才|Archiver|手机版|小R科技-WIFI机器人网·机器人创意工作室 ( 粤ICP备15000788号-6 )

GMT+8, 2024-5-19 11:38 , Processed in 1.087523 second(s), 19 queries .

Powered by XiaoR GEEK X3.4

© 2014-2021 XiaoR GEEK

快速回复 返回顶部 返回列表