Forum
Please or Register to create posts and topics.

Pass a packet through a DSPBlock

Dear Aaronia support team,

I need to pass a packet which I myself make its samples (I mean it is not provided by script inputs) to a IQDemodulation block and then transmit it over one of script outputs (e.g. "out0"). note that I don't want to use multiple scripts and note that I don't receive packets from any inputs. I have wrote the following codes by taking idea from the example of JSIQA documentation. but it does not work. Can you help me?

 

async function pass_through(){
blocks = await DSPStream.addBlocks({
demodulator : {type: "IQDemodulation" , config : {centerfreq : 2.4e+9 , samplerate: 1e+6, spanfreq: 0.2e+6}}
})
let packet = {
depth: 1,
payload: "iq",
unit: "volt",
minValue: -1,
maxValue: 1,
startFrequency: f1,
endFrequency: f2,
stepFrequency: sampleRate,
samples: my_own_samples,
startTime: 0,
endTime: Count/sampleRate
}
let connection = await DSPStream.connectBlocks([
{source: "out1" , drain: "demodulator"},
{source: "demodulator" , drain: "out0"},
])
await DSPStream.sendPacket(1, packet);
}

When you want to read data from an output of the current script block you'll have to specify it like this:

let connection = await DSPStream.connectBlocks([
{source: "script", output: "out1" , drain: "demodulator"},
{source: "demodulator" , drain: "out0"},
])

In a similar way you can make packets available at the script blocks input using

let connection = await DSPStream.connectBlocks([
{source: "in1" , drain: "demodulator"},
{source: "demodulator" , drain: "script", in: "in0" },
])

Background: In- and outputs of the script block are DSP blocks themselves, so they can be specified as source or drain targets. They also have their own "in" and "out" connectors which can make things somewhat confusing as e.g. "out1" can refer to different things ("out1" of the script block is connected to "in0" input of the "out1" DSPOutput block). In your example you were trying to specify a DSPOutput block as a source which could not work as the output of that block cannot be redirected. Instead what you want is to redirect whatever was connected to its input, which is "out1" of the "script" DSP block (a self reference).

Generally every "source" needs a specific "out" specifier, and every "drain" an "in" specifier. If they are missing those will default to "out0" and "in0" though which in many cases will just work.