检测到索尼相机 PTP 响应停止条件(端点停止)或不支持控制请求

问题描述 投票:0回答:1

我在 golang 上有一个程序可以与相机通信,但是当尝试使用参数发送命令

0x9201 (SDIOConnect)
时,它保持响应停止
(0x1,0x0,0x0)

我使用 libgphoto2 ,它工作得很好,但我们使用 go-usb 和 golang 来响应它的停止。可能是因为我使用方法不对?

    buffSetPcModeSony := []byte{0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x92, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
log.Printf("buffSetPcModeSony: [% x]", buffSetPcModeSony)
TransferOut(epOut, buffSetPcModeSony)
TransferIn(epIn)

这是写入和读取数据的函数

    func TransferOut(epOut *gousb.OutEndpoint, data []byte) {
    log.Println("===StartTransferOut===")
    // writeBytes might be smaller than the buffer size if an error occurred. writeBytes might be greater than zero even if err is not nil.
    writeBytes, err := epOut.Write(data)
    if err != nil {
        fmt.Println("Write returned an error:", err)
    }
    log.Printf("OUT endpoint 5 send only %d bytes of data", writeBytes)
    log.Println("===EndTransferOut===")
}

func TransferIn(epIn *gousb.InEndpoint) []byte {
    log.Println("===StartTransferIn===")
    totalData := make([]byte, 0)
    isRead := true
    for isRead {
        bufRead := make([]byte, epIn.Desc.MaxPacketSize)
        readBytes, err := epIn.Read(bufRead)
        if err != nil {
            isRead = false
            fmt.Println("Read returned an error:", err)
        }

        if readBytes < 12 {
            isRead = false
            log.Fatalf("IN endpoint 6 returned 12 bytes of data.")
        }

        if readBytes == 12 {
            log.Println("stop loop get data end of the buffer")
            isRead = false
        } else {
            log.Println("continue loop to get data")
        }

        log.Printf("total readBytes %d", readBytes)

        totalData = append(totalData, bufRead[:readBytes]...)
    }

    log.Printf("IN endpoint 6 received only [% x]", totalData)
    log.Println("===EndTransferIn===")
    return totalData
}

对于打开会话并获取设备信息,它可以工作,但不能使用 SDIOConnect,我从 gphoto2 找到了命令字节

go libgphoto2
1个回答
0
投票

我和你有同样的问题。你解决了吗?我该怎么办

© www.soinside.com 2019 - 2024. All rights reserved.