def test_get_struct_fmt_for_register_all(rsl_generator: RslGenerator): for reg in rsl_generator.regs: fmt = rsl_generator.get_struct_fmt_for_register(reg) struct_size = struct.calcsize(fmt) assert 0 <= struct_size <= 4, f"\nregister: {reg.name} should not exceed 4, but has size {struct_size}!"
def test_get_struct_fmt_for_register_float(rsl_generator: RslGenerator): reg = rsl_generator.find_register_by(name='DREG_GYRO_PROC_X') ret = rsl_generator.get_struct_fmt_for_register(reg) print(ret) assert ret == '>f', "Interpreted field is incorrect!"
def test_get_struct_fmt_for_register_one_short(rsl_generator: RslGenerator): reg = rsl_generator.find_register_by(name='DREG_GYRO_RAW_Z') ret = rsl_generator.get_struct_fmt_for_register(reg) print(ret) assert ret == '>hxx', "Interpreted field is incorrect!"
def test_get_struct_fmt_for_register_two_shorts(rsl_generator: RslGenerator): reg = rsl_generator.find_register_by(name='DREG_GYRO_RAW_XY') ret = rsl_generator.get_struct_fmt_for_register(reg) print(ret) assert ret == '>hh', "Interpreted fields for DREG_GYRO_RAW_XY are incorrect!"
def test_get_struct_fmt_for_register_mixed(rsl_generator: RslGenerator): register_name = 'CREG_COM_RATES6' expected_fmt = '>BxBx' reg = rsl_generator.find_register_by(name=register_name) result = rsl_generator.get_struct_fmt_for_register(reg) assert result == expected_fmt, f"INCORRECT struct.fmt for {register_name} expected {expected_fmt}, got {result}"