This is an old revision of the document!
Warning: Declaration of syntax_plugin_wrap_div::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/div.php on line
43
Warning: Declaration of syntax_plugin_wrap_div::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/div.php on line
81
Warning: Declaration of syntax_plugin_wrap_closesection::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/closesection.php on line
23
Warning: Declaration of syntax_plugin_wrap_closesection::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/closesection.php on line
29
Warning: Declaration of syntax_plugin_wrap_span::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/span.php on line
43
Warning: Declaration of syntax_plugin_wrap_span::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in
/var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/span.php on line
63
Warning: Declaration of syntax_plugin_gallery::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in
/var/www/kucjica/emperors-wiki/lib/plugins/gallery/syntax.php on line
51
Warning: Declaration of syntax_plugin_gallery::render($mode, &$R, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in
/var/www/kucjica/emperors-wiki/lib/plugins/gallery/syntax.php on line
147
Warning: Declaration of syntax_plugin_vshare::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in
/var/www/kucjica/emperors-wiki/lib/plugins/vshare/syntax.php on line
47
Warning: Declaration of syntax_plugin_vshare::render($mode, &$R, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in
/var/www/kucjica/emperors-wiki/lib/plugins/vshare/syntax.php on line
107
Warning: preg_match(): Compilation failed: invalid range in character class at offset 3444 in
/var/www/kucjica/emperors-wiki/inc/parser/lexer.php on line
118
A PCRE internal error occured. This might be caused by a faulty plugin
====== quadricone urbaines py ======
<code python>
import serial, subprocess, glob, time, csv, random
### assign arduino's serial port
usbport=glob.glob("/dev/tty*")[0]
### set up serial baud rate
ser = serial.Serial(usbport, 9600, timeout=1)
### the moving part -------------------
class Servo:
def __init__(self, servoID):
self.servoID=servoID
self.stop() # when initiated, stop!
def move(self, speed):
self.speed=speed
if (0 <= self.speed <= 180):
ser.write(chr(255))
ser.write(chr(self.servoID))
ser.write(chr(self.speed))
else:
print "Servo position must be an integer between 0 and 180.\n"
def stop(self):
self.move(90)
def down_slow(self):
self.move(100)
def down(self):
self.move(120)
def up(self):
self.move(80)
## initiate the morots and put them all in the STOP (90) position
## alternative
Servos = ["raja","gaja","vlaja", "zlaja"]
for i,servo in enumerate(Servos):
globals()[servo]=Servo(i+1)
globals()[servo].stop()
### the scanning part -----------------
# airodump-ng is running and logging the results into a csv file
# with the following command: sudo airodump-ng -o csv -w manuf mon0
# subprocess looks for the last edited csv file in current folder
# this file is parsed by the csv module to find the number of data packets that have passed through the network since the last check
csvs=subprocess.Popen("ls -t1 *csv | head -1", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
csv_last=csvs.communicate()[0].strip()
key_value=(' # IV') # look up this value in the scan dump
def lookup(dump):
datas=[]
results=[]
scan=open(dump, "rU")
next(scan)
scanDict=csv.DictReader((line.replace('\0','') for line in scan), delimiter=',')
for adict in scanDict:
if adict.has_key(key_value) and adict.get(key_value)!=None:
try:
datas.append(int(adict.get(key_value)))
except:
pass
datas.sort(reverse=True)
for i in range(4):
results.append(datas[i])
return results
### the main loop ----------------------
packet_list=lookup(csv_last)
print 'packet_list', packet_list
#random.shuffle(servo_list)
#print 'servo_list', servo_list
time.sleep(3)
while True:
new_packet_list=lookup(csv_last)
print "////////////////////////"
print " "
print 'new_packet_list', new_packet_list
print 'calculating the movements...'
for i,servo in enumerate(Servos):
print 'servo', servo
packet_diff=new_packet_list[i]-packet_list[i]
print 'packet_diff:', packet_diff
if packet_diff==0:
print 'go back up'
globals()[servo].up()
time.sleep(1)
globals()[servo].stop()
elif packet_diff < 10:
print 'up, little'
globals()[servo].up()
time.sleep(0.5)
globals()[servo].stop()
elif packet_diff >= 10:
print 'down, little'
globals()[servo].down_slow()
time.sleep(1)
globals()[servo].stop()
elif packet_diff >= 100:
print 'go down, big'
globals()[servo].down()
time.sleep(2)
globals()[servo].stop()
packet_list=new_packet_list # update packet list
time.sleep(15)
</code>