I played last night with minimodem , but it was receiving some crap i even connected my microphone and speaker via 3.5mm jack and the outputs are completly rubbish...
There is also this project - https://www.anfractuosity.com/projects/ultrasound-via-a-laptop/
Hmm it actually worked really well for me. Did you try a lower baudrate? What was your confidence setting?
The only thing i observed is that you really have to set the right confidence setting or you get data from random noise. When using a speaker and mic you have to watch your baudrate as i wasn’t getting reliable results above 600 baud.
The screenshots above is from just now when i connected the headphone plug of a pi 3b+ directly to a cheap usb soundcard on a pi4 with a cable. This way i can achieve way higher baudrates. I got reliable results up to 6000 baud just now.
You really need to tune the confidence setting to filter out random data from noise. And of course double check with aplay -l
and arecord -l
your using the right device if your not using pulse audio.
looks very nice too. I actually think that maybe it would be possible to frequency shift the data that minimodem generates into that range with sox too. The project you linked and minimodem actually both use the same modulation technique.
Edit cant seem to be able to shift it high enough to get inaudible.
Okay, so i finished most of the configuration for the send node via minimodem. But I want to implement a repeat function, and i get a bug, where for example I set repeat times to 2 and delay time to 10000ms, my execfunction gets run 2 times in a row!
Check out this stackoverflow post, and if someone is interested to help me , please do i believe there is a simple answer behind this issue!
maybe something like this:
let repeatNumber = 1
const timeout = 10000;
function repeat(time) {
repeatNumber -= 1;
setTimeout(()=>{
execMinimodem();
},time);
return;
}
function execMinimodem() {
exec(minimodem,(error, stdout, stderr) => {
//handle errors output etc
if (repeatNumber > 0) { repeat(timeout); }
return;
});
}
execMinimodem();
just of the top of my head and not tested at all, of course needs to be adapted but than should repeat the exec after a timeout that starts when the first finished as many times as stated in the repeatNumber.
Will test it during the day and let you know , by far i think that this may work!
After integrating the function i still get several minimodem programs executed!
I double checked that my repeatxtimes and repeatdelay is not mixed, and sure enough repeatxtimes is 2 and repeatdelay is 5000 as in my node settings!
well as i cant look at your full code i dont really have much to go on. My next tip would be my preferred strategy to put node.warn() statements everywhere to see whats going on.
I will try to execute a bash command sleep x right after minimodem finished , and i will go from there...
thats not a good way. I just tested this node script:
const { exec } = require("child_process");
let repeatNumber = 3
const timeout = 3000;
function repeat(time) {
repeatNumber -= 1;
setTimeout(()=>{
execMinimodem();
},time);
return;
}
function execMinimodem() {
exec("ls ~/", (error, stdout, stderr) => {
if (error) {
console.log(error.message);
return;
}
if (stderr) {
console.log(stderr);
return;
}
console.log(stdout);
if (repeatNumber > 0) { repeat(timeout) }
return
});
}
execMinimodem();
to see it working save it to somewhere on a raspberry pi as test.js
or something and than execute it with node test.js
. Just tested it and it defineitely works executing the ls
command 3 times 3 seconds apart.
Could you analyze my code , I am trying your solution, but it is not working as expected!
To be honest I haven't properly read the thread but took a glimpse on your code. I noticed you've defined your executesend
function as async
while @JGKK's example didn't. I'm not sure if it is the reason why it's not working as expected but it for sure could be.
I think you should describe in what way is your code working unexpectedly. It looks quite involved for someone else to get an idea what could happen when running it.
There were several problems. One being the unnecessary asynch function but the bigger one that he was parsing the amount of times to repeat as the time off delay. Which lead to a very small delay which felt like it was repeating instantly:
repeatdelaytoint = parseInt(repeatxtimes)
repeatxtimestoint = parseInt(repeatxtimes)
I must be tired as I don't understand why it would cause any meaningful delay unless it's repeated in a loop? But I wonder if this was intended to have parseInt(repeatdelay)
?
Let me create a github repository...
There is a repeat function which gets called at the end of the exec if repeatxtimestoint
is bigger than 0. The repeat function subtracts one from repeatxtimestoint
and than sets a timeout for repeatdelaytoint
and calls the exec again at the end of the timeout. This repeats the timeout for whatever many times repeatxtimestoint
is set to. As repeatxtimes
was by accident used for both values if it was set to repeat once the timeout would also be set to just 1ms. This way it looked like the timeout in the repeat function was not beeing just but instead it looked like it was just executed twice. So just a simple typo i think But maybe this was the main culprit here.
Okay after declaring repeatxtimestoint
and repeatdelaytoint
as global values I finally managed to pull it off! and i used console.log to see where i was wrong
Just curious a little bit, i see a repeatdelaytoint
pause before first execute, could I use simple if/else to overcome the first pause?
"With enough eyebulbs, all bugs are shallow." -- Eric S. Raymond