canid

sweep_cd

Mar 15th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. def sweep_cd():
  2.     samples = 3000
  3.     threshold = 0.995
  4.     chan_high = 0b1
  5.     hf_pll = 0b01
  6.     SPI.open(1, 0)
  7.     try:
  8.         set_stand_by()
  9.  
  10.         for chan_low in range(0b00000000, 0b11111111):
  11.             SPI.xfer2([0b00000000, chan_low, 0b00001100, 0b01000100, 0b01000100, 0b00000100, myAddr[0], myAddr[1], myAddr[2], myAddr[3], 0b11011111])
  12.             set_rx()
  13.             presence = 0.0
  14.             for sample in range(0, samples):
  15.                 if GPIO.input("P9_12"): presence = presence+1
  16.             sys.stdout.write ( '\033[94m'+"[+]"+'\033[0m'+"Carrier found at "+str((422+(float(chan_low)/10))*(1))+"Mhz; stability "+str(presence/samples)+".\n" if (presence/samples)>threshold else "")
  17.         for chan_low in range(0b00000000, 0b11111111):
  18.             SPI.xfer2([0b00000000, chan_low, 0b00001100|chan_high, 0b01000100, 0b01000100, 0b00000100, myAddr[0], myAddr[1], myAddr[2], myAddr[3], 0b11011111])
  19.             set_rx()
  20.             presence = 0.0
  21.             for sample in range(0, int(samples)):
  22.                 if GPIO.input("P9_12"): presence = presence+1
  23.             sys.stdout.write( '\033[94m'+"[+]"+'\033[0m'+"Carrier found at "+str((422+(float(chan_low|0b100000000)/10))*(1))+"Mhz; Stability "+str(presence/samples)+".\n" if (presence/samples)>threshold else "")
  24.  
  25.         for chan_low in range(0b00000000, 0b11111111):
  26.             SPI.xfer2([0b00000000, chan_low, 0b00001100|hf_pll, 0b01000100, 0b01000100, 0b00000100, myAddr[0], myAddr[1], myAddr[2], myAddr[3], 0b11011111])
  27.             set_rx()
  28.             presence = 0.0
  29.             for sample in range(0, int(samples)):
  30.                 if GPIO.input("P9_12"): presence = presence+1
  31.             sys.stdout.write( '\033[94m'+"[+]"+'\033[0m'+"Carrier found at "+str((422+(float(chan_low)/10))*(2))+"Mhz; stability "+str(presence/samples)+".\n" if (presence/samples)>threshold else "")
  32.  
  33.         for chan_low in range(0b00000000, 0b11111111):
  34.             SPI.xfer2([0b00000000, chan_low, 0b00001100|chan_high|hf_pll, 0b01000100, 0b01000100, 0b00000100, myAddr[0], myAddr[1], myAddr[2], myAddr[3], 0b11011111])
  35.             set_rx()
  36.             presence = 0.0
  37.             for sample in range(0, int(samples)):
  38.                 if GPIO.input("P9_12"): presence = presence+1
  39.             sys.stdout.write( '\033[94m'+"[+]"+'\033[0m'+"Carrier found at "+str((422+(float(chan_low|0b100000000)/10))*(2))+"Mhz; stability "+str(presence/samples)+".\n" if (presence/samples)>threshold else "")
  40.  
  41.     finally:
  42.         SPI.close()
Advertisement
Add Comment
Please, Sign In to add comment