Explain relation between asound.conf file with HFP and A2DP commands - c

Here i am looking for Testing A2DP and HFP (Hands free) Profiles.
So here in HFP i am using dbus command for sending message over dbus and execute service address of bluez. for connecting and disconnecting.
here i am using below command for audio playing in HFP.
aplay -D hw:0,1 -c 2 -f S16_LE file_name &
can you explain me what is the meaning of hw:0,1 .
HFP supports only 8000 Hz sampling rate wav files.
IN Advanced Audio Distribution Profile (A2DP) defines how the high quality audio can be streamed from one device to another over Bluetooth connection.
here i am using this command , but before this command i have to update asound.conf file.
aplay -Dplug:bluetooth file_name > /dev/null > /dev/null &
and in both case i am using same asound.conf file. which is given below.
pcm.!bluetooth {
type bluetooth
device "BD_ADDR" //bluetooth address of hands free device.
}
pcm.!default {
type plug
slave.pcm "bluetooth"
}
So i want to know the relation of this asound.conf file with HFP command and A2DP command.
Please Help me to sort out this confusion.

can you explain me what is the meaning of hw:0,1 .
The numbers after hw: stand for the sound card number and the device number. A third number can be added (hw:0,0,0) for the sub-device number, but it defaults to the next sub-device avaliable. The numbers start from zero, so, for example, to access the first device on the second sound card, you would use hw:1,0.
So i want to know the relation of this asound.conf file with HFP command and A2DP command.
asound.conf is configuration file for your PulsAudio server, normally you do not need it at all but in some cases you can setup there some specific options or behavior for your hardware. HFP and A2DP are just Bluetooth profiles which are used to communicate with your headset. You can use asound.conf to link sound from your PulsAudio server with Bluetooth device which you are pair. Which means that for example you can set default output/input to this particular BT device, that all applications in your system will use it to play and record sound.
But as I mention before normally all those things happen automatically and you do not need to do anything to make it work.
More about how to use asoundrc/asound.config you can find here: http://alsa.opensrc.org/.asoundrc

Related

Can i create a gcode that self destructs after one instance of printing?

Can i create a gcode that self destructs after one instance of printing? For example I send the gcode created to a printer at a remote area to print but I want them to only print it once. Can i add a self destruct code so that it deletes after running once?
No, sorry, you cannot. There is no GCODE command for self-destruct of the file (or command stream) and the GCODE commands can be processed by any number of recieving applications and firmwares. Some work on files, others work on command streams, and some can use GCODE in either a stream or a file. So there's no way to force the receiving app/firmware to delete the file or stream.
Everything depends on which firmware your printer is using. "Gcode" is interpreted differently on different printers.
Marlin is a very popular firmware and runs on nearly every entry-level printer, such as Creality printers (CR-10, Ender 3, etc), Wanhao/MP MakerSelect, etc.
You can find a full documentation of every available gcode command here: https://marlinfw.org/meta/gcode/
With that said, not all GCode commands are implemented by every printer. Some printers trim out GCODE that isn't commonly used to keep the firmware file small, thus allowing them to make the "brains" of the printer with a cheaper microcontroller.
There IS a delete from SD card option, the code is "M30" and is documented here: https://marlinfw.org/docs/gcode/M030.html
Your printer may not support this though, so you'll have to test it out yourself.
The usage is:
M30 /path/to/file.gco
You'll have to know the path to the file, and this relies on your path not changing, so it may not be very practical. This command is generally something used by someone issuing commands to a printer manager, not something you should be sticking at the end of a gcode file to self-destruct.

How to get PIDs using a mount point before removed by udev on plug out

I want to know mechanism to get processes using any mount point before unmounted and remove by udev on removing the storage device in Debian OS.
When I skip remove directory in udev rule file it get a lot of processes including kernel etc.
I want to implement an alert message on screen if some one remove pen drive from system while uploading or downloading in the pen drive.
Please help me.
You may use lsof command. This command lists which process is using which file. output contains command, PID, USERID, file type, Device, side , file name etc.
You may grep for mount point to find who is using your device.
Syntax :
#lsof | grep <mount point>
OR
#lsof <mount point>
Other option is to use fuser command. It displays process IDs which are using given file/dir
Syntax :
#fuser <mount point >
Thanks for your reply. I am getting it by fuser. My question is how to handle it after removed by user. In my system hot plugging is managed by udev rules. Its show Specified filename
/media/pen-drive does not exist. Remove action is
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/sh -c '/bin/fuser -m /media/%E{dir_name'", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

Contiki with Tmote data I/O

Here I have a Tmote Sky node. And I have printf the RSSI on the terminal. Now I want to store these RSSI data to my computer. I have tried cfs which is used to operate the external flash of a node. So how can I save the data to my computer with contiki.
/platform/sky/Makefile.common provides a target serialdump, which will also print the output to a file named serialdump-<current time>. Therefore you want to tun make serialdump TARGET=sky.
Or do you want to get the data from the external flash? In that case you need to add a function that dumps the file contents to the serial (e.g. when pushing the button or sending a special command via serial). You can then save that output to a file.

C - running program accept input

This is a very beginner-level question in C.
Don't know where to start looking/searching.
So, if I have a program continuously running in C, what is the best way to accept input through the command line into the program?
EX, mysql is already running, but you can process a command call
mysql SELECT * FROM *
Do I need a different program to write to file/stdin?enter code here
Clarification:
So, mysql seems to be able to take in commands while it is already running... is that possible in C?
Goal:
I have some hooks into open gl es, and I want to run a continuous draw loop in the background, while having the ability to call commands such as
glhookprogram make "object1" model "triangle" program "default"
glhookprogram attr "object1" position "1.0, 1.0, 0.0" scale "2.0" rotation "45, 0, 0"
this way, I can have a node server run hw-accelerated animations in javascript on the rpi.
Looks like this is what you need (and I'm sorry - I won't be going into too much details as there are plenty of sources on the Web about that):
A "server" - that would be your background process that stays running in memory and can accept and process commands (requests)
A "client" - a (short-running?) process that can accept commands from user (GUI, command-line. Network? Other process?) and send requests to your "server"
This is not a trivial task for a beginner. I would suggest googling for "server-client" and for "inter-process communications" first and go from there.
The range of options to "accept input" into your server includes (but is not limited to) the following:
(Windows) messages
Shared memory and a command queue (producer-consumer)
Shared file (just listing it here for completeness, I'd advise against this particular one for your case)
Named pipes
Sockets (thanks for reminding me of those in the comments, can't believe I missed that!)

How to get modified data from a file in linux?

I am designing a logger plugin for my tool.I have a busybox syslog on a target board, and i want to get syslog data from it so i can forward to my host(not via remote port forwarding of syslog) via my own communication framework.Initially i had made use of syslog's ability to forward messages it receives to a named pipe but this only works via a patch addition which is not feasible in my case.So now my idea is to write a configuration file in syslog to forward all log messages it receives to a file and track the file to get my data.I can use tail function to monitor my file changes but my busybox tail does not support "--follow" option since syslog performs logrotate which causes "tail -f" to fail.And also i am not sure if this is a good method to do it.So what i wanted to ask is there another way in which i can get modified data from a file.I can use inotify, but that can only be used to track file changes.So is there a way to do this?
You could try the "diff" utility (or git-diff, which has more facilities).
You may write a script/program which can receive an inotify event. And the script reopens the file and starts to read till EOF, from the previously saved last read file position.

Resources