User Tools

Site Tools


motors-scanner-test-1

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 14

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 14

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 0

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 0

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 0

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 0

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 0

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 0

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 0

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 0

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

====== salzamt, linz, 11. 09. 2012 ====== airodump-ng is scanning the wifi this code parses the .csv file airodump is writing to and uses the value of '#IV's or the amount of data packets to send positional values to linear actuators. <code python> import subprocess, glob, time, csv from arduino import Arduino, Servo # scanning part ----------------- # airodump-ng is running and logging the results into a csv file # 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 listlasted=subprocess.Popen("ls -ct1 *csv | head -1", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) lasted=listlasted.communicate()[0].strip() print lasted # reading the scan log from a csv file def lookup(dump): 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(' # IV'): data=adict.get(' # IV') return data packets=int(lookup(lasted)) print 'packets', packets # moving part ------------------- portz=glob.glob("/dev/ttyUSB*")[0] #print portz my_board=Arduino(portz) my_board.output([9, 10]) linearone=my_board.attachServo(9) lineartwo=my_board.attachServo(10) # !!!! motors are not in sync!!!! # extreme positions of the motor one and two: linearone_max = 139 lineartwo_max = 121 linearone_min = 72 lineartwo_min = 87 # | linear one | # 72 - - - - - - - - - - 139 # | linear two | # 87 - - - - - - - - - - 121 # thus a dictionary of compatible values tupples is used to make sure the two motors are always in the same position positions = {0:[(72,87)],1:[(73,88)],2:[(74,88)],3:[(75,89)],4:[(76,90)],5:[(77,90)],6:[(78,91)],7:[(82,92)],8:[(88,95)],9:[(93,98)],10:[(100,101)],11:[(110,108)],12:[(114,109)],13:[(120,111)],14:[(124,113)],15:[(125,114)],16:[(128,115)],17:[(129,116)],18:[(130,117)],19:[(132,118)],20:[(135,119)],21:[(137,120)],22:[(139,121)]} # put the motors in the minimum position linear_one.write(positions[0][0][0]) linear_two.write(positions[0][0][1]) time.sleep(10) # the main loop ----------------- # lookup function checks for difference in the number of packets # it sends the motors to a new position accordingly key_pos=0 max_pos=len(positions)-1 while True: newPackets=int(lookup(lasted)) packetsDiff=newPackets-packets print 'packetsDiff', packetsDiff # decide whether to stretch or shrink: if packetsDiff>=10 and packetsDiff<50 and key_pos<max_pos: new_key=key_pos+2 print 'linear1 should stretch',positions[new_key][0][0] print 'linear2 should stretch',positions[new_key][0][1] print 'current key_pos: ' + str(new_key) + " .. was oldkey: " + str(key_pos) linearone.write(positions[new_key][0][0]) time.sleep(0.3) lineartwo.write(positions[new_key][0][1]) time.sleep(0.3) key_pos=new_key #update position elif packetsDiff>50 and key_pos<max_pos: new_key=key_pos+5 print 'linear1 should stretch',positions[new_key][0][0] print 'linear2 should stretch',positions[new_key][0][1] linearone.write(positions[new_key][0][0]) time.sleep(0.3) lineartwo.write(positions[new_key][0][1]) time.sleep(0.3) if key_pos>=max_pos: key_pos=max_pos #reset position else: key_pos=new_key #update position elif packetsDiff<=0 and key_pos>0: new_key=key_pos-2 print 'linear1 should shrink',positions[new_key][0][0] print 'linear2 should shrink',positions[new_key][0][1] print 'current key_pos: ' + str(new_key) + " .. was oldkey: " + str(key_pos) linearone.write(positions[new_key][0][0]) time.sleep(0.3) lineartwo.write(positions[new_key][0][1]) time.sleep(0.3) key_pos=new_key #update position else: print "else: packetDiff is too little", packetsDiff new_key=key_pos print 'nothing changed, will stay in the position', positions[new_key] time.sleep(3) packets=newPackets #updates the packets </code>

motors-scanner-test-1.1348523687.txt.gz · Last modified: 2012/09/24 21:54 by 81.10.185.142