yincheng.zhong
2025-11-23 212ccb49d3e7c7fa138c5f9d335d0b8c5a08d2a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
o
ê!iÆ
ã@sŽddlZddlmmZddlZddlmZmZddl Z   ddl
m Z de de fdd„Z dd „Zd
d „Zd edefd d„Zdd„Zdd„ZdS)éN)ÚdatetimeÚtimezone)Ú   protocolsÚsentenceÚreturncCs*d}|dd…D]}|t|ƒN}q|d›S)NréZ02X)Úord)rÚcsÚch©r ú<E:\GIT\Lawnmower_STM32H7\python\tests_hitl\test_protocols.pyÚ_calc_checksum    sr c Csätddddddtjd}tj|dd    d
d d d dddd
 d¡}|j}d}||ƒ}|sRddt ¡vs5t    
|¡r:t   |¡ndt   |¡t   |¡t   |¡dœ}t t     |¡ƒ‚d}}}|j}d}||ƒ}|sŒddt ¡vsot  
|¡rtt   |¡ndt   |¡t   |¡t   |¡dœ}t t     |¡ƒ‚d}}}| ¡d| d¡…|| d¡d| d¡d…}}t|ƒ}||k}|s t    d|fd||f¡dt ¡vsÎt  
|¡rÓt   |¡nddt ¡vsßt  
t¡rät   t¡ndd t ¡vsðt  
|¡rõt   |¡nd t   |¡d!œ}   d"d#|   i}
t t   |
¡ƒ‚d}}| d$¡} t| ƒ} d%}| |k}|sjt  d|fd&| |f¡d't ¡vs8t    
t¡r=t     t¡nd'd(t ¡vsKt    
| ¡rPt     | ¡nd(t   | ¡t   |¡d)œ}d*d+|i} t t     | ¡ƒ‚d} }}dS),Nééé ééré ©Útzinfog :|-CêC@g‰YÔÌ]@g@H@皙™™™™É?皙™™™™¹?ggš™™™™Ù^@ç333333ó?g333333ã¿)
Ú   timestampÚlat_degÚlon_degÚalt_mZeast_velZ   north_velZup_velÚ heading_degÚ pitch_degÚroll_degÚasciiz$GPFMI,úLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.startswith
}(%(py4)s)
}r©Úpy0Úpy2Úpy4Úpy6z
zJassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.endswith
}(%(py4)s)
}rÚ*é©ú==©z0%(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}Úchecksumr Úbody©r"r#Úpy3Úpy5úassert %(py7)sÚpy7ú,é©z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sÚlenÚfields©r"Úpy1r.r%úassert %(py8)sÚpy8)rrÚutcrZbuild_gprmi_sentenceÚdecodeÚ
startswithÚ @py_builtinsÚlocalsÚ
@pytest_arÚ_should_repr_global_nameÚ   _safereprÚAssertionErrorÚ_format_explanationÚendswithÚstripÚindexr Ú_call_reprcompareÚsplitr5)ÚtsrÚ @py_assert1Ú @py_assert3Ú @py_assert5Ú @py_format7r,r+Ú @py_assert4Ú @py_format6Ú @py_format8r6Ú @py_assert2Ú @py_format9r r r Ú test_build_gprmi_sentence_formats*ö õt t8Â
¼rTc
Csˆtddddddtjd}tj|dd   d
d  d ¡}|j}d }||ƒ}|sLddt ¡vs/t    
|¡r4t   |¡ndt   |¡t   |¡t   |¡dœ}t t     |¡ƒ‚d}}}| ¡d| d¡…}|| d¡d| d¡d…}t|ƒ}||k}|sÉt    d|fd||f¡dt ¡vsŒt  
|¡r‘t   |¡nddt ¡vst  
t¡r¢t   t¡nddt ¡vs®t  
|¡r³t   |¡ndt   |¡dœ}   dd|   i}
t t   |
¡ƒ‚d}}|j} d}| |ƒ} t| ƒ} d}| |k}|s6t  d|fd| |f¡dt ¡vsøt  
t¡rýt   t¡nddt ¡vs t    
|¡rt     |¡ndt   | ¡t   |¡t   | ¡t   | ¡t   |¡d œ}d!d"|i}t t     |¡ƒ‚d} }} } }}dS)#Nrrrrrrr)g{®Gáz„?g{®Gáz”¿g®Gáz®ï¿)rrg333333Ó¿g€=@)rZaccel_gÚ
gyro_deg_sÚ temperature_crz$GPIMU,r rr!rr&r'r(r*r+r r,r-r0r1r2é )zj%(py9)s
{%(py9)s = %(py0)s(%(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.split
}(%(py5)s)
})
} == %(py12)sr5)r"r8r.r/r1Úpy9Úpy12úassert %(py14)sÚpy14)rrr;rZbuild_gpimu_sentencer<r=r>r?r@rArBrCrDrFrGr rHrIr5)rJrrKrLrMrNr,r+rOrPrQrRÚ @py_assert6Ú @py_assert8Ú @py_assert11Ú @py_assert10Ú @py_format13Ú @py_format15r r r Ú test_build_gpimu_sentence_format'süût ÀîrbÚpayloadcCsPd}d}t dt|ƒ¡}t|||ƒd@}d}||||t d|¡|S)NsªUóz<Hiÿÿs
)ÚstructÚpackr5Úsum)rcÚheaderZ
frame_typeÚlengthr+Zfooterr r r Ú_build_control_frame7s  rjc s–g‰t ‡fdd„¡}tt ddd¡ƒ}| |dd…¡| |dd…¡tˆƒ}d}||k}|swt d|fd ||f¡d
t    
¡vsGt  t¡rLt  t¡nd
d t  
¡vsXt  ˆ¡r]t  ˆ¡nd t  |¡t  |¡d œ}d d|i}t t |¡ƒ‚d}}}ˆd}|j}tj}d}   || ƒ}
||
k}|sÓt d|fd||
f¡t  |¡t  |¡dt  
¡vs°t  t¡rµt  t¡ndt  |¡t  |   ¡t  |
¡dœ} dd| i} t t | ¡ƒ‚d}}}}}   }
ˆd}|j}tj}d} |    }
||
ƒ} || k}|s;t d|fd|| f¡t  |¡t  |¡dt    
¡vst  t¡rt  t¡ndt  |¡t  |   ¡t  | ¡dœ}dd|i}t t |¡ƒ‚d}}}}}   }
} dS)Ncó
ˆ |¡S©N©Úappend©Úframe©Úreceivedr r Ú<lambda>Bó
z7test_pythonlink_decoder_float_payload.<locals>.<lambda>z<ffrgš™™™™™Ù¿érr(r4r5rrr7r9r:r)zk%(py3)s
{%(py3)s = %(py1)s.forward
} == %(py11)s
{%(py11)s = %(py7)s
{%(py7)s = %(py5)s.approx
}(%(py9)s)
}Úpytest)r8r.r/r1rXÚpy11zassert %(py13)sÚpy13gš™™™™™Ù?)zi%(py3)s
{%(py3)s = %(py1)s.turn
} == %(py12)s
{%(py12)s = %(py7)s
{%(py7)s = %(py5)s.approx
}(-%(py9)s)
})r8r.r/r1rXrYrZr[©rZPythonLinkDecoderrjrerfÚfeedr5r@rHr>r?rArBrCrDZforwardrvÚapproxZturn)ÚdecoderrprRrMrOrNrSÚ @py_assert0r\r]r_Ú @py_format12Ú @py_format14r^r`rar rqr Ú%test_pythonlink_decoder_float_payload@s®ÄØr€c
sšg‰t ‡fdd„¡}tt ddd¡ƒ}| |¡tˆƒ}d}||k}|sjt d|fd||f¡d t    
¡vs:t  t¡r?t  t¡nd d
t    
¡vsKt  ˆ¡rPt  ˆ¡nd
t  |¡t  |¡d œ}d d |i}t t |¡ƒ‚d}}}ˆd}|j}tj}d}   d}
|| |
d} || k}|sÎt d|fd|| f¡t  |¡t  |¡dt    
¡vs§t  t¡r¬t  t¡ndt  |¡t  |   ¡t  |
¡t  | ¡dœ} dd| i} t t | ¡ƒ‚d}}}}}   }
} ˆd}|j}tj}d}   d}
|| |
d} || k}|s=t d|fd|| f¡t  |¡t  |¡dt  
¡vst  t¡rt  t¡ndt  |¡t  |   ¡t  |
¡t  | ¡dœ} dd| i} t t | ¡ƒ‚d}}}}}   }
} dS)Ncrkrlrmrorqr r rsNrtz5test_pythonlink_decoder_pwm_payload.<locals>.<lambda>z<HHiÐi@rr(r4r5rrr7r9r:rg333333Ó?gš™™™™™©?)Úrel)zy%(py3)s
{%(py3)s = %(py1)s.forward
} == %(py13)s
{%(py13)s = %(py7)s
{%(py7)s = %(py5)s.approx
}(%(py9)s, rel=%(py11)s)
}rv)r8r.r/r1rXrwrxzassert %(py15)sÚpy15g§èH.ÿ!ù?)zv%(py3)s
{%(py3)s = %(py1)s.turn
} == %(py13)s
{%(py13)s = %(py7)s
{%(py7)s = %(py5)s.approx
}(%(py9)s, rel=%(py11)s)
}ry)r|rprRrMrOrNrSr}r\r]r_Ú @py_assert12rZ @py_format16r rqr Ú#test_pythonlink_decoder_pwm_payloadLs
®Øâr„)Úbuiltinsr>Ú_pytest.assertion.rewriteÚ   assertionÚrewriter@rerrrvZhitlrÚstrr rTrbÚbytesrjr€r„r r r r Ú<module>s"