This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DLPC350: USB Interface中的sequence bytes具体逻辑

Part Number: DLPC350

Hi,

我在用python脚本重新实现DLPC350的通信。我没太理解dlpu010g-DLPC350 Programmer Guide文档里面关于sequence byte的解释。

文档描述是:

Host sends the sequence byte. When a single command is more than 64 bytes, the command is sent
as multiple USB packets and the sequence byte numbers the packets so the device can assemble
them in the right sequence. In other cases, this value is irrelevant and generally set to 0.

这是说当command+数据大于64bytes就需要修改sequence byte么?

我看SDK源码里面DLPC_PrepReadCmd 这个byte是设置为0,而DLPC_PrepWriteCmd这个byte又是全局变量g_SeqNum++。这是为什么?

  • 读的时候就直接加上了读的数据,可以不用这个字节;而写的时候,需要标记发的第几段。

        g_OutputBuffer[0]=0; // First byte is the report number
        memcpy(&g_OutputBuffer[1], &msg, (sizeof(msg.head)+sizeof(msg.text.cmd) + msg.head.length));
     
    static int DLPC350_PrepReadCmd(DLPC350_CMD cmd)
    /**
     * This function is private to this file. Prepares the read-control command packet for the given command code and copies it to g_OutputBuffer.
     *
     * @param   cmd  - I - USB command code.
     *
     * @return  0 = PASS
     *          -1 = FAIL
     *
     */
    {
        hidMessageStruct msg;
    
    
        msg.head.flags.rw = 1; //Read
        msg.head.flags.reply = 1; //Host wants a reply from device
        msg.head.flags.dest = 0; //Projector Control Endpoint
        msg.head.flags.reserved = 0;
        msg.head.flags.nack = 0;
        msg.head.seq = 0;
    
    
        msg.text.cmd = (CmdList[cmd].CMD2 << 8) | CmdList[cmd].CMD3;
        msg.head.length = 2;
    
    
        if(cmd == BL_GET_MANID)
        {
            msg.text.data[2] = 0x0C;
            msg.head.length += 1;
        }
        else if (cmd == BL_GET_DEVID)
        {
            msg.text.data[2] = 0x0D;
            msg.head.length += 1;
        }
        else if (cmd == BL_GET_CHKSUM)
        {
            msg.text.data[2] = 0x00;
            msg.head.length += 1;
        }
    
    
        g_OutputBuffer[0]=0; // First byte is the report number
        memcpy(&g_OutputBuffer[1], &msg, (sizeof(msg.head)+sizeof(msg.text.cmd) + msg.head.length));
        return 0;
    }
  • 感谢回复,所以说对于读命令,这个byte都可以置为0。

    对于写命令,每一个写命令包都需要标记这个byte么?比如对于set_mode,set_LED_Enable这些数据只有一个byte的命令也需要标记sequence么?

  • 主要是长的command需要。用python,整个API都需要改写。也可以将API在QT中编译为lib,再用Python调用。