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
Id | Name | Protocol Buffers name | Protocol 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
Id | Modes | Description |
1. | 1440p30 | 2560×1440 at 30 fps, landscape orientation |
2. | 1080p30 | 1920×1080 at 30 fps, landscape orientation |
3. | 4Kp30portrait | 2160×3840 at 30 fps, portrait orientation |
4. | 1080p30portrait | 1080×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
Id | Modes | Description |
1. | 720p60 | 1280×720 60fps |
2. | 720p30 | 1280×720 30fps |
State Machine
During operation, at any particular moment the Camera can be in one of the states listed in the table below
Id | Name |
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
Id | Name | Protocol Buffers name | Description |
1. | Command not allowed | command_not_allowed | Camera module received command that is not valid for current state |
2. | File error | file_error | General filesystem error |
3. | Invalid media | invalid_media | SD card could not be mounted |
4. | Unsupported media | unsupported_media | SD 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 parameter | invalid_parameter | One or more given command parameters are not valid |
6. | No SD card | no_sd_card | SD card is not present |
7. | SD card is full | sd_card_is_full | Not enough free space on SD card |
8. | Unknown error | unknown_error | Other unexpected errors |
9. | Unknown command | unknown_command | Camera does not support received command |
10. | Pending operation | pending_operation | Camera 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
Id | Name | Protocol Buffers name | Description |
1. | Boot done | boot_done | The 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 error | file_error | Filesystem error |
3. | SD card ejected | sd_card_ejected | SD card has been ejected |
4. S | SD card inserted | sd_card_inserted | SD card has been inserted |
5. | SD card is full | sd_card_is_full | No more space of SD card left to save video file |
6. | SD card is too slow | sd_card_too_slow | SD card is not fast enough to save video in real time |
7. | New file created | new_file_created | During 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 completed | fw_upgrade_completed | FW upgrade was successfully performed and Camera is about to reboot. |
9. | FW upgrade failed | fw_upgrade_failed | “firmware.bin” file was found on SD card, but FW upgrade failed by some reason |
10. | FW upgrade file not found | fw_upgrade_file_not_found | FW 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