|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: Can I ask you to "translate" this to English for me ?
QP->start("/bin/sh", QStringList() << "-c" << command);
Sure: call operator<< on the results of calling some unknown function QStringList() and (char *)"-c" and then call operator<< on the results of that with some unknown object command . Then pass that ojbect and (char *)"/bin/bash" to method start on some unknown object QP . What any of this actually does in not known in the context of what you've presented here. I'm guessing it pulls the tail on a elephant at the Bronx Zoo. Its as valid a guess as anything else.
Assuming this goes back to your question about creating a link between /dev/ttyUSB0 and something that looks might be a bluetooth device file (which you've now helpfully removed, so I can't refer to it .. nice), Are you sure that's what you want to do? This would suggest that you have a serial USB dongle (i.e. an RS232 to USB converter) to which you've attached a serial BlueTooth receiver. I don't know if any such beast actually exists. I suspect not, so you're probably going in the wrong direction here.
But a quick perusal of the docs for QProcess, which is what I assume that QP is, doesn't suggest that QP launches a terminal, so is that part of what command does? Perhaps you'd be better off looking into how to use sudo to let a user launch a given command without having to enter a password? https://askubuntu.com/a/159009 Alternatively, you could change the ownership of the executable to a user with sufficient access to perform whatever task it is you're trying to do, and then set the suid bits on the executable so the executable runs as that user. You man need to call seteuid() and setegid() as well.
Keep Calm and Carry On
|
|
|
|
|
Assuming that QP is a pointer to a QProcess Class | Qt Core 6.5.0[^] object then:
1. QStringList() << "-c" << command creates an array of strings which will form the second parameter of the QP->start call.
2. QP->start("/bin/sh", ... will create a shell process which reads the strings passed in via QStringList above, and executes the command string in the shell.
3. What happens next is not clear since it will depend on the actual command string, and how the start function treats the created process. The documentation should clarify.
|
|
|
|
|
Message Closed
modified 5-May-23 10:29am.
|
|
|
|
|
I don't think it does. The QProcess::start method just starts the program: in this case a shell. The started program will process the information passed in via the QStringList , and then (probably) terminate. I don't use QT so I have no way of testing this. But I do not think you can call sudo or su in this way as the elevated process will be the started shell, and not your application. As I suggested in reply to your other question, you need to get the elevated privilege before starting your application.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Take a look at https://people.csail.mit.edu/albert/bluez-intro/c404.html[^]* which is a simple implementation. But to do it without the bluetooth libraries would mean writing all the actual bluetooth handling that goes on top of the sockets.
*in fact it would appear to be a complete tutorial on bluetooth usage.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: if you pay attenti0on to the title - I asked for help with using "socket".
Well this is what you actually asked:
Member 14968771 wrote: I am , rater naively, looking for (C/C++ no command scripts , please ) documented / commented example on how to implement Bluetooth in Linux, preferably skipping "bluez".
And that was the best example Google found for me. I have not been able to test it for you as I don't have the bluez library. But if you want to know how to use sockets directly then Google will find plenty of sample code that shows a client server implementation, e.g socket c programming - Google Search[^]. But you will still need to have a good understanding of the bluetooth transport protocol to implement it; that is why people use ready made libraries.
|
|
|
|
|
"Bluez" is the "official Linux Bluetooth stack". Your resistance to it simply means you will continue to flail about indefinitely.
https://www.researchgate.net/publication/345032366_Bluetooth_Stack_and_how_Linux_OS_handles_it#pf1f
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
modified 3-Apr-23 12:18pm.
|
|
|
|
|
Member 14968771 wrote: Linux, preferably skipping "bluez"
Even if you don't want to use it you can still look at it to see how they do it.
The license it has means you can do anything you want with it.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: How do I implement "Linux socket " for same ? You do what I suggested yesterday and implement the bluetooth protocol in your code. The document I gave you the link for gives example code. But if that is not enough you need to study the bluetooth protocol, and Google will find plenty of references for you.
|
|
|
|
|
Member 14968771 wrote: How do I implement "Linux socket " for same ?
Myself I have no idea.
But if it was me and I could not use the other library then, as I already stated, I would look at the source code for the library because the license specifically allows that.
That would give me ideas to implement it on my own.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
You seem to be struggking with some basic concepts. A device_id is simply an identifier that is returned by the bluetooth driver in the kernel. The kernel code uses this id to acces a specific connection (socket etc.) between devices. So every time you call a library function, you pass it the device_id so the driver code knows which connection you are referring to. I use the analogy of a telphone number, if you pass your telephone number to your mobile service provider, it always knows where to send messages.
If you want to bypass the device_id and use a plain socket (which is conceptually the same thing as described above) then that is fine. But as we keep saying, that means you have to write the code to actually use the bluetooth protocol over the connection that the socket makes with a remote device. Also, Bluetooth does not replace RS232, it is a network protocol that uses the ISO/OSI model.
But ultimately all your questions are asking for more information than there is space for in a forum such as this. The only way to get a good understanding of what you are trying to do (which remains something of a mystery) is to do a lot of research. The internet has hundreds of papers that detail networking in general and the various specific protocols, so that is where you need to go.
The link I gave you three days ago gives some good details (although abridged) on this whole subject. I strongly advise you to study it carefully, as it answers at least most of your questions.
|
|
|
|