Set current DateTime - SONY SDK

56 Views Asked by At

I am trying to set the datetime of a Sony alpha 7s iii to be a PC current datetime, using the Sony SDK. Without modifying too much to the RemoteCli.cpp code that is provided as an example, I added a case there:

while (true) {
    cli::tout << "<< Time Sync >>\nWhat would you like to do? Enter the corresponding number.\n";
    cli::tout
        << "(0) Return to REMOTE-MENU\n"
        << "(1) Set Camera Time From PC \n"
        ;
    cli::tout << "input> ";
    cli::text select;
    std::getline(cli::tin, select);
    cli::tout << '\n';
    if (select == TEXT("1")) { /* Time Sync */
        camera->set_datetime();
    }
    else if (select == TEXT("0")) {
        cli::tout << "Return to REMOTE-MENU.\n";
        break;
    }
    cli::tout << std::endl;
}// end of loop-Menu7

and based on this question , I created a new set_datetime function in CameraDevice.cpp:

void CameraDevice::set_datetime() {
    std::time_t result = std::time(nullptr);
    std::asctime(std::localtime(&result));
    cli::tout << result;

    CrInt64 time = static_cast<CrInt64>(result);
    SDK::CrDeviceProperty prop;
    prop.SetCode(SDK::CrDevicePropertyCode::CrDeviceProperty_DateTime_Settings);
    prop.SetCurrentValue(time);
    prop.SetValueType(SDK::CrDataType::CrDataType_UInt64);
}

Unfortunately, the PC current time is not written on the camera.

1

There are 1 best solutions below

0
Gilad Samuel On BEST ANSWER

I didn't notice that I forgot to add the set device property command - SDK::SetDeviceProperty(m_device_handle, &prop);

Changed it to this:

void CameraDevice::set_datetime() {
    std::time_t result = std::time(nullptr);
    std::asctime(std::localtime(&result));
    cli::tout << result;

    SDK::CrDeviceProperty prop;
    prop.SetCode(SDK::CrDevicePropertyCode::CrDeviceProperty_DateTime_Settings);
    prop.SetCurrentValue((CrInt64u)(result));
    prop.SetValueType(SDK::CrDataType::CrDataType_UInt64);

    SDK::SetDeviceProperty(m_device_handle, &prop);
}

And it worked!

In addition, when looking at the datetime on the camera's screen (in settings), it won't work.

The camera settings menu needs to be closed.