|
Hello
This is a follow-up on my previous post about “ln” commend.
I am trying to link “dev/ttytUSB0” with “dev/rfcomm0”.
I am doing something wrong and obviously not doing it in
correct sequence or using Linux commands wrong. .
I am using “ln” and “rfcomm” and get no response from both “ln” and “rfcomm”;
nov5-6@nov56-desktop $ sudo ln /dev/ttyUSB0 /dev/rfcomm0
[sudo] password for nov5-6:
nov5-6@nov56-desktop $ rfcomm –a
nov5-6@nov56-desktop $ \
When I run “ln” again I get this:
\nov5-6@nov56-desktop $ sudo ln -v /dev/ttyUSB0 /dev/rfcomm0
[sudo] password for nov5-6:
ln: failed to create hard link '/dev/rfcomm0': File exists
nov5-6@nov56-desktop $
If I use “rfcomm” it still returns nothing.
nov5-6@nov56-desktop $ rfcomm –a
nov5-6@nov56-desktop $ \
I am obviously missing something and I am asking the group for a solution.
Thanks, any help with solving thius will be much appreciated
|
|
|
|
|
It seems like you're still trying to connect /dev/rfcomm0 and /dev/ttyUSB0 together, so that a write to one will write to the other. As explained previously, that's not how a link works. Creating a link could be thought of as providing a different name for the same object. So for example, suppose you live at 42 Main Street. Creating a link is like adding the number 24 to your house. If you tell someone you live at 24 Main Street, or 42 Main Street, they find the same house, either way.
As far as I know, there's no way to multiplex 2 files together. At least not in the Unix/Linux world. Maybe Windows does this?
You do know that /dev in all but very old Linux systems is a virtual file system, and gets recreated every time you reboot? It's actually quite dynamic. For example as you plug-in and unplug USB devices, new /dev entries get added and removed as needed.
My other suspicion is that you're trying to create /dev/rfcomm0 incorrectly. when you ls a device file, you get something like crw------- 1 root root 4, 1 Sep 23 08:17 /dev/tty1 . The "c" at the start of the permissions string indicates its a character device, and 4, 1 indicate the MAJOR and MINOR device numbers. The major device number is, more or less, an index into the kernel's device driver table, and the minor is, once again more or less, the specific device to do I/O with. So in the case above, the MAJOR is 4, a console TTY device, and 1 is the tty number. Similarly /dev/tty2 has MAJOR,MINOR 4,2 etc. I'm guessing that /dev/rfcomm0 should be some sort of radio frequency communication device. As such it will have it's own MAJOR/MINOR assignments, almost certainly different from what a USB Serial device would have. Additionally, an rfcomm device will probably have its own set of ioctl calls that only make sense for that device.
So think about that, what happens if you could link devices together what should happen when you try to send an ioctl to one of them that the other does not recognize, via the multiplex? Should it silently fail on one, but succeed on the other? What's the return value? How would you distinguish which device had rejected the IOCTL call. Worse, an ioctl looks like ioctl(int fd, unsigned long request, ...) . So a request id (say 2) to one device might turn it on and to the other might put it in diagnostic mode.
I repeat, it's not quite clear what you are trying to do. If you need a /dev/rfcomm0 device file to communicate to your bluetooth device (e.g. a bluetooth dongle, maybe???) then you're going to have to figure out how to create that device file. Maybe see the man page for mknod? But maybe your bluetooth thingy has a serial port, and you connect to it via a serial USB port (/dev/ttyUSB0)? In that case, communications to/from it are going to be over the serial device, and you should have some documentation on what you need to send to /dev/ttyUSB0 to control the bluetooth thing. Or maybe the bluetooth thingy appears as a serial device when plugged in? In either case, it doesn't seem like the rfcomm command is going to be what you need, as it is probably scanning for /dev/rfcommX devices with the right major device number to communicate correctly to it.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Thank you for the reply.
I am not sure HOW to reply without offending, however, I have specifically asked for assistance in analyzing the posted commands. I need to keep this short, my new OS does not do spell
check...
However - the second usage of "ln" failed because the /dev/rfcomm0 WAS already build....
|
|
|
|
|
I have found that relaying on responses / return values of SOME Linux commands is not necessary.
Usually there are other commands where the result of the first command can be found, hence verified.
For example "ln -v /dev/ttyUSB0 /dev/rfcomm0" result can be verified using
"ls /dev/rf*"
|
|
|
|
|
It may help if you provide a long listing of thos devices:
ls -al /dev/tty*
ls -al /dev/rfc*
This would at least show how these two are currently assigned.
|
|
|
|
|
I do not get the symbol "->" .
I am trying to have serial port "ttyUSB0 " linked with rfcomm0.
Which command is correct ?
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/ttyUSB0 /dev/rfcomm0
[sudo] password for nov25-1:
'/dev/rfcomm0' -> '/dev/ttyUSB0'
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/rfcomm0 /dev/ttyUSB0
'/dev/ttyUSB0' -> '/dev/rfcomm0'
nov25-1@nov251-desktop:~$
|
|
|
|
|
It shows that the device name on the left is a link to the actual device named on the right. So when you send any data to /dev/rfcomm0 it will actually go to the device at /dev/ttyUSB0 .
|
|
|
|
|
Thanks,
would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ?
Now for the follow-up question - more (confusing_) Linux terminology.
physical, hard , symbolic ??
hence
" which way's up " ?
what would be the purpose of "symbolic" link ?
if there is no -s option , is the link "hard" ?
is "hard" == "physical" ?
-P, --physical
make hard links directly to symbolic links
-s, --symbolic
make symbolic links instead of hard links
Cheers
|
|
|
|
|
jana_hus wrote: would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ? Not really as the name on the left is just a node in the /dev directory tree, not an actual device. The link just associates one name with another. I have not looked at this for some time, but I think they are hard links. They are actually set up by the kernel when the system is initialised at boot time, based on the connected devices.
|
|
|
|
|
Way back, the UNIX filesystem only supported a physical link. So a directory entry might have been
struct dirent {
unsigned long d_ino;
char d_name[30];
}; So if your directory contained
8539501 foo
8539502 bar
8539503 baz
8539502 paw Then it should be clear that the files bar, inode=8539502 and paw inode=8539502 are the same file, i.e a Physical (or hard) link. If you list the directory you'll see something like
[k5054@azure foo]$ ls -li
total 0
8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar
8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz
8539501-rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo
8530502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 paw The -i flag to ls add the inode, and so we can see bar and paw have the same inode (8359502). Also, column 3 shows the number of physical links to the inode, which for bar and paw are 2, but foo and baz are only one. Note that a hard link doesn't need to reside in the same directory, you can for example do something like
ln foo/bar/baz ping/pong/paw , which will create the physical link. There are 2 restrictions to hard links: 1) you can't create a hard link between directories, and 2) you can't create hard links across file systems. Symbolic (soft) links solve both these problems. In the case of a soft link, the link can be thought of as a reference. If we take the above directory and create a soft link between foo and bang via
ln -s foo bang</pre> we now get: <pre>k5054@azure foo]$ ls -li<br />
total 4<br />
8539536 lrwxrwxrwx 1 k5054 k5064 3 Oct 13 06:48 bang -> foo<br />
8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar<br />
8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz<br />
8539501 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo<br />
8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 paw</pre> This shows that the file <code>bang is a symbolic link (file type "l") which points to "foo". Now "bang" acts as a pointer or an indirection. In order to get to the contents of <bang>, the OS has to open bang, read its contents and then open the file pointed to by the contents. Also, note that the size of bang is 3, ie "foo". Since we now have this indirection, we can link to files in other filesystems, and we can also create links to other directories. You're also not limited to only one indirection. A soft link can point to another soft link, to another soft link, etc.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Thanks, it is getting more "convoluted"...
Allow me to start over.
The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ".
Calling "/dev/ttyUSB0 " a node or device SHOULD be "technicality" - the task is still the same.
However,
the "link" option - "symbolic" or "hard /[physical " SHOULD make a difference as far as the task goes.
My , probably incorrect, interpretation is:
"symbolic" still accomplishes the task, but introduces another "intermediate process" - "pointer" etc.
"hard / physical " accomplishes the task directly
I do appreciate this discussion, very much, thank you.
|
|
|
|
|
jana_hus wrote: The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ".
In that case, the whole preceding discussion about links has been just a waste of time. You can't do that task with links. A link means a single object (file, device, directory, etc) can be accessed using multiple different names.
If you create a link from /dev/ttyUSB0 to /dev/rfcomm0, then anything written to either ttyUSB0 or rfcomm0 will end up in rfcomm0. If there was a physical device associated with the name /dev/ttyUSB0 before creating the link, it will be bypassed by the new link.
|
|
|
|
|
PLEASE
suggest alternative approach.
|
|
|
|
|
There is no alternative. You cannot link two nodes together and expect the system to send data to them as separate entities. Linking A to B means that A is B and vice versa.
|
|
|
|
|
If you want to send your data to two different destinations, you need to send it twice.
|
|
|
|
|
EDIT
Edited title.
<a href="https://github.com/orgs/bluez/discussions/categories/q-a">bluez Q A · Discussions · GitHub</a>[<a href="https://github.com/orgs/bluez/discussions/categories/q-a" target="_blank" title="New Window">^</a>]
This one is dead...
For all those OF's who recall the popular TV "quiz" show...
<b>I am looking for a way to identify - in Linux / <b>Ubuntu open source</b>
SPECIFICALLY
1) what database is used to keep track of result of
"scanning for remote Bluetooth device "
2) what database , if any, keeps track of recently used and valid ID # / authorization #</b>
I am NOT seeking the actual link / reference , I am asking for
current / actually copy of "bluez" library as adopted by Linux.
I am NOT asking for various implementation of " bluez" - such as "hci" etc.
I am NOT asking where to find "bluez" source code - there are plenty of copies of SAME, undocumented and UNSUPPORTED
of "bluez" library on many github files...
I know about flaky Python Bluetooth app -- no reference needed.
Just point me to REAL / USED / CURRENT (Aug 2024) "copy" of "bluez" - that is all I am asking.
as in Ubuntu packages for example..
( If I knew how to do that , I would not ask ---duh...) -
Thank you
|
|
|
|
|
jana_hus wrote: Just point me to REAL / USED / CURREN This is a job for Google, Bing, Duck Duck Go ...
|
|
|
|
|
You have forgotten the StartPage man........
As an answer to OPs question, this should help. First result especially.
|
|
|
|
|
Yes, but you need to tell the person who wants the answer.
|
|
|
|
|
jana_hus wrote: library as adopted by Linux.
To start with that means nothing.
It is like asking someone to provide instructions on how to replace the alternator for a 'truck'.
The name 'linux' is generic. There are many vendor builds (using 'vendor' very loosely.)
Of those each has a build. Where the build stipulates the code that is included in the binary that represents the version of linux that is actually installed.
Except of course the installer might install different parts also.
And on top of that then other installer might change stuff as well.
Somewhere there is a linux command that can tell you what version is installed on whatever you are looking at.
After you identify that then you can start looking for the code that corresponds to that.
It will probably be one of those github repos.
jana_hus wrote: there are plenty of copies of SAME, undocumented and UNSUPPORTED
of "bluez" library on many github files...
And presumably you think you are going to find one that is much 'better' than those. Good luck with that.
|
|
|
|
|
Thanks, appreciate the reply. I think I did not express what I am after - he usual " my fault".
( But I do appreciate you did no dwell on that...)
I will try to correct that.
The "bluez" library "advertisement " states it has been adopted by Linux.
It is part of Linux kernel.
That is the basic.
My question / search is HOW to access / find the actual source code of
"bluez" library / package in Ubuntu .
Something like
open file directory xyz
open file which contains the "bluez" package
I know where / how to get "bluez" source coder in github,
I am after its residence in Ubuntu.
|
|
|
|
|
|
I like to discuss this with somebody.
I am using "systemctl" to control / verify that bluetooth service is actually running.
Works so, so.
The "problem" is AFTER I reboot the Ubuntu "bluetooth setting" - located on very right
top of the desktop - ALWAYS shows "Bluetooth off".
I cannot restart bluetooth using this "setting" - it does not react at all to "Bluetooth on".
I am puzzled why I need to use "systemctl start bluetooth" get the service running.
My code DOES not stops the service - only verifies it is running.
Thanks
|
|
|
|
|
Check to see if bluetooth is enabled systemctl is-enabled bluetooth.service . If it is enabled, you'll need to dig into the logs to figure out why its not coming up. If it is disabled, then as root: systemctl enable --now bluetooth.service which will tell systemd that it should start the bluetooth service on boot. The --now flag is optional and will start the given service immediately. Without it, you will either have to start the service manually (systemctl start bluetooth.service ) or reboot the system. It's probably a good idea to reboot the system as soon as you may after enabling the service, just to check it is coming up OK, or debug why it isn't.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Thank you, you have nailed it...I assume some of my "safety code" accidentally disabled the service.
Or maybe I should blame it on bad weather, or somebody else , as is customary.
What was a real challenge - navigate thru all " why are you doing that?... post detail error
...post your (formatted ) code...you have asked this before...I do not know the answwr, but L like...
I am really hesitant to ask questions on this forum, I always get flamed....
Anyway, thanks for you help, much appreciated.
|
|
|
|
|