<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scan_chain_len(self, scan_chain):
 """Retrieves and returns the number of bits in the scan chain. Args: self (JLink):
 the ``JLink`` instance scan_chain (int):
 scan chain to be measured Returns: Number of bits in the specified scan chain. Raises: JLinkException: on error. """

        res = self._dll.JLINKARM_MeasureSCLen(scan_chain)
        if res < 0:
            raise errors.JLinkException(res)
        return res