Skip to main content

Camera Control

5 minutes, 38 seconds

cmd_gen Camera Control Utility

The camera processor uses a utility cmd_gen to for control of parameters form the TX1.  The utility talks over /dev/ttyTHS1 between the camera processor and TX1.

The cmd_gen utility requires the use of libafw_zlog.so and libpal.so files to operate.

Camera uses protobuf-c library to create and pack (serialize) messages and then send them using RLP protocol over UART port. This is accomplished using the cmd-gen utility.  These must be located in the same directory.

It can be executed as follows /cmd_gen -d /dev/ttyTHS1 -i

When in the utility you can use the ‘help’ menu to go through the different command options.

There are 3 types of message implementations:  Commands, Status, and Notification

Commands

Commands are sent by Drone to Camera. The complete list of commands are listed below

IdNameProtocol Buffers nameProtocol Buffers parameters
1.       Report camera status“camera_status”
2.       Enable/disable EIS“enable_eis”eis_config
3.       Enter idle“enter_idle”
4.       Enter video view“enter_video_view”view_config
5.       Still capture“capture”still_capture_config
6.       Factory“factory”factory_config
7.       Format SD card“format”
8.       Report FW version“fw_ver”
9.       Send metadata“metadata”metadata_config
10.   Power off“power_off”
11.   Reboot“reboot”
12.   Report SD card status“sd_stat”
13.   Report serial number“serial_number”
14.   Set Time“set_time”set_time_config
15.   Start video record“start_record”
16.   Stop video record“stop_record”
17.   Capture Picture-In-Video“piv”
18.   FW upgrade“upgrade”
19.   USB Mass Storage mode control“usb_ms”usb_ms_enable
20.   Set HDMI mode“set_hdmi”hdmi_config
21.   Move ROI“move_roi”roi_transition
22.   Abort ROI movement“abort_roi_movement”

The enter_video_view command has the single parameter mode, which value should be one from the list of supported modes shown in the table below

IdModesDescription
1.       1440p302560×1440 at 30 fps, landscape orientation
2.       1080p301920×1080 at 30 fps, landscape orientation
3.       4Kp30portrait2160×3840 at 30 fps, portrait orientation
4.       1080p30portrait1080×1920 at 30 fps, portrait orientation

The set_hdmi command has the single parameter mode, which value should be one from the list of supported HDMI modes shown in the table below

IdModesDescription
1.       720p601280×720 60fps
2.       720p301280×720 30fps

State Machine

During operation, at any particular moment the Camera can be in one of the states listed in the table below

IdName
1.       Idle
2.       Video Live View
3.       Video Capture
4.       Firmware Upgrade

Due to SOC and design constraints, any command may be restricted to be executed only in one or more states. For example the format command can be accepted only in “Idle” and “Video Live View” states, while fw_ver can be accepted and executed in any state. If the command the Drone sends to the Camera is not allowed in current state, the camera will return “error” status with “Command not allowed” error code.

Statuses

Status is a special Protocol Buffers message containing result of command execution. One status message is returned for every received command.

Status messages are sent by Camera to Drone and never send by Drone to Camera.

For blocking commands status is returned only after the command is being executed, for non-blocking commands status is returned immediately after processing the command even if corresponding action is not completed yet.

Any command may return one of the following statuses to Drone:

–          “ok”;

–          “error”.

When “error” status is returned, an additional error code is provided. For complete list of error codes see the table below

IdNameProtocol Buffers nameDescription
1.       Command not allowedcommand_not_allowedCamera module received command that is not valid for current state
2.       File errorfile_errorGeneral filesystem error
3.       Invalid mediainvalid_mediaSD card could not be mounted
4.       Unsupported mediaunsupported_mediaSD card speed class or size are not supported. Camera module supports only SD cards with speed class 10 and above and size 8Gb and above.
5.       Invalid parameterinvalid_parameterOne or more given command parameters are not valid
6.       No SD cardno_sd_cardSD card is not present
7.       SD card is fullsd_card_is_fullNot enough free space on SD card
8.       Unknown errorunknown_errorOther unexpected errors
9.       Unknown commandunknown_commandCamera does not support received command
10.   Pending operationpending_operationCamera has some operations to be done

Notifications

Notification is a special Protocol Buffers message designed to notify the Drone about some Camera events. In most cases it is to notify the Drone about completion of non-blocking command. In addition, the Camera may notify Drone when SD card status (inserted/ejected) changes. For complete list of the notifications that camera may send to Drone see the table below

IdNameProtocol Buffers nameDescription
1.       Boot doneboot_doneThe camera has just booted and ready to process incoming commands. This message contains one integer parameter “protocol_version” – protocol version ID the camera was built with.
2.       File errorfile_errorFilesystem error
3.       SD card ejectedsd_card_ejectedSD card has been ejected
4.      SSD card insertedsd_card_insertedSD card has been inserted
5.       SD card is fullsd_card_is_fullNo more space of SD card left to save video file
6.       SD card is too slowsd_card_too_slowSD card is not fast enough to save video in real time
7.       New file creatednew_file_createdDuring video recording, new Video or Metadata file was created. This message has one string parameter new_file_path which contains path to newly created file relative to SD card root directory. Example: “DCIM/100DRONE/TEAL0001.MP4”
8.       Fw upgrade completedfw_upgrade_completedFW upgrade was successfully performed and Camera is about to reboot.
9.       FW upgrade failedfw_upgrade_failed“firmware.bin” file was found on SD card, but FW upgrade failed by some reason
10.   FW upgrade file not foundfw_upgrade_file_not_foundFW upgrade failed because “firmware.bin” file was not found on SD card

Executable and Script Examples

This is the cmd_gen executable – cmd_gen_linux_aarch64

These are several video script examples – video_script_examples

  • video_Landscape_record.sh This script will set the TX1 live view stream to 720p30, SD card video to 1440p30 landscape and start to record to the SD card
  • video_not_stabilized_record.sh This script will set the TX1 live view stream to 720p30, SD card video to 4Kp30 portrait and start to record to the SD card
  • video_landscape_EIS_move_ROI.sh This script will set the TX1 live view stream to 720p30, SD card video to 1440p30 landscape, enable EIS (Electronic Image Stabilization), and show an example of electronically tilting to move the ROI (Region of Interest)
  • video_landscape_capture.sh This script will set the TX1 live view stream to 720p30, SD card video to 1440p30 landscape and take a full frame (12MP) still image

Was this article helpful?