-
Notifications
You must be signed in to change notification settings - Fork 64
Lepton CCI through UVC extension units
The Lepton CCI interface is available though UVC extension units starting with release 0.99.2.
There are 5 extension units defined, unit IDs 3..7 map to lepton modules AGC, OEM, RAD, SYS, and VID, respectively.
VC_CONTROL_XU_LEP_AGC
guid: 2d317470-656c-2d70-6167-632d30303030
unit id: 3
VC_CONTROL_XU_LEP_OEM
guid: 2d317470-656c-2d70-6f65-6d2d30303030
unit id: 4
VC_CONTROL_XU_LEP_RAD
guid: 2d317470-656c-2d70-7261-642d30303030
unit id: 5
VC_CONTROL_XU_LEP_SYS
guid: 2d317470-656c-2d70-7379-732d30303030
unit id: 6
VC_CONTROL_XU_LEP_VID
guid: 2d317470-656c-2d70-7669-642d30303030
unit id: 7
Within each of those extension units, control IDs 1..N are assigned to each register within the module, where N is the number of registers in the module, with a N=255 limit for each module (not encountered).
Some pseudo-code for taking a register like LEP_CID_SYS_SHUTTER_POSITION and computing the unit and control ids:
lepton_cci_reg = LEP_CID_SYS_SHUTTER_POSITION
switch (lepton_cci_reg & 0xff00)
...
case LEP_CID_SYS_MODULE: // you must define this, note weird base for OEM module
unit_id = 6
...
control_id = ((lepton_cci_reg & 0x00ff) >> 2) + 1
- Each control responds to GET_LEN/MIN/MAX/INFO/DEF/CUR, and SET_CUR.
- GET_MAX values for struct parameters return 0xff * LEN
- GET_DEF returns the same value as GET_CUR (the current value)
- Lepton CCI Run commands are implemented as 1-byte controls. To run a command, instead of setting a parameter, issue a SET_CUR with a length of 1 and any 1-byte data (it will be ignored). This works for any register, including and not limited to the few that are actually overloaded. A GET_* request with a length of 1 has undefined behavior.
1-, 2-, and 4-byte controls can be mapped to V4L2 using uvcdynctrl on Linux. Here is a control mapping xml so that the controls can be accessed via guvcview (or other programs that support arbitrary user-defined V4L2 extensions):
https://github.com/groupgets/purethermal1-uvc-capture/blob/master/v4l2/uvcdynctrl/pt1.xml https://github.com/groupgets/purethermal1-uvc-capture/blob/master/v4l2/uvcdynctrl/load.sh
uvcdynctrl's raw control functionality (through libwebcam) works to get/set the longer, more complex structures (as string mapping UVC controls to V4L2 extensions isn't implemented in the Kernel). The command-line interface for this is pretty awkward, but proves these will work on Linux. Some basic testing has been done on OS X through libuvc and qtkit with success there as well (including for long structures). Work on Windows here will be left as an exercise for the reader.
Known bugs / WIP:
- GET_MIN always returns 0x00 * LEN, which is OK for 99% of controls, except for a couple enumerations that accept negative values. This shouldn't affect your ability to actually set these values as long as your OS does not restrict you from doing so.