Apertus (GSOC - 2019)
View Code

About

Control daemon is a central place to control cameras parameters and functionality inside the AXIOM Beta Linux Operating System. Current implementation is done as systemd daemon, written in C++. Communication is done via Unix Domain sockets and flatbuffers is used to minify packages. Current endpoints to communicate with daemon are: command line interface (CLI), which allows to send commands from shell and Web Remote, a HTML UI which can be used from smartphones or tablets.

Overview of work Done

The work done can be segregated into the following :

Creation of Adapters

SysfsAdapter

  • Done :

    This is a simple adapter created to read from /sys/fs location . Used currently by Environment Module which is used to give information about the voltages and temperatures of systems

  • Scope :

    -

  • Code

I2CAdapter

  • Done :

    This is used to get and set i2c registers values. There are 2 versions of it .One that has a dependency of SMBUS , and one without it . Both have been tested to work fine .This was created so as to mimic to `i2c.func` file in the scripts. Currently the options made available using this are byte `b` and word `w` operations .

  • Scope :

    This module can be exapanded to enable options like `c`,`p` mode etc if required (Reference : https://linux.die.net/man/8/i2cget)

  • Code

Memory Adapter

  • Done :

    This is a Adapter which is used to map memory using `mmap`. This was already in place when coding period was started. WriteWord was updated to correctly write values to the required register.

  • Scope :

    -

  • Code

Modules

CMV12000 Module

  • Done :

    This module is used to interact with the CMV12000 sensor using the MemoryAdapter. This was already in place when coding period was started. `SetAnalogGain` function was updated according to the `set_gain.sh` script.

  • Scope :

    This Module can be extended to add aggregated functions like `SetAnalogGain` to acheive a certain functionality. (Reference : "https://docs.google.com/document/d/1avhqneK2whvau_XBEGza_ujum8SB4EgMCl6i5aC9e18/edit#")

  • Code

Environment Module

  • Done :

    This is a module that mimics the `zynq_info.sh` file . This gives us the temperature and voltage results of various zynq_sensors of the module using the SysfsAdapter.

  • Scope :

    This Module should be extended to make it a central place for getting information about all the sensors in the camera.

  • Code

I2CHelper Module

  • Done :

    This is a module that enables the setting and getting the i2c registers via the endpointes (DaemonCLI and WebUI {Has to be updated}) using the `I2CAdapter` . Currently the byte and word operations are allowed .

  • Scope :

    This module can be exapanded to enable options like `c`,`p` mode etc if required (Reference : https://linux.die.net/man/8/i2cget).

  • Code

I2CTest Module

  • Done :

    This module mimics the `pac1720info.sh` script. This gives information of various pac1720 sensors on the power board.

  • Scope :

    This module was primarily created for testing with I2CAdapter . This module should be either renamed to something like `Pac1720InfoModule` or be merged with `Environment Module`.

  • Code

LutConf Module

  • Done :

    This module uses the MemoryAdapter to set the LUT config values . Reference (Add LUT register overview)

  • Scope :

    This module is highly dependent on the format of the file in which LUTConfig Values are used. Hence it has to be updated if the format of LUT values is changed. Currently it relies on the the structure that every newline has one LUT value .

  • Code

Message Packet Restructuring

  • Done :

    As a result of adding different types of control for camera parameters , It was required that we have different packets for different types of controls (as there were different number and types of parameters to process each type of request ). As of now there are three different types of packet structures.

    1. Basic Packet : Currently used only for CMV12000 sensor
    2. I2C Packet : Used for setting and getting I2C registers
    3. Blob Packet : Used for setting LUT config values
  • Schema

Unit Testing

  • Done :

    The work done concentrates on testing individual functionality of the Modules.The current implementation involves testing CMV12000 Module and the I2CAdapter.

  • Scope :

    This has to be extended to every module. Integration testing has to be done.Since most functionality of the Adapters/Modules involve reading or writing data(Ex Reading sensor temperature which is dynamic) ,it might be difficult to Unit test these functionalities. This can be solved using Mock objects , or to test these parts with integration testing.

  • Code

Minor Changes

  • During the work Adapters and Modules were segregated. Hence the work of interacting with the Camera sensor registers and filesystem is done by Adapters, whereas the Modules use the Adapters to achieve certain tasks. For ex the SetAnalogGain function in CMV12000Module uses MemoryAdapter to read write certain registers.

  • The Flatbuffer `_builder` was not cleared when the request was sent . Hence added `_builder.clear()` to clear it.

  • The WriteWord function was modified to clear the original value of the register using `ptr[reg] &= ~0xFFFF` and then setting the desired value using `ptr[reg] |= val`

Further Scope/TODO

  • High Priority :

    The current packet structure ,specially the blob part has to be tested to check if sending large size blob packets(ex LUT config file) is safe for Daemon Communication.

  • Other :
    1. The project has 2 end points to communicate with namely DaemonCLI and WebUI. The current state of webUI has to be updated according to the latest work done. This requires updating the WebUI itself and the MessageHandler. Since there are different types of messages (Packets) that have to be sent to Daemon ,a generic JSON structure for sending request has to be decided upon . Work is in Progress for this part.

Code Flow