<commit_before>#
#
import serial
import Command
import time

class Flock(object):
   def __init__(self):
      self.port_num = 0
      self.baudrate = 38400;
    
      # Standard bird settings: Page 20 FOB manual
      self.bytesize = serial.EIGHTBITS
      self.parity = serial.PARITY_NONE
      self.stopbits = serial.STOPBITS_ONE
      self.timeout = 1
    
      self.port = None
    
    
   def open(self):
      self.port = serial.Serial(port=self.port_num,
                                baudrate=self.baudrate,
                                bytesize=self.bytesize,
                                parity=self.parity,
                                stopbits=self.stopbits,
                                timeout=self.timeout)
     
      # Open the port and get started
      #port.open()
      self.port.setRTS(0)            # Don't reset the bird
    
   def setCmdAddr(self, addr):
      """ Set destination addr for next command """
      self.port.write(chr(Command.ToFbbNormal))
      self.port.write(chr(addr))
      
   def getSoftwareRevision(self):
      cmd_ret = self.examineAttribute("SoftwareRevision")
      assert(len(cmd_ret) == 2)
      sw_ver = tuple(map(ord,cmd_ret))
      return sw_ver
   
   def getCurrentError(self):
      cmd_ret = self.examineAttribute("BirdErrorCode")
      assert(len(cmd_ret) == 1)
      error_code = ord(cmd_ret)
      return error_code

   def getAddressingMode(self):
      cmd_ret = self.examineAttribute("AddressingMode")
      assert(len(cmd_ret) == 1)
      return ord(cmd_ret)
   
   def getBirdAddress(self):
      cmd_ret = self.examineAttribute("FbbAddress")
      assert(len(cmd_ret) == 1)<commit_msg>Fix reset issue with RTS.  Before this change, statserial had to be running to hold the state of the RTS line.<commit_after>#
#
import serial
import Command
import time
import sys

class Flock(object):
   def __init__(self):
      self.port_num = 0
      self.baudrate = 38400;
    
      # Standard bird settings: Page 20 FOB manual
      self.bytesize = serial.EIGHTBITS
      self.parity = serial.PARITY_NONE
      self.stopbits = serial.STOPBITS_ONE
      self.timeout = 1
    
      self.port = None
    
    
   def open(self):
      self.port = serial.Serial(port=self.port_num,
                                baudrate=self.baudrate,
                                bytesize=self.bytesize,
                                parity=self.parity,
                                stopbits=self.stopbits,
                                timeout=self.timeout)
     
      # Open the port and get started
      #port.open()
      
      print "Resetting flock",
      sys.stdout.flush()
      self.port.setRTS(1)       # Reset the flock
#      while(self.port.getCTS()):
#         print "x",
      for i in range(5):       # Wait 1 second
         time.sleep(0.2)
         sys.stdout.write(".")
         sys.stdout.flush()
      
      self.port.setRTS(0)       # Set back to working
#      while(not self.port.getCTS()):
#         print ".",
      for i in range(5):       # Wait 1 second
         time.sleep(0.2)
         sys.stdout.write(".")
         sys.stdout.flush()
         
      print "complete."
    
   def setCmdAddr(self, addr):
      """ Set destination addr for next command """
      self.port.write(chr(Command.ToFbbNormal))
      self.port.write(chr(addr))
      
   def getSoftwareRevision(self):
      cmd_ret = self.examineAttribute("SoftwareRevision")
      assert(len(cmd_ret) == 2)
      sw_ver = tuple(map(ord,cmd_ret))
      return sw_ver
   
   def getCurrentError(self):
      cmd_ret = self.examineAttribute("BirdErrorCode")
      assert(len(cmd_ret) == 1)
      error_code = ord(cmd_ret)
      return error_code

   def getAddressingMode(self):
      cmd_ret = self.examineAttribute("AddressingMode")
      assert(len(cmd_ret) == 1)
      return ord(cmd_ret)
   
   def getBirdAddress(self):
      cmd_ret = self.examineAttribute("FbbAddress")
      assert(len(cmd_ret) == 1)
{'fraction_non_alphanumeric': 0.10100502512562815, 'fraction_numerical': 0.0092964824120603, 'mean_word_length': 1.9164835164835166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098116', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1206, 'n_words': 253}