how to give permission to intel realsense camera on Ubuntu - linux

OS:Ubuntu 18.04
camera: Intel realsense D415
I can use cheese to show the compound image of the camera. But when I run
import pyrealsense2 as rs
pipeline = rs.pipeline()
pipeline.start()
It throws out error access failed for 8086:ad6 uid: 1-1-12
Is anyone that knows how to solve this? Thanks!

You need to install Intel Realsense permission scripts located in librealsense source directory.
For that, first, git clone the librealsense to a local folder
git clone https://github.com/IntelRealSense/librealsense
Next, run the following commands to copy the 99-realsense-libusb.rules files to the rules.d folder
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
And, then udevadm control to modify the internal state of the running udev dameon to reload rules. Also, udevadm trigger to request device events from the kernel.
sudo udevadm control --reload-rules
sudo udevadm trigger
Update: I recently faced the Runtime error: backend-v412.cpp:988 - Frames didn't arrived within 5 seconds. Seems like the pipeline is not able to handle the framebuffers, and there is quite a lot of drop in the frames, specifically above 720p, 15 frames/sec.
Any resolutions?
Update 2:
Resolution: As suspected it is a pipelining issue w.r.t the amount of the data the USB port can carry. To prevent frame drop or overload of data through the USB, it has to be connected to a Motherboard that has USB 3.1 Gen 1 specifications. Refer to page 78 of this document https://www.intelrealsense.com/wp-content/uploads/2020/06/Intel-RealSense-D400-Series-Datasheet-June-2020.pdf

Related

Serial port unavaliable arduino

Trying to upload a code to arduino, but whether in the Arduino IDE or Arduino Create, both return this erro while uploading. Running on Linux Tara(mint 19 cinnamon).
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega2560 -build-cache /tmp -build-path /tmp/716441957/build -verbose -libraries /tmp/716441957/custom -libraries /tmp/716441957/pinned /tmp/716441957/sketch_oct8a
Sketch uses 8280 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 443 bytes (5%) of dynamic memory, leaving 7749 bytes for local variables. Maximum is 8192 bytes.
Programming with: Serial
Flashing with command:/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude -C/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino-create-agent734074237/sketch_oct8a.hex:i
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
1#
First, check the port in your IDE. In Arduino tools->port
If the port is hidden or you can not move the cursor over this then run this commands in your terminal.If everything ok then skips this and follow the second part.
sudo apt-get install librxtx-java -y
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
2#
After this again check the first method. If it is not working then run this commands
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>
You probably have another program running which is already using this port.
You should close most other programs like putty or another serial monitor app.
Otherwise, try to reconnect the Arduino to the PC.
I know that these ideas below come from using a Teensy, but they may help you.
Sometimes there are the ACM* ports listed in the Arduino IDE. Try looking at the ser ports. I know when I am running my Teensy, sometimes I have them switched and need to select the correct one.
Also, from my experience with the Teensy, you might need to add a udev rule to allow permissions to access the port from non-root user. Here is the link that shows the udev file.
There is no direct way to solve this issue. In addition to it, you are not using an IDE. I will list the things you need to check, I am sure this will solve your problem.
I am not good at Linux environment so I will refer to applications names as window, you go the corresponding application in Linux.
Go to linux device manager and see for your arduino board. It should have proper naming like "arduino uno at port 3", then use the correct port in your command. If this name does not come properly then it means Driver is not available in your machine. So, go to step2.
Find the driver online and install it in your system, I am not sure about the support of linux with arduino, once it is done please repeat step1.
So, I conclude in short that you do not have the proper driver (which is strongly believe) or pointing the wrong port. I am not an expert with the udev rules, but it is definitely an issue you can experience with these kinds of micro-controllers.

libusb calls without sudo using udev-rules

Tested on Kubuntu 16.04 64 bit only. I have an application which source is not under my control. It uses some libusb calls which ends up in e.g.:
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/031: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
When running the above mentioned application as root, it works as expected.
When I change the permissions of the regarding file like:
sudo chmod a+w /dev/bus/usb/001/031
then the application will work with standard user rights (until I disconnect / reconnect my usb device).
Now I'm looking for a way, to e.g. automatically execute the chmod a+w each time when the specific usb device is plugged in.
Might this be possible by writing a specific udev rule?
Maybe other solutions the libusb calls without root rights?
Solution: Based upon David Grayson's answer, I'd now added an additional line with SUBSYSTEM=="usb" to my rule file. My rules file now finally looks like this:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
I suggest that you add a new file in /etc/udev/rules.d named usb.rules. It should have the following contents:
SUBSYSTEM=="usb", MODE="0666"
This will make all USB devices readable and writable by all users.
You could also narrow it down to specific USB devices using idVendor and idProduct attributes mentioned in Ignacio's answer.
Assuming Kubuntu 16.04 uses PolicyKit, put the following in a file in /etc/udev/rules.d, naming it similarly to the files that already exist there:
ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="xxxx", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
Replace the two sets of "xxxx" with the vendor ID and product ID of the device respectively.
Oldie but goldie. Help me to solve my issue with sharing the usb with virtual machines under AQEMU. Thanks a lot.
I added to the /etc/udev/rules.d file usb.rules with this line
SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
and virtual machine can see USB stick being connected life.

Run command after mount/unmout usb pen drive

I have Raspberry Pi (with Raspbian) and using it as DLNA/UPnP server and renderer. I run minidlna as DLNA server and i have some media files on USB.
I would like to automaticaly rebuild DLNA DB when drive is mounted and unmounted. This is done by command:
sudo service minidlna force-reload
Is threre any way how to autorun this command?
BTW I use "USBmount" package for automount USB drives.
Thanx
You can do this using the tool usbmount.
It has the possibility to add scripts that will be run on mount/umount events in /etc/usbmount/mount.d/ and /etc/usbmount/umount.d/.
Start by finding your device in lsusb. Note the ID (eg 12f5:a91a)
Create a new udev rules file in /etc/udev/rules.d/ eg /etc/udev/rules.d/100-my-mount.rules and write a new rule in there like this:
ACTION=="add", ATTRS{idVendor}=="12f5", ATTRS{idProduct}=="a91a", RUN+="/home/your_username/bin/my-mount-script.sh"
For unmounted device use ACTION=="remove" in rule and another script.

A2DP sink without pulseaudio

So I'm trying to make my linux server play music sent from my Android phone using bluetooth (the linux machine is the A2DP sink and the phone is the source).
What I have done so far is to:
install bluez and enable audiosource/audiosink
pair phone and server
connect to server from phone (phone says it's streaming audio over bluetooth)
But I can't hear anything. Also, most guides on the internet assumes Pulseaudio and I would prefer to use ALSA.
I currently have the following in /etc/asound.conf:
pcm.!default{
type bluetooth
profile "auto"
}
I'm running Bluez v4.99 and Alsa v1.0.25.
Any ideas?
I know this is an old post, but hopefully the answer is useful to people currently working on this.
You can use /etc/bluetooth/audio.conf, which is the system-wide file, or ~/.asoundrc, which is your local file. Both are read by BlueZ/ALSA. However, I think you need to include the MAC address in your config file, z.B.:
pcm.btheadset {
type bluetooth
device "XX:XX:XX:XX:XX:XX" #MAC address
profile "auto"
}
The best resources I've found for this are:
1) James B's blog post: Bluez must be one of the best kept secrets in Linux
He explains the structure and interface between BlueZ and ALSA, which I found nowhere else on the internet.
2) His second post with code: Bluez A2DP AudioSink for ALSA
3) The ALSA site, which introduces the structure of pcm plugins, but doesn't really explain them very well.
4) Some ALSA plugin tutorials: The ALSA wiki
Some useful commands:
$sudo service bluetooth restart
$sudo alsa force-reload
Run these after you change the asoundrc or audio.conf files.
Here you find a manual to configure bluetooth with ALSA or Pulseaudio:
-tested on Linux Mint 17.3 Mate, 64bit / Ubuntu 14.04 Mate, 64bit-
HOW TO MAKE ALSA AND BLUETOOTH WORK TOGETHER WITHOUT PA
This part is for pure ALSA-based systems without Pulseaudio like KXStudio, QStudio64,Tango studio..!
Be sure that Pulseaudio is deinstalled and your soundcards
configured right in ALSA!
delete pulse-audio cookies and files in
/home/USERNAME/.config/pulse
Modify your bluetooth-audio.conf:
type:
gksudo pluma /etc/bluetooth/audio.conf
Set
# This section contains options which are not specific to any
# particular interface
[General]
Enable=Socket
Save the file.
setup ~/.asoundrc file
type:
sudo hcitool scan
Scanning ...
XX:XX:XX:XX:XX:XX
Stereo Headset
Create a hidden-file named .asoundrc in your home-folder!and write:
pcm.!default {
type plug
slave.pcm {
type bluetooth
device "XX:XX:XX:XX:XX:XX"
profile "auto"
}
}
Replace “XX:XX..” with the adress of your device.
Save the file!
Run these after you change the asoundrc or audio.conf files:
sudo service bluetooth restart
sudo alsa force-reload
or reboot your computer!
———————————————————————————————————–—-
Go to your blueman-applet at your taskbar, search & setup your new device!
Note: Some bluetooth-devices need a passphrase (eg. 0000) by default
while some others takes shuffle-pairing.
Keep your found and paired device to “trust”!
Connect your device as AUDIO via A2DP!
————————————————————————————————————
If your device is connected with your system you can play sound with totem (gui), vlc (gui+terminal), mplayer (terminal), qmmp (gui), banshee and browsers over bluetooth while setting the output in players to “default”!
—————————————————————————————————–———
RENAME THE .ASOUNDRC IN HOME-FOLDER TO “.ASOUNDRC_OFF”
TO GET YOUR OLD SYSTEM-SETTINGS WITHOUT BLUETOOTH BACK!
type: mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF
->to disable the bluetooth-specific asoundrc
type: mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc
-> to enable it!
Alternative:
Make two “scripts” to activate/deactivate bluetooth with .asoundrc in your home-folder:
Create one empty file and write/paste:
#!/bin/bash
mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF
or:
#!/bin/bash
cd /home/USERNAME/
mv .asoundrc .asoundrcOFF
To activate your .asoundrc for bluetooth again, create another file with following entry:
#!/bin/bash
mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc
or:
#!/bin/bash
cd /home/USERNAME/
mv .asoundrcOFF .asoundrc
Make the files executable and run them with “open with terminal”!
Now you have two “buttons” to switch bluetooth-sound On or Off.
Give them individual-icons:
;-)
————————————————————————————————————-
PLAYERS
————–
It’s recommend to use totem, Qmmp or Banshee-player - because there is nothing more to do than
play and listen! Also totem-player shows videos too.
VLC-player needs the “default” sounddriver for bluetooth to working right!
Check in: /home/USERNAME/.config/vlc/vlcrc
that alsa-audio-device
in >>line1666<<
is:
# ALSA Device Name (string)
alsa-audio-device=default
Use this commands to use players with terminal:
To play music, type:
MPlayer
———––
mplayer /home/USERNAME/Musik/1.mp3
If you hear no sound or get errors try:
mplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3
VLC-Player
—————-
cvlc /home/USERNAME/Musik/1.mp3
vlc /home/USERNAME/Musik/1.mp3
rvlc /home/USERNAME/Musik/1.mp3
To add whole directories type:
rvlc add /home/USERNAME/Musik/
type: start/stop/next... to navigate!
or use the vlc-gui.
—————————————————————————————————–——-
To use mplayer with graphical-interface you have to install the gui-package:
type:
sudo apt-get install mplayer-gui
Open a terminal via Ctrl-Alt-T and use the commands below.Use the lines and type/copy one by one to avoid confusion(!):
cd /usr/share/mplayer/skins/default
for FILE in *.png; do sudo convert “$FILE” -define png:format=png24 “$FILE”; done
cd /usr/share/mplayer/skins; sudo rm default; sudo ln -s Blue default
———————————————————————————————————–
Now you can start the mplayer-gui without errors!
If you prefer the terminal type:
gmplayer /home/USERNAME/Musik/1.mp3
or
gmplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3
if you have problems!
terminal command without gui:
mplayer /DIRECTION/TO/FILE
Available Output-Modules and Drivers:
mplayer -vo help
———————————————————————-
BLUETOOTH WITH PULSEAUDIO
————————————————–--------
For Linux systems that comes with pulseaudio:
(1.) Edit /etc/bluetooth/audio.conf and uncomment the following line:
AutoConnect=true
Run the following command to install latest packages for blueman and related modules:
sudo add-apt-repository ppa:blueman/ppa
sudo apt-get update
sudo apt-get upgrade blueman
enter code here
(3.) Check if the following lines are added in /etc/pulse/default.pa:
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
If not, add the lines.
REBOOT!
Run the new blueman-applet.
Right click on the panel applet and turn bluetooth on.
The old profie of you bluetooth device would still be there, remove it.
Right click on the blueman-panel applet and select Setup New Device.
Complete the wizard for your device.(If you have problems with “pairing” restart your system and skip this step!)
Now you get a connected bluetooth device!
To send/hear audio over it just follow these 2 steps:
Open Mate-volume control-settings (or pavucontrol) with rightclick in taskbar,
browse to “HARDWARE” -
and use the dropdown to turn the Built-in audio profiles of all other soundcards “off”
so that the bluetooth-device gets active!
use the other dropdown to set the bluetooth device to use A2DP
Now start the totem-player or vlc (with pulseaudio-output) to send audio to bluetooth!
Enjoy your sound!
;-)
WLAN-ISSUES:
——————–—
In case you see a WiFi connection drop after connecting to the bluetooth device run the following
command:
$ echo “options iwlwifi 11n_disable=1 bt_coex_active=0 power_save=0 auto_agg=0 swcrypto=1” |
sudo tee -a /etc/modprobe.d/iwlwifi.conf > /dev/null
tested 2017 for LM 17.3 (Rosa) MATE and Ubuntu 14.04 by chalee:
http://mayastudio.tumblr.com/bluetooth
My guess is that your audio path isn't routing the bluetooth to your speakers. I have seen similar issue, which was fixed by manually doing step 5 "Connect PulseAudio bluetooth source to PulseAudio ALSA sink" from this link: http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/
I just tried to do the same thing, I'm using Fedora 19, so your mileage my vary. These are the steps I took.
Made computer discoverable
Pair phone to computer (it had a headphone logo next to it)
On my HTC phone I clicked "connect" on the pairing
Go into gnome3's sound settings
Go to the input tab
Select the bluetooth item for your phone
Maybe adjust volume...

Run something when USB device is plugged in doesn't work

I made a script in /etc/udev/rules.d/local.rules
SUBSYSTEM=="usb", SYSFS{idVendor=="b58e"}, SYSFS{idProduct=="9e84"}, ACTION=="add", RUN+="notify-send USB"
I then reload udev with
sudo udevadm control --reload-rules
I've tried to remove everything but subsystem and run. I've tried the run '=' instead of '+=', I've tired ATTR instead of SYSFS. I tried "sudo service udev restart" and "sudo reload udev". I unplug the device, then plug it in again and it does not run the action. I tried renaming it 70-local.rules and changing permissions to a+x. I've tried changing 'subsystem' to 'bus'. I've tried setting run to be "/path/test.sh" which has the same command.
I'm not an expert and this isn't an answer, but I've found the following steps useful in identifying the appropriate attributes to trigger on:
Locate the device path using udevadm, lsusb, or usb-devices. I normally just use lsusb and let tab completion in my shell guide me. In my case, the path is /dev/bus/usb/003/007.
Use udevadm to identify the device attributes for rule writing. In my case, I used udevadm info -a --attribute-walk --root --name=/dev/bus/usb/003/007.
Write the rule and check that it's triggering. In my case, I'm just changing the device owner to user "stephen" and it's very easy for me to check if it's working by using ls -l /dev/bus/usb/003/007. My rule for this case looks like: SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", OWNER="stephen". I have a similar rule that puzzled me for a little while because the subsystem was expecting ATTRS not ATTR, which is why I recommend walking the attributes. The rule in this latter case became: `SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", OWNER="stephen".
And, of course, man udev is always helpful. As you said, you should struggle to identify that your rule is triggering properly and may be best off just doing a quick ownership change on the device as I did for a first step. You can run into trouble with bad attributes or symbolic links sometimes and it's
it does not run the action
No, it runs the action. The problem is that it doesn't know where to send the notification, since there's no notification framework running when udev starts. You will need to send a DBus message across the system bus and have a user daemon catch the message and post a notification instead.

Resources