@@ -150,9 +150,13 @@ write_cosmos_lineitem = function(output,line_writer,entry,qual_prefix,descr)
150150 bits_remainder = bits_remainder - attribs .bitsize
151151 end
152152 attribs .bitsize = bits_remainder
153- elseif (entry .entity_type == " STRING_DATATYPE" or entry . entity_type == " BINARY_DATATYPE " ) then
153+ elseif (entry .entity_type == " STRING_DATATYPE" ) then
154154 attribs .ctype = " STRING"
155- elseif (SEDS .index_datatype_filter (entry )) then
155+ elseif (entry .entity_type == " BINARY_DATATYPE" ) then
156+ attribs .ctype = " BLOCK"
157+ elseif (entry .entity_type == " FLOAT_DATATYPE" ) then
158+ attribs .ctype = " FLOAT"
159+ elseif (entry .entity_type == " BOOLEAN_DATATYPE" or SEDS .index_datatype_filter (entry )) then
156160 attribs .ctype = (entry .is_signed and " INT" ) or " UINT"
157161
158162 -- This only handles integers
@@ -193,38 +197,68 @@ write_cosmos_block = function(output,line_writer,entry,qual_prefix,descr)
193197
194198end
195199
196-
197200-- -------------------------------------------------------------------------
198201-- Helper function: write a flattened array, adding a digit to the name prefix
199202-- -------------------------------------------------------------------------
200203write_cosmos_array_members = function (output ,line_writer ,arr ,qual_prefix )
201204
202- local min , max
203-
204205 -- Arrays can be dimensioned by an index type, and that type may have a better string representation
205206 -- This also means that the range could be something other than the typical limits
207+ local min , max
208+ local minv , maxv
206209 local dimension_typename
210+ local writer
211+ local datatyperef
212+ local dimension_obj
213+
214+ -- This wrapper handles the case where the array elements are not at byte boundaries
215+ -- The output is expressed as a series of 8 bit values (packed)
216+ local_packedarray_writer = function (idx , element_qual_prefix )
217+ local attribs = {
218+ name = SEDS .to_macro_name (element_qual_prefix ),
219+ ctype = " UINT" ,
220+ bitsize = 8 ,
221+ descr = string.format (" %s packed byte %d" , qual_prefix or " array" , idx )
222+ }
223+ line_writer (output , attribs )
224+ end
207225
208- for dimension in arr :iterate_subtree (" DIMENSION" ) do
209- if (dimension .indextyperef ) then
210- dimension_typename = dimension .indextyperef :get_qualified_name ()
211- min = dimension .indextyperef .resolved_range .min
212- max = dimension .indextyperef .resolved_range .max
226+ -- This wrapper handles the normal case where the array elements are a
227+ -- whole number of bytes, and thus spelled out normally in the definition
228+ local_array_writer = function (idx , element_qual_prefix )
229+ write_cosmos_block (output ,line_writer ,datatyperef ,element_qual_prefix )
230+ end
231+
232+ datatyperef = arr .datatyperef
233+
234+ -- Check if this needs to be output as a bitmap
235+ if ((datatyperef .resolved_size .bits % 8 ) ~= 0 ) then
236+ -- Packing: The dimension is the size of the whole array
237+ min = { value = 0 , inclusive = true }
238+ max = { value = arr .resolved_size .bits / 8 , inclusive = false }
239+ writer = local_packedarray_writer
240+ else
241+ -- Normal: The actual dimension will be used
242+ for dimension in arr :iterate_subtree (" DIMENSION" ) do
243+ if (dimension .indextyperef ) then
244+ dimension_typename = dimension .indextyperef :get_qualified_name ()
245+ min = dimension .indextyperef .resolved_range .min
246+ max = dimension .indextyperef .resolved_range .max
247+ end
213248 end
249+ writer = local_array_writer
214250 end
215251
216252 -- As a fallback use a generic 32-bit integer as the index type
217- local dimension_obj = SEDS .edslib .NewObject (dimension_typename or " BASE_TYPES/int32" )
253+ dimension_obj = SEDS .edslib .NewObject (dimension_typename or " BASE_TYPES/int32" )
218254
219255 -- Determine the usable min/max -- this means adjusting for inclusiveness of the limits
220- local minv
221256 if (min ) then
222257 minv = min .value + (min .inclusive and 0 or 1 )
223258 else
224259 minv = 0
225260 end
226261
227- local maxv
228262 if (max ) then
229263 maxv = max .value - (max .inclusive and 0 or 1 )
230264 else
@@ -234,7 +268,7 @@ write_cosmos_array_members = function(output,line_writer,arr,qual_prefix)
234268 for i = minv ,maxv do
235269
236270 dimension_obj (i )
237- write_cosmos_block ( output , line_writer , arr . datatyperef , append_qual_prefix (qual_prefix , dimension_obj ))
271+ writer ( i , append_qual_prefix (qual_prefix , dimension_obj ))
238272
239273 end
240274
@@ -355,7 +389,7 @@ for _,instance in ipairs(SEDS.highlevel_interfaces) do
355389 -- The various interfaces should be attached under required_links
356390 for _ ,binding in ipairs (instance .required_links ) do
357391 local reqintf = binding .reqintf
358- local intf_type_str = reqintf .type :get_qualified_name ()
392+ local intf_type_str = reqintf .type :get_qualified_name ()
359393 if (intf_type_str == " CFE_SB/Telemetry" or intf_type_str == " CFE_SB/Telecommand" ) then
360394 local cmd = reqintf .intf_commands and reqintf .intf_commands [1 ]
361395
@@ -391,4 +425,3 @@ for _,instance in ipairs(SEDS.highlevel_interfaces) do
391425 end
392426 end
393427end
394-
0 commit comments