code: def channel2int(channel):
      
      if channel is None:
          return None
      if isinstance(channel, int):
          return channel
      # String and byte objects have a lower() method
      if hasattr(channel, "lower"):
          match = re.match(r'.*(\d+)$', channel)
          if match:
              return int(match.group(1))
      return None
docs: Try to convert the channel to an integer.
  
      :param channel:
          Channel string (e.g. can0, CAN1) or integer
      
      :returns: Channel integer or `None` if unsuccessful
      :rtype: int