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); }
uint16_t CanonPS::Capture() { uint16_t ptp_error = PTP_RC_GeneralError; if ((ptp_error = Operation(PS_OC_FocusLock, 0, NULL)) != PTP_RC_OK) PTPTRACE2("Focus Lock Error: ", ptp_error); delay(500); if ((ptp_error = Operation(PS_OC_InitiateCaptureInMemory, 0, NULL)) != PTP_RC_OK) PTPTRACE2("Capture Error: ", ptp_error); return ptp_error; }
uint16_t CanonPS::Initialize(bool binit) { uint16_t ptp_error = PTP_RC_GeneralError; if (binit) { if ((ptp_error = Operation(PS_OC_StartShootingMode, 0, NULL)) != PTP_RC_OK) PTPTRACE2("StartShootingMode failed: ", ptp_error); } else { if ((ptp_error = Operation(PS_OC_EndShootingMode, 0, NULL)) != PTP_RC_OK) PTPTRACE2("EndShootingMode failed: ", ptp_error); } return ptp_error; }
void CamStateHandlers::OnDeviceInitializedState(PTP *ptp) { uint16_t ptp_error; if (stateConnected == stDisconnected || stateConnected == stInitial) { stateConnected = stConnected; if((ptp_error = Eos.SetProperty(EOS_DPC_LiveView, 0)) != PTP_RC_OK) { //turn off live view PTPTRACE2("AO Camera: LiveView off failed", ptp_error); } if((ptp_error = Eos.SetProperty(EOS_DPC_LiveView, 2)) != PTP_RC_OK) { //turn on live view PTPTRACE2("AO Camera: LiveView mode 2 failed", ptp_error); } AO_Camera->postFIFO(Q_NEW(QEvent, CAM_READY_SIG)); }//if(stateConnected... }
uint16_t CanonPS::EventCheck(PTPReadParser *parser) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 0, 0, 0, 1, 1, 0 }; if ( (ptp_error = Transaction(PS_OC_CheckEvent, &flags, NULL, parser)) != PTP_RC_OK) PTPTRACE2("EventCheck error: ", ptp_error); return ptp_error; }
uint16_t CanonEOS::GetDeviceInfoEx(PTPReadParser *parser) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 0, 0, 0, 1, 1, 0 }; if ( (ptp_error = Transaction(EOS_OC_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK) PTPTRACE2("GetDeviceInfo error:", ptp_error); return ptp_error; }
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; } }
uint16_t CanonEOS::GetProperty(uint16_t prop, PTPReadParser *parser) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 1, 0, 0, 1, 1, 0 }; uint32_t params[1]; params[0] = (uint32_t)prop; if ( (ptp_error = Transaction(EOS_OC_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK) PTPTRACE2("GetProperty error:", ptp_error); return ptp_error; }
uint16_t CanonEOS::MoveFocus(uint16_t step) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 1, 0, 0, 0, 0, 0 }; uint32_t params[1]; params[0] = (uint32_t) step; if ( (ptp_error = Transaction(EOS_OC_MoveFocus, &flags, params, NULL)) != PTP_RC_OK) PTPTRACE2("MoveFocus error: ", ptp_error); return ptp_error; }
uint16_t CanonEOS::SetImageQuality(uint32_t format) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 0, 0, 1, 1, 1, 0 }; ImgQualitySupplier sup; sup.SetPictureFormat(format); if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)&sup)) != PTP_RC_OK) PTPTRACE2("SetImageQuality error", ptp_error); return ptp_error; }
uint16_t CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 2, 0, 0, 1, 1, 0 }; uint32_t params[2]; params[0] = object_id; params[1] = parent_id; if ( (ptp_error = Transaction(EOS_OC_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK) PTPTRACE2("GetObject error:", ptp_error); return ptp_error; }
uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val) { uint16_t ptp_error = PTP_RC_GeneralError; OperFlags flags = { 0, 0, 1, 1, 3, 12 }; uint32_t params[3]; params[0] = 0x0000000C; params[1] = (uint32_t)prop; params[2] = val; if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK) PTPTRACE2("SetProperty error:", ptp_error); return ptp_error; }
uint16_t CanonEOS::SwitchLiveView(bool on) { uint16_t ptp_error = PTP_RC_GeneralError; if ((ptp_error = SetProperty(EOS_DPC_LiveView, (on) ? 2 : 0)) == PTP_RC_OK) { if (on) { if ((ptp_error = SetProperty(0xD1B3, 0)) != PTP_RC_OK) { PTPTRACE2("LiveView start failure:", ptp_error); SetProperty(EOS_DPC_LiveView, 0); return PTP_RC_GeneralError; } } } return ptp_error; }
// $(AOs::Commands::Statechart::focus_move) .................................. QState Commands::focus_move(Commands *me, QEvent const *e) { switch (e->sig) { // @(/2/4/4/2) case Q_ENTRY_SIG: { //Notify(PSTR("AO_Commands: Focus Move Entry\r\n")); uint16_t ptp_error; if((ptp_error = Eos.MoveFocus(me->fstep_cmd)) != PTP_RC_OK) { //one step towards the camera PTPTRACE2("AO_Commands: Focus Step failed", ptp_error); AO_Lights->postFIFO(Q_NEW(QEvent, LED_ERROR_SIG)); } if(me->fstep_cmd == NSTEP) { --me->focus_position; } else { ++me->focus_position; } me->cmd_delay.disarm(); me->cmd_delay.postIn(me, FM_CMD_DELAY); return Q_HANDLED(); } // @(/2/4/4/2) case Q_EXIT_SIG: { //Notify(PSTR("AO_Commands: Focus Move Exit\r\n")); return Q_HANDLED(); } // @(/2/4/4/2/0) case CMD_DELAY_SIG: { //Notify(PSTR("AO_Commands: Focus Move: CMD_DELAY_SIG\r\n")); FocusMovedEvt *fme = Q_NEW( FocusMovedEvt, FOCUS_MOVED_SIG ); fme->focus_position = me->focus_position; AO_Lights->postFIFO(Q_NEW(QEvent, LED_WORKING_SIG)); AO_Camera->postFIFO( fme ); return Q_TRAN(&Commands::idle); } } return Q_SUPER(&QHsm::top); }