I would like to create a streaming audio from a Nao to my WPF form.
The only way that i have found is that we can download a recorded sound on Nao over SSH.
But its not a real streaming ...
If anyone has an idea !
Thanks
run this command on your NAO (login via ssh) gst-launch-0.10 pulsesrc ! audioconvert ! vorbisenc ! oggmux ! tcpserversink port=1234
list via VLC: vlc tcp://IP:1234/
You should look at gstreamer that is embedded in the robot. It would be a bit slow, but it'll be real streaming...
For windows:
Download the latest pulseaudio (not the official one) and creat a config.pa file with these two lines:
load-module module-native-protocol-tcp listen=0.0.0.0 auth-anonymous=1
load-module module-waveout
Run pulseaudio on your windows machine first with pulseaudio -F config.pa
On your NAO:
pacmd load-module module-tunnel-sink sink_name=nao server=192.168.1.152
(change this address to your windows one. Also make sure pulseaudio is running on windows otherwise this wont work)
qicli call ALAudioDevice._listOutputs
The previous command will show you the index number of the pulseaudio device you just created. Use this number in the next commands
pacmd set-default-sink 1
qicli call ALAudioDevice._setDefaultOutput 1
Thats it. Now everything comes through your pc speakers. index 0 is NAO's soundcard
For Linux:
Run this on terminal:
pactl load-module module-rtp-recv
On NAO:
pactl load-module module-null-sink sink_name=nao (creates the sink)
qicli call ALAudioDevice._listOutputs (checks the index on sink)
qicli call ALAudioDevice._setDefaultOutput 1
pactl load-module module-rtp-send source=nao.monitor
I find the Linux approach more stable. The TCP one on windows might break after some time.
Related
I am having a serial communication problem on Linux. I am trying to send and receive information between an arduino and the Unity3D engine which uses C# (mono) to open the serial communication. But I suspect that this is an issue with Linux permissions, which is why I post this here.
I already added the user to the dialout group and serial communication is actually working when I compile and run the following C# using mono:
using System.IO.Ports;
sp = new SerialPort("/dev/ttyACM0", 9600);
sp.Open();
However, the same code in Unity3D at runtime tells me:
IOException: No such file or directory
The frustrating thing is that this is actually working on another Linux machine and I am having trouble understanding what the difference could be that is causing it not to work on the other.
Here are some differences on both systems:
The working Linux is Lubuntu 19 with the Unity3D installation inside of /home, which is on the same partition as root. The Unity3D version is 2019.2.
The non-working system is Linux Mint 19.3 with the Unity3D installation also in /home, but this is a different partition from root. The Unity3D version is 2019.3.
The permissions look slightly different too:
crw-rw----+ 1 root dialout 166, 0 mei 1 05:08 /dev/ttyACM0 --> Lubuntu
crw-rw---- 1 root dialout 166, 0 May 1 15:03 /dev/ttyACM0 --> Mint
Also:
getfacl /dev/ttyACM0
gives me the following on Lubuntu:
# file: dev/ttyACM0
# owner: root
# group: dialout
user::rw-
user:myname:rw-
group::rw-
mask::rw-
other::---
and the following on Linux Mint:
# file: dev/ttyACM0
# owner: root
# group: dialout
user::rw-
group::rw-
other::---
Does anyone have any insight into why in one scenario Unity3D can't access /dev/ttyACM0, while in the other one it can? Or any idea's how I might find out?
EDIT:
I played around a bit with the following to check what the program is allowed to read:
string[] fileArray = Directory.GetFiles(#"/dev");
foreach(string s in fileArray)
{
Console.WriteLine(s);
}
And when run inside of Unity3D only a handful of files are recognized, only those with "other" read permissions.
In contrast, when I compile it outside of unity with mono, all the files in /dev are printed.
This confuses me, shouldn't Unity3D also be run with my user ID, and in turn have access to the dialout group permissions?
Unity3D is launched through a launcher application, could this cause it to not be run as my user?
I would double check that the ACM device isnt reconnecting and being given ACM1/2/3 etc instead of 0. I've had the issue that it has timed out, reconnected and the number has incremented, because they are virtual this can happen very quickly and the system doesn't remove the previous devicefile before creating the new one. If you type dmesg into terminal it will show any re connections and what port they got assigned, running sudo dmesg -c will clear the output as it can be quite verbose.
Hope this helps. Hardware can be painful to work with sometimes.
I finally found the culprit. Apparently Unity3D recently changed their launcher (Unity Hub) to a sandbox version using flatpak, and for some reason /dev is blacklisted by default.
To get around this Unity Hub should be launched with the parameter:
--device=all
The entire command to get this to work for me is:
/usr/bin/flatpak run --branch=stable --arch=x86_64 --device=all --command=start-unityhub com.unity.UnityHub
I have some large project that connect to many devices over SSH.NET
Now I have to add support for new modem witch is digi 6030dx.
I added it and I am able to connect with no issues
But when I send some/any command like show config the output is:
[16C[0K
[16C[0Ks
[17C[0Kh
[18C[0Ko
[19C[0Kw
[20C[0K
[20C[0Kc
[21C[0Ko
[22C[0Kn
[23C[0Kf
[24C[0Ki
[25C[0Kg
Commands
-------------------------------------------------------------------------------
config View and modify the configuration
exit Exit the CLI
analyzer Analyzer commands.
cli-legacy Enter the legacy Admin CLI.
cp Copy a file or directory.
help Show CLI editing and navigation commands.
ls List a directory.
mkdir Create a directory.
modem Modem commands.
more View a file.
mv Move a file or directory.
ping Ping a host.
reboot Reboot the system.
rm Remove a file or directory.
scp Copy a file or directory over SSH.
show Show instance statistics.
system System commands.
traceroute Print the route packets trace to network host.
update Update firmware.
dra.wk.0001> ashowconfigdra.wk.0001> ashowconfig
[16C[0K
Does anyone known what are this strange signs / why my command is splited by this and newlines?
It is first device that have this issue and the app support over 200 other with no issues.
I guess some coding issue or something ? putty does not show this signs so probably 'understand' them somehow?
Those are ANSI escape codes.
In general, with SSH, you get these only if your client (library) declares support for terminal emulation.
SSH.NET library does that always, when you use the "shell" channel (SshClient.CreateShell or SshClient.CreateShellStream).
In general (were you connecting to well behaving SSH server), to avoid getting the codes:
Use "exec" channel (use SshClient.RunCommand). SSH.NET does not use terminal emulation on "exec" channel. Though SSH servers on "devices" (contrary to full servers) usually do not implement the "exec" channel. See also What is the difference between exec_command and send with invoke_shell() on Paramiko?
Modify SSH.NET code not to request terminal emulation for the "shell" channel. – Remove SendPseudoTerminalRequest request from Shell.Start implementation.
Though as you are connecting to some "device" and telneting further to another device and the codes probably come from the far device, the question is whether this will in fact have any effect on that device at all. Possibly you won't be able to avoid getting the codes. Lack of terminal emulation on the first SSH connection possibly won't have any effect on the second telnet connection.
In the end, you may have to deal with the codes.
See also How to strip ANSI escape codes from AIX topas command result in C#.
i did for now
this.answer = Regex.Replace(this.answer, #"\r\[\d{0,3}C\[0K", "", RegexOptions.IgnoreCase);
will see if have any negative impact but looks perfect for now :D
Okay I succeeded in creating a custom Minecraft launcher for my server. Everything is working fine but there is one cool thing i would like to add. I think it would be cool if people can instantly join a server upon launching minecraft. Does anyone know if this is possible to do?
Have you seen:
http://minecraft.gamepedia.com/Minecraft_launcher
Specifically the section called
Command Line usage
MinecraftDev.jar (all systems): java -cp Minecraft.jar net.minecraft.bootstrap.Bootstrap <username> <server:port>.
Beginning with the launcher released with Minecraft 1.6.1, there are
other commands for the launcher. These can be seen by running java
-jar Minecraft.jar -help.
this shows you it is possible to launch minecraft telling it to connect to server. you should check out the -help to see the full list of command line arguments
I have a client that is supposed to grab data from a micro-controller ( Arduino if you are familiar with it ), that transmits once a second a line of values, and send that data to a server to which the client is connected .
How should i do that ? The micro-controller when connected to the PC , 'shoots' data on one of the COMs.. should i approach the problem as a client-server ? I mean should i connect with my client to the micro-controller passing the mcontroller's port ? And if so, can anyone give me a link to such a solution ?
From what you're writing You could just download a port-analyzer to check what's coming in.
http://www.serial-port-monitor.com/
You can also write a simple macro in excel that grab data and output to sheet,
just open the com-port with the right settings.
If it's an 24/7-application, I'd recommend a simple complied program running as a service, .NET or maby compiled script, autoit3 or similar (if you're on win32).
http://www.autoitscript.com/forum/topic/19769-phone-dialer-using-com-to-modem-on-serial-port/
(3:rd post, Martin)
Regards,
//t
I've been really interested in adding support for video podcasts to Media Browser.
I would like users to be able to navigate through the available video podcasts and stream them from the internets. That's really easy cause media player etc.. will happily play a file that lives in the cloud.
The problem is that I want cache these files locally so subsequent viewings of the same episode will not involve streaming and instead will play the local file.
So... I was thinking, why not host an HttpListener and as media player asks it for bits of the file, have the HttpListener download and store it locally. Next time a user plays the file we will already have portions of the file locally.
Does anyone know of example code that uses HttpListener for proxying?
EDIT
The idea would be only to proxy simple streamable content like MP3 or Mov.
The bounty will go to an actual implementation.
Here is the API I would like:
// will proxy a uri on the local port, if cacheFile exists it will resume the
// download from cacheFile.
// while the file is downloading it will be name cacheFile.partial, after the
// download is complete the file will be renamed to cacheFile.
// Example usage: ProxyFile("http://media.railscasts.com/videos/176_searchlogic.mov", 8000, #"c:\downloads\railscasts\176_searchlogic.mov")
//
// Directly after this call http://localhost:8000 will be the proxy stream, it will be playable locally.
void ProxyUri(Uri uri, int port, string cacheFile)
Edit 2
HttpListener is looking pretty unpromising I will probably need to do the work at a TCP socket level as HttpListeners seem to require the program runs as admin which is going to be really tricky.
I hadn't done anything with HttpListener before, so I thought this would be a nice little exercise to bring myself up to speed with it - and so it proved. I implemented it as a single ProxyListener class whose constructor takes the parameters of the ProxyUri function you specified. Once you obtain an instance, you start it listening (and potentially downloading) by calling its Start method. When you're done with it, call Cleanup.
There are one or two rough edges but basically it works as per your question. To test it, I built it up as a console application with a Program class which accepts input lines consisting of (uri, port, filename), space-separated, creates the ProxyListener instances and starts them. You can run this console application, type in a suitable line, and the downloader will start (printing out progress to console). Simultaneously you can e.g. fire up IE and fetch the file from the specified port, and you will be able to download it while the downloader is still working. The "uploader" progress will be printed to console, too.
I'm having a bit of trouble pasting it in here, maybe due to size (it's not that big, but bigger than the snippets you normally see here - the ProxyListener class is a tad under 200 lines). Does it sound interesting? If so, I'll post it to a pastebin and update this answer with a link.
Update: Posted as a gist.
Note that you will need Administrator privileges to run the program, since HttpListener requires this.
Update 2: Under certain circumstances, it is not necessary to have admin privileges to run HttpListener. See this link and this one. The idea is, if you can reserve an URL namespace during installation time, then the user does not have to have admin privileges if listening against that namespace.
Streaming was not designed to be saved, and also these protocols are very custom and very complex to implement, streaming sessions do lots of validation and synchronization which will be extremely difficult to imitate. Of course it is not an impossible task, but its fairly big task to do. Only other way is to read and save it as local media file, and use that as a reference. Because you can use windows media encoder to read stream and write stream data as local file, but it still may not allow you to do copy protected data.
Did you consider using HTTP proxy with caching features?
Like:
Apache httpd with mod_proxy and mod_cache
Squid
See also Web Cache # wikipedia
If you want your application to have such web cache component, I suggest you look for Web Cache implementation in .Net, and not code it from scratch.