Sony camera PTP response halt condition detected (endpoint stalled) or control request not supported

47 views Asked by At

I have a program on golang to communicate with the camera but its keeps response halt when try to send the command 0x9201 (SDIOConnect) with params (0x1,0x0,0x0)

I use libgphoto2 and its works well but we I do it use go-usb with golang the response its halt. it's maybe because I use it in the wrong way?

    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)

this is the function to write and read data

    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
}

for the open sessions and get device info its works but not with SDIOConnect, I found the command byte from gphoto2

gphoto2 logs

0

There are 0 answers