def sweep(port, rate, ID, retry=<NUM_LIT:3>):
if port == '<STR_LIT>':<EOL><INDENT>s = ServoSerial(port, rate, fake=True)<EOL><DEDENT>else:<EOL><INDENT>s = ServoSerial(port, rate)<EOL><DEDENT>if ID < <NUM_LIT:0>:<EOL><INDENT>ID = xl320.XL320_BROADCAST_ADDR<EOL><DEDENT>try:<EOL><INDENT>s.open()<EOL><DEDENT>except SerialException as e:<EOL><INDENT>print('<STR_LIT:->'*<NUM_LIT>)<EOL>print(sys.argv[<NUM_LIT:0>], '<STR_LIT::>')<EOL>print(e)<EOL>exit(<NUM_LIT:1>)<EOL><DEDENT>pkt = makePingPacket(ID)<EOL>s.write(pkt)<EOL>for cnt in range(retry):<EOL><INDENT>ans = s.read()<EOL>if ans:<EOL><INDENT>for pkt in ans:<EOL><INDENT>servo = packetToDict(pkt)<EOL>utils.prettyPrintPacket(servo)<EOL>print('<STR_LIT>'.format(pkt))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print('<STR_LIT>'.format(cnt))<EOL><DEDENT>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT>s.close()<EOL>
Sends a ping packet to ID's from 0 to maximum and prints out any returned
messages.

Actually send a broadcast and will retry (resend) the ping 3 times ...