Hi,
I've been trying to add more than one input pin for my custom module. I've tried:
add_pin(M, 'input', 'in1', 'input1', PT, 1);
add_pin(M, 'input', 'in2', 'input2', PT, 1);
But after building the custom module still only has one input pin. I've also tried:
add_pin(M, 'input', 'in1', 'input1', PT, 2);
add_pin(M, 'input', 'in2', 'input2', PT, 2);
Basically, I'm not sure of the syntax for the numPinArray argument to the add_pin() function.
Thanks.
3:35pm
Hello David,
Please try omitting the number after the PT argument. Doing so specifies creating a "pin array".
Thanks,
Kevin
12:05pm
Hi,
Actually, I found if I wanted my module to have 4 inputs say I did this:
num_in_pins = 4;
add_pin(M, 'input', 'in', 'audio input', PT, num_in_pins);
and resulted in pins, in.1, in.2, in.3 and in.4. Thanks.
2:58pm
Hi David,
The code you provided creates a pin array, which is just fine. In theory, it should work the same as adding 4 separate pins, but if you run into any issues, it could be because of the pin array implementation. If you don't have any issues, then you are good to go, however it's good to know that it's not exactly the same thing as creating 4 separate pins. To access each of your pins, you'll need to use the array indexing method.
Here is a code example from the deinterleave module:
PT = new_pin_type(1, [], [], '*32', []);
add_pin(M, 'output', 'out', 'Output signal', PT, NUMOUT);
for i=1:length(M.outputPin)
M.outputPin{i}.type=M.inputPin{1}.type;
M.outputPin{i}.type.numChannels=1;
M.outputPin{i}.type.numChannelsRange=1;
M.outputPin{i}.type.isComplex=isComplex;
M.outputPin{i}.clockDivider = M.inputPin{1}.clockDivider;
end
Since a Pin is an object you have to index using {} because the array is a cell array.
The following code, similar to your implementation, would create an array of 4 Pin objects:
add_pin(M, 'output', 'out', 'Output signal', PT, 4),
for i=1:length(M.outputPin)
M.outputPin{i}.type=M.inputPin{1}.type;
M.outputPin{i}.type.numChannels=1;
M.outputPin{i}.type.numChannelsRange=1;
M.outputPin{i}.type.isComplex=isComplex;
M.outputPin{i}.clockDivider = M.inputPin{1}.clockDivider;
end
Where each Pin object in the array would be called: M.outputPin{1}, M.outputPin{2}, M.outputPin{3}, M.outputPin{4}.
Thanks,
Kevin