USB2.0_UC-391_Rev.E + DVP/MT9J003 works on Windows but fails on Jetson Nano

Hi,

I just got 4 cameras attached to the Jetson Nano via USB2.0_UC-391_Rev.E boards. Using the corresponding config “DVP/MT9J003*.cfg” versions it works well on Windows via the “USBTest.exe” file (tried all 4 cameras connected via a usb 3.0 hub and also “directly attached”).

On my Jetson Nano I try to execute “ArduCam_Py_Demo.py” with Python 3.6.9 64Bit but only receive:

color mode 3
open fail,rtn_val =  65281

Which means ArducamSDK.Py_ArduCam_autoopen() failed.

Is there a way to identify what exactly fails / what is missing?

I prepended

    cam_count, indexs, serials = ArducamSDK.Py_ArduCam_scan()
    print("Camera count %i" % (cam_count))
    print("FmtMode", FmtMode)
    print("Size: %i x %i. Bit width=%i, color mode=%i" % (Width, Height, BitWidth, color_mode))

to check if it sees the cameras etc.

Output of the execution contains this then:

Camera count 4
FmtMode 0
Size: 1280 x 720. Bit width=8, color mode=3

(using the 720p config file as test - all others fail too but work on Windows(10) ).
I also tried to open a specific camera by “index” - with the same result.

Any ideas on what to do to make it work?

Thanks in advance
Ronny

hi, @GWRon

You can add “sudo” before running program commands

Hi @yang,
Thanks for your suggestion.
I tried “sudo” on some customized stuff and it still failed.

I then run the original “ArduCam_Py_Demo.py” with sudo - and it worked (so thanks here for that).
So I tried to find out what was the difference:

Adding ArducamSDK.Py_ArduCam_scan() before ArducamSDK.Py_ArduCam_autoopen(cfg) leads to the error code (failed to create the camera connection).

    # add this line:
    cam_count, indexs, serials = ArducamSDK.Py_ArduCam_scan()

    #ret,handle,rtn_cfg = ArducamSDK.Py_ArduCam_open(cfg,0)
    ret,handle,rtn_cfg = ArducamSDK.Py_ArduCam_autoopen(cfg)
    if ret == 0:
       
        #ArducamSDK.Py_ArduCam_writeReg_8_8(handle,0x46,3,0x00)
        usb_version = rtn_cfg['usbType']

So for me the “scan” command seems to do something which makes opening the camera faulty.

Edit: just for completeness: after the “scan” it would also fail to explicitely open a specific camera with ArducamSDK.Py_ArduCam_open(cfg,0) (or (cfg, 1) as your docs show.

Can you replicate that?


Second question:
What needs to be changed (some rules.d? addding the user to which groups?) to avoid requiring sudo?

Seems if you use

    cam_count, indexs, serials = ArducamSDK.Py_ArduCam_scan()

you need to wait a while until you can open a camera.

   cam_count, indexs, serials = ArducamSDK.Py_ArduCam_scan()
    time.sleep(1)
    #ret,handle,rtn_cfg = ArducamSDK.Py_ArduCam_open(cfg,1)
    ret,handle,rtn_cfg = ArducamSDK.Py_ArduCam_autoopen(cfg)
    if ret == 0:

works.

hi, @GWRon

You can download the arducam.rules file and place it under the /etc/udev/rules.d folder.

Arducamsdk.py_arducam_scan () This method has done the following:

  1. Open the camera
  2. Get information
  3. Turn off the camera

When you use this method, you cannot call the Open method immediately to open the camera, you need to add a delay in the middle.

Maybe this information (scan requires delay) should be added to the API docs.

Thanks for your help.


To to sum up the solution:

  • download arducam.rules from your post
  • add arducam.rules to /etc/udev/rules.d/[arducam.rules] and re-plug the cameras (so rules take effect)
  • add a time.sleep(1) after you used ArducamSDK.Py_ArduCam_scan()

Alternatively arducam.rules content is (for now):

SUBSYSTEM=="usb", ATTRS{idVendor}=="52cb", ATTRS{idProduct}=="52cb", MODE="0777"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="52cb", MODE="0777"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="03f1", MODE="0777"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0c45", MODE="0666"

hi, @GWRon

Thank you for your summary, we will optimize the document.