def cum_serial(self, raw,rev=0):
    """ Cumulate serial data
        and return times(int)
        計算數據重複（持續）次數
    """
    org = raw[1:]
    diff = raw[:-1]
    result = []
    for i in xrange(len(org)):
      result.append(self.high_or_low(org[i], diff[i],rev))

    times = 0
    try:
      if result[-1] == result[-2]:
        signal = result[-1]
        re_signal = result[:]
        try:
          while signal == re_signal[-1]:
            re_signal.pop()
            times += 1
        except:
          pass
      else:
        times += 1
    except:
      times = '?'

    if self.debug:
      for i in result:
        print i

    self.debug_print(times)
    return times