void PSStateHandlers::OnSessionOpenedState(PTP *ptp) { if (FAILED(((CanonPS*)ptp)->SetDevicePropValue(PS_DPC_EventEmulateMode, (uint16_t)4)) ) PTPTRACE("EventEmulateMode error\r\n"); if (FAILED(((CanonPS*)ptp)->Initialize(true)) ) PTPTRACE("Initialization error\r\n"); ptp->SetState(PTP_STATE_DEVICE_INITIALIZED); }
uint8_t CanonEOS::Init(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[10]; USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); uint8_t rcode; UsbDevice *p = NULL; EpInfo *oldep_ptr = NULL; PTPTRACE("EOS Init\r\n"); AddressPool &addrPool = pUsb->GetAddressPool(); if (devAddress) return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; // Get pointer to pseudo device with address 0 assigned p = addrPool.GetUsbDevicePtr(0); if (!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; if (!p->epinfo) { PTPTRACE("epinfo\r\n"); return USB_ERROR_EPINFO_IS_NULL; } // Save old pointer to EP_RECORD of address 0 oldep_ptr = p->epinfo; // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence p->epinfo = epInfo; // Get device descriptor rcode = pUsb->getDevDescr( 0, 0, 10, (uint8_t*)buf ); // Restore p->epinfo p->epinfo = oldep_ptr; if( rcode ) { PTPTRACE2("getDevDesc:", rcode); return rcode; } if (udd->idVendor == 0x04A9) return PTP::Init(parent, port, lowspeed); else { PTPTRACE("Camera isn't Canon\r\n"); return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; } }
void EOSStateHandlers::OnSessionOpenedState(PTP *ptp) { uint16_t ret; ret = ((CanonEOS*)ptp)->SetPCConnectMode(1); if (FAILED(ret)) { PTPTRACE2("SetPCConnectMode failed", ret); return; } ret = ((CanonEOS*)ptp)->SetExtendedEventInfo(1); if (FAILED(ret)) { PTPTRACE2("SetExtendedEventInfo failed", ret); return; } PTPTRACE("Init complete\r\n"); ptp->SetState(PTP_STATE_DEVICE_INITIALIZED); //if (!FAILED(((CanonEOS*)ptp)->SetPCConnectMode(1)) && !FAILED(((CanonEOS*)ptp)->SetExtendedEventInfo(1))) // ptp->SetState(PTP_STATE_DEVICE_INITIALIZED); }