Camera Control

This section describes how to run the camera control demo script for the Sony-EV9520L. The below control script communicates with the camera over I2C via the SC16IS752 UART bridge and allows sending control commands during live streaming.

Download the Control Script

In Host PC, download the control_ev9520l.py script file from the download link below and copy it to the Jetson Orin Super Developer Kit:

Download Link: control_ev9520l.py

Note:

If file is not able to download, go through Full Script section below.

Install Dependencies on Developer Kit

Before running the script, install the required Python libraries on the Developer Kit. Open a terminal and run the following commands:

Dependency 1 — smbus2 :

pip3 install smbus2    # for i2c communication

Dependency 2 — pyserial :

pip3 install pyserial    # for serial communication
Run the Control Script

Once the dependencies are installed, navigate to the directory where the script was copied and execute it using Python3 in terminal

python3 control_ev9520l.py

The script initializes the SC16IS752 UART bridge over I2C bus 9, address 0x48, configures UART channel A at 9600 baud (8N1 format), and sends two sequential control command ZoomIn and ZoomOut to the Sony-EV9520L camera with a 4-second interval between them.

Script Overview
FunctionDescription
I2C InitializationOpens I2C bus 9, connects to SC16IS752 at address 0x48 (A0=A1=0)
UART ConfigurationConfigures UART channel A — 9600 baud, 8N1 format, FIFO enabled (14.7456 MHz crystal)
TX Ready CheckPolls Line Status Register (LSR) until Transmit Holding Register (THR) is empty and ready
Command Frame 1Sends 6-byte frame: [0x81, 0x01, 0x04, 0x07, 0x27, 0xFF] to camera via UART
DelayWaits 4 seconds between the two command frames
Command Frame 2Sends second 6-byte frame: [0x81, 0x01, 0x04, 0x07, 0x37, 0xFF] to camera via UART
Full Script
import smbus2
import time
 
bus = smbus2.SMBus(9)
I2C_ADDR = 0x48  # A0=A1=0
 
def write_reg(subaddr, data, channel=0):
    # Channel A: subaddr << 3 | 0x00
    bus.write_byte_data(I2C_ADDR, (subaddr << 3) | 0x00, data)
 
def read_reg(subaddr, channel=0):
    return bus.read_byte_data(I2C_ADDR, (subaddr << 3) | 0x00)
 
# Initialize UART A
write_reg(0x03, 0x80)  # LCR: Enable divisor
write_reg(0x00, 0x5B)  # DLL: 91 (9600 baud, 14.7456MHz crystal)
write_reg(0x01, 0x00)  # DLH: 0
write_reg(0x03, 0x03)  # LCR: 8N1
write_reg(0x02, 0x01)  # FCR: Enable FIFO
write_reg(0x01, 0x03)  # IER: Enable TX holding
 
# Verify LSR (Line Status Register) for TX ready
while not (read_reg(0x05) & 0x20):  # Check THR empty
    time.sleep(0.01)
 
# Send data
data = [0x81, 0x01, 0x04, 0x07, 0x27, 0xFF]
data1 = [0x81, 0x01, 0x04, 0x07, 0x37, 0xFF]
for b in data:
    write_reg(0x00, b)  # THR: Write byte
    time.sleep(0.01)  # Small delay for stability
time.sleep(4)
for b in data1:
    write_reg(0x00, b)  # THR: Write byte
    time.sleep(0.01)  # Small delay for stability