title: ERROR:can.socketcan.ctypes:Setting filters failed -1 Find out the can error frame
body: <p>I am writing Python codes to <code>see the Error frames</code>. I want to set <code>Error Filters</code>. But this code never works when I set the <code>CAN_RAW_ERR_FILTER</code>. But the filter works when the filter set to <code>CAN_RAW_FILTER</code>.</p>
  
  <p><code>CanRecv.py</code> on <code>vcan0</code></p>
  
  <pre><code>import can
  import logging
  logging.basicConfig(level=logging.DEBUG)
  def recv_one():
      bus = can.interface.Bus(bustype='socketcan', channel='vcan0', bitrate=250000, can_filters=[{"can_mask":0x1FFFFFFF, "can_id":0x20000000, "extended":True}])
      try:
          while 1: #print "bus: ", bus
              msg = bus.recv()
              print("Message recv : ", msg)
      except: # can.CanError:
          print("Eror")
  
  if __name__ == '__main__':
      recv_one()
  </code></pre>
  
  <p><code>CanSend.py</code></p>
  
  <pre><code>import can
  import logging
  logging.basicConfig(level=logging.DEBUG)
  def send_one():
      bus = can.interface.Bus(bustype='socketcan', channel='vcan0', bitrate=250000, can_filters=[{"can_id": 0x11, "can_mask": 0x21, "extended": False}])
      msg = can.Message(arbitration_id=0xc0ffee,#0x20000088, #0xc0ffee,
                        data=[0, 25, 0, 1, 3, 1, 4, 1],
                        extended_id=True)
      try:
          print "bus: ", bus
          bus.send(msg)
          print("Message sent on {}".format(bus.channel_info))
      except can.CanError:
          print("Message NOT sent")
  
  if __name__ == '__main__':
      send_one()
  </code></pre>
  
  <p>I tried to change the  library code like this,</p>
  
  <pre><code>def set_filters(self, can_filters=None):
      """Apply filtering to all messages received by this Bus.
  
      Calling without passing any filters will reset the applied filters.
  
      :param list can_filters:
          A list of dictionaries each containing a "can_id" and a "can_mask".
  
          &gt;&gt;&gt; [{"can_id": 0x11, "can_mask": 0x21}]
  
          A filter matches, when ``&lt;received_can_id&gt; &amp; can_mask == can_id &amp; can_mask``
  
      """
      filter_struct = pack_filters(can_filters)
      print ("Filter Struct : ", filter_struct, type(filter_struct))
      res = libc.setsockopt(self.socket,
                            SOL_CAN_RAW,
                            CAN_RAW_ERR_FILTER, #CAN_RAW_FILTER,CAN_RAW_ERR_FILTER,
                            filter_struct, len(filter_struct)
                           )
      print("My Code")
      # TODO Is this serious enough to raise a CanError exception?
      if res != 0:
          log.error('Setting filters failed: ' + str(res))
  </code></pre>
  
  <p>The output comes as,</p>
  
  <pre><code> DEBUG:can:can config: {'interface': 'socketcan_ctypes', 'channel': 'vcan0'}
  INFO:can.socketcan.ctypes:Loading socketcan ctypes backend
  INFO:can.socketcan.ctypes:Loading libc with ctypes
  INFO:can.socketcan.native:Loading socketcan native backend
  DEBUG:can.socketcan.native:CAN_* properties not found in socket module. These are required to use native socketcan
  DEBUG:can.socketcan.ctypes:Result of createSocket was 3
  DEBUG:can.socketcan.ctypes:Creating a filtered can bus
  ('Can_mask is : ', 536870911)
  ('The Pack_filer is :', [2684354560, 2684354559], {'can_id': 536870912, 'can_mask': 536870911, 'extended': True}, '=2I')
  Filter Struct :  �����
  My Code
  ERROR:can.socketcan.ctypes:Setting filters failed: -1
  DEBUG:can.socketcan.ctypes:Binding socket with id 3 to channel vcan0
  DEBUG:can.socketcan.ctypes:calling ioctl SIOCGIFINDEX
  INFO:can.socketcan.ctypes:ifr.ifr_ifindex: 22
  DEBUG:can.socketcan.ctypes:bind returned: 0
  DEBUG:can.socketcan.ctypes:Trying to read a msg
  DEBUG:can.socketcan.ctypes:Receiving a message
  </code></pre>