+ # Capability arguments may need to be expanded (e.g. 1 16 bit argument needs to be 2 8 bit arguments for the state machine)
+def capArgExpander( items ):
+ newArgs = []
+ # For each defined argument in the capability definition
+ for arg in range( 0, len( capabilities_dict[ items[0] ][1] ) ):
+ argLen = capabilities_dict[ items[0] ][1][ arg ][1]
+ num = items[1][ arg ]
+ byteForm = num.to_bytes( argLen, byteorder='little' ) # XXX Yes, little endian from how the uC structs work
+
+ # For each sub-argument, split into byte-sized chunks
+ for byte in range( 0, argLen ):
+ newArgs.append( byteForm[ byte ] )
+
+ return tuple( [ items[0], tuple( newArgs ) ] )
+