Weird URI string displayed on mounting iPod - linux

I have written a small program to detect whenever a device is mounted on a desktop running Linux. I have used GIO for this. I am extracting the URI of the mounted resource and displaying it to the user. When I put in a CD I get a URI string which looks like file:///media/cdrom0/ which I can understand. But when I mount an iPod the URI I see is something like gphoto2://[usb:002,028]. What does this mean? I have observed that the second number (028) keeps increasing every time I take the device out and plug it back in. Can some one interpret this URI for me?
Update: As shodanex answered, the two numbers are the bus number and device number respectively. gphoto2:// indicates the protocol (PTP/MTP).

gphoto2://[usb:002,028]
I guess 002 is the bus number, and 28 is the adress of the device on that bus.
It maps to the second and fourth field of the lsusb util output. Here is an example
on my system :
Bus 001 Device 015: ID 05e3:0715 Genesys Logic, Inc. USB 2.0 microSD Reader
I guess it would translate to :
usb:001,015

I have these kinds of URL's in Nautilus too, but the other response doesn't explain how that relates to a mount location on disk. I can navigate through the files on an SD card via the Nautilus file browser, but I don't see any of these files in /mnt/ or /media/ or anywhere else I would typically look for automatically mounted file systems.
Eventually I tried right-clicking the folder, selecting "Open with other application," choosing a text editor, and then I could see that the folder was actually mounted at:
'~/.gvfs/gphoto2 mount on usb%3A001,010'
I wish Nautilus and other tools in ubuntu would provide some more obvious way to find these files... this seems pretty un-intuitive.

Related

Unable to validate syslinux.cfg syntax

I am trying to boot an appliance to a USB drive and the provided configuration file for the syslinux.cfg file seems to have some error in it. Is there any way to validate a syslinux.cfg file and its syntax or anyone smart on here that might be able to check why this seems to not work? After booting, we received the following error:
SYSLINUX 4.04 EDD 2011-04-18 Copyright (C) 1994-2011 H. Peter Anvin et al
Unknown keyword in configuration file: 1
No DEFAULT or UI configuration directive found!
boot:
This is the configuration we have inside the syslinux.cfg file. I've tried multiple formatting options of my USB drive, including FAT32 and FAT16. I've tried renaming folders as prescribed by other articles (although I don't think there is a file referencing issue, because, because otherwise how would it know that there is an unknown keyword in the configuration file?).
SERIAL 1 38400 CONSOLE 1 default vmlinuz0 initrd=initrd0.img root=live:CDLABEL=LIVE rootfstype=vfat ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 serial text console=ttyS1,38400n8
We are following instructions from a vendor on how to boot to a USB to recover this appliance, but I don't get the strong feeling that they understand what's going on, so I thought I'd see if anyone could weigh in on why it cannot find a DEFAULT or UI configuration directive, despite the "default vmlinuz0" line being right there.

Persistant name in usb device which open several connections || connect USB to specific port [duplicate]

This question already has an answer here:
Change default names for USB virtual serial ports in Linux
(1 answer)
Closed 5 years ago.
I am trying to add a persistent name to a USB device connection to be able to connect to it by writing /dev/multitech instead of /devttyACMx. I have been able to do so with other devices by adding an udev rule, for example:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="0021",ATTRS{serial}=="356136967675473", SYMLINK+="multitech"
The problem is that this device open 6 connections, from ttyACM0 to ttyACM5 (if nothing else connected) but to use it you have to use the ttyACM0 (meaning the first connection) but if you write:
$ ls -l /dev/multitech
you may get whatever connection it has open, maybe ttyACM0 or maybe ttyACM3... the thing is that this is useless for me, since it sometimes works and sometimes it does not. Is there anything I can do about this?
Thanks a lot!!
normally each connection the device establishes has its own interface or alternate setting in USB tree structure. in udev rules you can use several other attributes (all you can display using udevadm info --attribute-walk http://www.beyondlogic.org/usbnutshell/usb5.shtml#InterfaceDescriptors )
run an attribute walk with udevadm info --attribute-walk + /sys/class/... or /dev/... path for your device to see the identifiers of the several usb interfaces it has in its usb structure and try to include them in the udev rule, i.e. using the following attributes:
ATTRS{bAlternateSetting}=="..."
ATTRS{bInterfaceClass}=="..."
ATTRS{bInterfaceNumber}=="..."
ATTRS{bInterfaceProtocol}=="..."
ATTRS{bInterfaceSubClass}=="..."
try to assign a specific /dev/ttyACMx for any interface the device has in its usb structure and try to assign the top-level interface in the usb structure to /dev/ttyACM0 ...
http://weininger.net/how-to-write-udev-rules-for-usb-devices.html
Change default names for USB virtual serial ports in Linux
This post was the solution to my troubles, instead of using the /devttyACMx
y changed to used the names in /dev/serial/by-id/
up until now it has worked fine, if it stops doing it I will post it

Linux: device appears in /dev but cannot be accessed

I have created a Linux device driver and can add it to the system (insmod, mknod). When I look in /dev I see it listed as camerax:
ls -l /dev/camerax
crw-r--r-- 1 root root 245, 0 Jun 27 17:19
Even so, I cannot access it. Whatever I do, I get an error.
For example:
int fd = open("/dev/camerax", O_RDONLY);
printf("%d [%s]\n", fd, strerror(errno));
Generates:
-1 [No such device or address]
I'm running as a super user. Any suggestions?
Your Module is not linked to the special file which you have mentioned so it is giving error.
If your module is successfully inserted verify in /proc/devices using cat command
cat /proc/devices.
file created using mknod in the path /dev/____ is just a refrence to your driver
The major and minor number should match with your inserted device.
I have solved the problem.
Instead of creating the major device number dynamically, as described in the documentation, I now set it explicitly to 61. Everything now works.
The only difference I can see between the working and non-working versions is the major number (and yes, I change anything that uses the device number so I am always using the appropriate one).
This adds one more bizarre feature of the system to my growing list.

How to determine OS Type while Mass storage Driver is enumerating

I would like to find the host OS while enumerating and select only the corresponding OS image file with the mass storage driver.
For example:
"insmod g_mass_storage.ko file=/win.iso,mac.iso"
While executing the above command, when the device is attached to WINDOWS, i need to show up win.iso instead of exposing mac.iso.
The command should look like "insmod g_mass_storage.ko file=/win.iso"
While executing the above command, when the device is attached to MAC, i need to show up mac.iso instead of exposing win.iso.
The command should look like "insmod g_mass_storage.ko file=/mac.iso".
I would appreciate any other thoughts/work around to this problem.

QFileDialog doesn’t list tty* files in /dev/ on Linux

I’m working on a Linux desktop application that needs to open a USB serial port, typically /dev/ttyUSB0 or /dev/ttyUSB1. I’m using QFileDialog to let the user select the file:
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setFilter(QDir::System | QDir::AllEntries | QDir::Hidden);
dialog.setViewMode(QFileDialog::Detail);
QStringList fileNames;
if (dialog.exec())
fileNames = dialog.selectedFiles();
When I direct the FileDialog to /dev, none of the files that I can see by typing “ls /dev -al” are there. The directories show up, but for example, this file doesn’t:
$ ls -al /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 2011-10-09 10:47 /dev/ttyS0
My user is a member of the dialout group:
$ groups
luke adm dialout cdrom audio video plugdev users fuse netdev bluetooth lpadmin admin sambashare
I’ve tried adding QDir::Readable and QDir::Writable and the above file still doesn’t show up. What am I doing wrong?
It amazes me how often people don't answer the question that was originally asked. I'll try not to do that here, if I can. I've done some homework on this problem since I'm having exactly the same issue. The short answer is that you can't use QFileDialog to reliably list and select nodes in "/dev". When you set the "QDIR::System" bit in the QFileDialog Filter using QFileDialog::setFilter(QDIR::System), you would expect that all the files in /dev would show up, but they do not. Admittedly, there are more entries than when it is not set, but most of the device nodes are still not displayed. It is clear that QFileDialog is doing some additional filtering behind the scenes, and that this filtering cannot be turned off in any obvious way.
On the other hand, if you use the QDir class with the QDir::System filter bit set, then in fact all of the /dev entries do appear in the entryList. For example, assuming that you already have a QComboBox named TTYDevices in your user interface, try something like this:
DevDir=new QDir("/dev","tty*",QDir::Name,QDir::System);
ui->TTyDevices->addItems(DevDir->entryList());
Then use the standard signals from QComboBox to detect and act on selection of the desired device node. By the way, ui is the standard Qt pointer to the instance of your parent window class and should be set up in the Window's constructor. Just make sure that you don't reference it before the constructor calls ui->setupUi(this). If you do, the program will crash.
This trick provides identical functionality to QFileDialog, with the additional features provided by accessing the QDir object directly. It does mean that you cannot easily have the same familiar, uniform interface provided QFileDialog, but it works and is remarkably easy to code.

Resources