关掉程序再打开,再下载固件程序,就不能向USB传输数据了

[复制链接]
285|12
手机看帖
扫描二维码
随时随地手机跟帖
houcs|  楼主 | 2019-5-28 23:04 | 显示全部楼层 |阅读模式
关掉程序再打开,再下载固件程序,就不能向USB传输数据了

使用特权

评论回复
chuxh| | 2019-5-28 23:05 | 显示全部楼层
你自己写的程序?

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:06 | 显示全部楼层
照着PC机示例程序写了一个PC程序,第一次打开PC程序下载FX2固件程序后能正常使用。

使用特权

评论回复
renyaq| | 2019-5-28 23:07 | 显示全部楼层
如果不再次下载固件程序

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:09 | 显示全部楼层
不再次下载固件程序,程序使用是正常的。

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:10 | 显示全部楼层
请问FX2在设备枚举和重枚举的时候有啥要注意的,导致我这种错误。

使用特权

评论回复
yinxiangh| | 2019-5-28 23:11 | 显示全部楼层
我觉得问题应该就是在FX2初始化,枚举重枚举那里。

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:12 | 显示全部楼层
我FX2只要reset一下就全好了,不reset再下载固件程序就不行。

使用特权

评论回复
zwll| | 2019-5-28 23:14 | 显示全部楼层
不清楚这部分该怎么做,可以多次下载固件程序不出错。

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:15 | 显示全部楼层
是不是每次下载之前都要重新get_address之类的

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:17 | 显示全部楼层

下面是固件下载程序,就是原来的示例程序,没改过
BOOL CCYDEMODlg::OnDownloadFirmware(LPTSTR strdownloadfile,BOOL displaycharen)
{
        // TODO: Add your control notification handler code here
        HANDLE hDevice=NULL;
        BOOL   bResult = FALSE;
        ULONG  nBytes;
        char   DeviceName[256] = "";
//        char   tempbuff[256];
//        char   temp[256];
    unsigned char buffer[MAX_BIX_SIZE];
    int    numreadfile  = 0;
//        int i;

        HWND hdlg = NULL;
        VENDOR_REQUEST_IN        myRequest;

        BOOL Downloadresult = FALSE;
        
        m_strTestDisplay+="\r\n";

        // Open the driver
        if(!bOpenDriver(&hDevice,m_strName.GetBuffer(m_strName.GetLength())))
        {
                m_strTestDisplay+="No available device!\r\nPlease try again!\r\n";
                UpdateData(FALSE);
                return Downloadresult;
        }        
        
        myRequest.bRequest = 0xA0;
        myRequest.wValue = 0xE600;
        myRequest.wIndex = 0x00;
        myRequest.wLength = 0x01;
        myRequest.bData = 1;        //锁定
        myRequest.direction = 0x00;
        
        bResult = DeviceIoControl (hDevice,
                IOCTL_Ezusb_VENDOR_REQUEST,
                &myRequest,
                sizeof(VENDOR_REQUEST_IN),
                NULL,
                0,
                &nBytes,
                NULL);
        
        if (bResult!=TRUE)
        {
                m_strTestDisplay+="Error!Can't lock USB chip\r\n";
                CloseHandle(hDevice);
                return Downloadresult;
        }               
        else {
                m_strTestDisplay+="Success!\r\nUSB chip has been locked!\r\n";
        }
        UpdateData(FALSE);

        CFile MyFile;
        if (!MyFile.Open(strdownloadfile,CFile::modeRead,NULL))
        {
                MessageBox("Can't open the config file!","Config Error",MB_ICONERROR);
                CloseHandle(hDevice);
                return Downloadresult;
        }
        else
        {
                MyFile.Read(buffer,MAX_BIX_SIZE);        //读取文件
                numreadfile = MAX_BIX_SIZE;
                CString strfilelength;
                strfilelength.Format("The config file size is %d Bytes\r\n",numreadfile);
                m_strTestDisplay+=strfilelength;
                UpdateData(FALSE);
        }
        MyFile.Close();

    bResult = DeviceIoControl (hDevice,
                IOCTL_Ezusb_ANCHOR_DOWNLOAD,
                buffer,
                numreadfile,
                NULL,
                0,
                &nBytes,
                NULL);
        if (bResult!=TRUE)
        {
                m_strTestDisplay+="Error!\r\nDownlod config file Fail!\r\n";
        }
    else
        {
                m_strTestDisplay+="Success!\r\nConfig file has been downloaded\r\n";
        }
        UpdateData(FALSE);

        myRequest.bRequest = 0xA0;
        myRequest.wValue = 0xE600;
        myRequest.wIndex = 0x00;
        myRequest.wLength = 0x01;
        myRequest.bData = 0;        //复位
        myRequest.direction = 0x00;

        bResult = DeviceIoControl (hDevice,
                IOCTL_Ezusb_VENDOR_REQUEST,
                &myRequest,
                sizeof(VENDOR_REQUEST_IN),
                NULL,
                0,
                &nBytes,
                NULL);

        if (bResult!=TRUE)
                m_strTestDisplay+="Error!\r\nReset USB chip fail!\r\n";
        else {
                m_strTestDisplay+="Success!\r\nUSB chip has been reset\r\n";
                Downloadresult = TRUE;
        }
        UpdateData(FALSE);

        CloseHandle(hDevice);
        return Downloadresult;        
}

使用特权

评论回复
stly| | 2019-5-28 23:18 | 显示全部楼层
lz是在做USB通信么??

使用特权

评论回复
houcs|  楼主 | 2019-5-28 23:18 | 显示全部楼层
唉,还是没有什么结果,算了,先结贴吧,多谢大家啦

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

743

主题

8382

帖子

5

粉丝