how to return several bytes from another object
Sabre00
Posts: 30
I have tried to "modularize" or in propeller case "object-terise" my application code. I have a situation where am reading 6 bytes from an external device in a child object and I would would like to return these 6 bytes to the main object. I tried making the parent object a child of the child but I got a cyclic call error. that didn't work.
I have the bytes saves in an array and when I use the RETURN Arrayname and that didn't seems to work either.
I was trying to see if I could alter the values of a mirror array within the parent object but I can't seem to figure out how to do that just yet. if it even is possible.
my question is is it possible to return from a child object multiple bytes?
while writing this I thought about using the COG RAM to store data where it can be seen from all objects. is that the answer?
I have the bytes saves in an array and when I use the RETURN Arrayname and that didn't seems to work either.
I was trying to see if I could alter the values of a mirror array within the parent object but I can't seem to figure out how to do that just yet. if it even is possible.
my question is is it possible to return from a child object multiple bytes?
while writing this I thought about using the COG RAM to store data where it can be seen from all objects. is that the answer?
Comments
I didn't use your method but I found out another way to get the job done. I am just putting my solution in here so others can see it.
in the child object where the array is stored I create another PUB where there is one parameter, a count parameter for the array.
eg.
PUB GET_ARRAY(counter)
RETURN arrayname(counter)
in the parent object I have;
repeat a from 0 to 5
parentarray[noparse][[/noparse]a] := child.GET_ARRAY(a)
once complete I can then use the parentarray values.
This is with a known array size in this example six. If the size is variable you can just use an end of array character.
Although this essentially uses up twice as much memory it is a crude way to get around the problem to return values from a child object back to the parent.