Between additional searches ( http://varx.org/wordpress/2016/02/03/bit-fields-in-python/ ) and a comment I settled on:
class TimeBits(ctypes.LittleEndianStructure):
_fields_ = [
("padding", ctypes.c_uint32,15), # 6bits out of 32
("seconds", ctypes.c_uint32,6), # 6bits out of 32
("minutes", ctypes.c_uint32,6), # 6bits out of 32
("hours", ctypes.c_uint32,5), # 5bits out of 32
]
class PacketTime(ctypes.Union):
_fields_ = [("bits", TimeBits),
("binary_data",ctypes.c_uint32)
]
packtime = PacketTime()
now = datetime.today().timetuple()
packtime.bits.hours = now[3]
packtime.bits.minutes = now[4]
packtime.bits.seconds = now[5]
It offers a cleaner structured setting of the associated fields, especially as this is called at least every second. A similar structure has been created for Date and other bitpacking vectors