+
    ȞRj)                        R t ^ RIHt ^ RIHt ^ RIHt  ^ RIHtH	t	H
t
HtHtHtHtHt R tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"]]n#        ]]n$        ]]n%        ]]n&        ]]n'        ]]n(        ]]n)        ]]n*        ]]n+        ]]n,        ]]n-        ]]n.        ]]n/        ]]n0        ]]n1        ] ]n2        ]!]n3        ]"]n4        ]tR#   ] d    R tR tR tR tR	 t
R
 tR tR t	 Li ; i) aC  
Monkey-patch for scservo_sdk compatibility issues.

This module patches the scservo_sdk library to fix API mismatches without
modifying the installed package. Import this module before using sms_sts.

Required package: feetech-servo-sdk>=1.0.0 (provides scservo_sdk with a flexible
protocol_packet_handler.__init__). On Python 3.11, if you see:
  TypeError: protocol_packet_handler.__init__() missing 2 required positional arguments: 'portHandler' and 'protocol_end'
then install the same SDK as Python 3.13: pip install feetech-servo-sdk
See robot_models/requirements-arm.txt.
)sms_sts)GroupSyncWrite)SMS_STS_ACC)
SCS_TOHOST	SCS_TOSCSSCS_MAKEWORDSCS_MAKEDWORD
SCS_LOWORD
SCS_HIWORD
SCS_LOBYTE
SCS_HIBYTEc                     V ^,          #     words   &scservo_patch.pyr   r      s    d{    c                 "    V ^,	          ^,          # )   r   r   s   &r   r   r      s    	T!!r   c                     V R ,          #   r   dwords   &r   r	   r	       s    v~r   c                 "    V ^,	          R,          # )   r   r   r   s   &r   r
   r
   #   s    v%%r   c                 >    V ^,          V^,          ^,          ,          # r   r   lowhighs   &&r   r   r   &   s    d
t122r   c                 >    V R ,          VR ,          ^,          ,          # r   r   r   s   &&r   r   r   )   s    f$-B!677r   c                 D    V^ 8  d   ^V,          ^,
          MRpW,          #     l    r   valuebitsmasks   && r   r   r   ,       "&)T	Q|r   c                 D    V^ 8  d   ^V,          ^,
          MRpW,          # r$   r   r&   s   && r   r   r   0   r*   r   c                x    \         \        V `  4        Wn        \	        V P                  V \
        ^4      V n        R# )zAPatched __init__ for sms_sts that correctly calls GroupSyncWrite.N)super_original_sms_sts__init__portHandlerr   r   groupSyncWrite)selfr0   s   &&r   _patched_sms_sts_initr3   5   s1     

T+-"()9)94aPDr   c                >    \         \        V `  V P                  W4      # z0Wrapper to inject portHandler as first argument.)r-   r.   read1ByteTxRxr0   r2   scs_idaddresss   &&&r   _patched_read1ByteTxRxr:   ?       "D78H8H&ZZr   c                >    \         \        V `  V P                  W4      # r5   )r-   r.   read2ByteTxRxr0   r7   s   &&&r   _patched_read2ByteTxRxr>   D   r;   r   c                >    \         \        V `  V P                  W4      # r5   )r-   r.   read4ByteTxRxr0   r7   s   &&&r   _patched_read4ByteTxRxrA   I   r;   r   c                @    \         \        V `  V P                  WW44      # r5   )r-   r.   	writeTxRxr0   r2   r8   r9   lengthdatas   &&&&&r   _patched_writeTxRxrG   N   s     "D3D4D4DfW]ddr   c                @    \         \        V `  V P                  WW44      # r5   )r-   r.   regWriteTxRxr0   rD   s   &&&&&r   _patched_regWriteTxRxrJ   S   s     "D6t7G7GZ`ggr   c                @    \         \        V `  V P                  WV4      # r5   )r-   r.   write1ByteTxRxr0   r2   r8   r9   rF   s   &&&&r   _patched_write1ByteTxRxrN   X        "D89I9I6\`aar   c                @    \         \        V `  V P                  WV4      # r5   )r-   r.   write2ByteTxRxr0   rM   s   &&&&r   _patched_write2ByteTxRxrR   ]   rO   r   c                >    \         \        V `  V P                  V4      # r5   )r-   r.   actionr0   r2   r8   s   &&r   _patched_actionrV   b   s    "D01A1A6JJr   c                >    \         \        V `  V P                  V4      # r5   )r-   r.   pingr0   rU   s   &&r   _patched_pingrY   g   s    "D.t/?/?HHr   c                    \        W4      # )z!Convert SCS value to host format.)r   r2   r'   r(   s   &&&r   _scs_tohostr\   m   s    e""r   c                    \        W4      # )z!Convert host value to SCS format.)r   r[   s   &&&r   
_scs_toscsr^   r   s    U!!r   c                    \        V4      # )zGet low byte of word.)r   r2   r   s   &&r   _scs_lobytera   w       dr   c                    \        V4      # )zGet high byte of word.)r   r`   s   &&r   _scs_hibyterd   |   rb   r   c                    \        V4      # )zGet low word of dword.)r	   r2   r   s   &&r   _scs_lowordrg          er   c                    \        V4      # )zGet high word of dword.)r
   rf   s   &&r   _scs_hiwordrj      rh   r   c                    \        W4      # )z"Make word from low and high bytes.)r   r2   r    r!   s   &&&r   _scs_makewordrm      s    ""r   c                    \        W4      # )z#Make dword from low and high words.)r   rl   s   &&&r   _scs_makedwordro      s    ##r   N)5__doc__scservo_sdk.sms_stsr   r.   scservo_sdk.group_sync_writer   r   scservo_sdk.scservo_defr   r   r   r   r	   r
   r   r   ImportErrorr3   r:   r>   rA   rG   rJ   rN   rR   rV   rY   r\   r^   ra   rd   rg   rj   rm   ro   r/   r6   r=   r@   rC   rI   rL   rQ   rT   rX   
scs_tohost	scs_toscs
scs_lobyte
scs_hibyte
scs_loword
scs_hiwordscs_makewordscs_makedwordr   r   r   <module>r}      su   = 7 +  BQ[
[
[
e
h
b
b
K
I#
"




#
$ 3  "8  "8  "8  0  !6  #:   #:   *  &    +  (  *  *  *  *  !.  "0   i  "&381s   C" "DD