adding delay made it much better
parent
0b6012545d
commit
7a6e6e9176
|
@ -326,6 +326,11 @@ void ICACHE_FLASH_ATTR loop(os_event_t *events) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5ms pause = 200 hz polling
|
||||
// TODO: Ratekeeperize this
|
||||
os_delay_us(5000);
|
||||
|
||||
system_os_post(LOOP_PRIO, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import socket
|
|||
import usb1
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
|
||||
__version__ = '0.0.3'
|
||||
|
||||
|
@ -44,7 +45,9 @@ class PandaWifiStreaming(object):
|
|||
dat, addr = self.sock.recvfrom(0x200*0x10)
|
||||
if addr == (self.ip, self.port):
|
||||
ret += parse_can_buffer(dat)
|
||||
except socket.error:
|
||||
except socket.error as e:
|
||||
if e.errno != 35:
|
||||
traceback.print_exc()
|
||||
break
|
||||
return ret
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import sys
|
|||
import time
|
||||
from helpers import time_many_sends
|
||||
from panda import Panda, PandaWifiStreaming
|
||||
from nose.tools import timed, assert_equal, assert_less, assert_greater
|
||||
|
||||
def test_udp_doesnt_drop():
|
||||
p = Panda()
|
||||
|
@ -10,17 +11,25 @@ def test_udp_doesnt_drop():
|
|||
p.set_can_loopback(True)
|
||||
|
||||
pwifi = PandaWifiStreaming()
|
||||
pwifi.can_recv()
|
||||
|
||||
for i in range(30):
|
||||
pwifi.kick()
|
||||
for msg_count in [1, 100]:
|
||||
for i in range({1: 0x80, 100: 0x10}[msg_count]):
|
||||
pwifi.kick()
|
||||
|
||||
speed = 500
|
||||
p.set_can_speed_kbps(0, speed)
|
||||
comp_kbps = time_many_sends(p, 0, pwifi, msg_count=10)
|
||||
saturation_pct = (comp_kbps/speed) * 100.0
|
||||
speed = 500
|
||||
p.set_can_speed_kbps(0, speed)
|
||||
comp_kbps = time_many_sends(p, 0, pwifi, msg_count=msg_count, msg_id=0x100+i)
|
||||
saturation_pct = (comp_kbps/speed) * 100.0
|
||||
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
if msg_count == 1:
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
print("UDP WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f" % (msg_count, speed, comp_kbps, saturation_pct))
|
||||
assert_greater(saturation_pct, 60)
|
||||
assert_less(saturation_pct, 100)
|
||||
print("")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ from panda import Panda
|
|||
from nose.tools import timed, assert_equal, assert_less, assert_greater
|
||||
import time
|
||||
import os
|
||||
import random
|
||||
|
||||
def connect_wo_esp():
|
||||
# connect to the panda
|
||||
|
@ -27,19 +28,21 @@ def connect_wifi():
|
|||
# TODO: Ubuntu
|
||||
os.system("networksetup -setairportnetwork en0 %s %s" % (ssid, pw))
|
||||
|
||||
def time_many_sends(p, bus, precv=None, msg_count=100):
|
||||
def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None):
|
||||
if precv == None:
|
||||
precv = p
|
||||
if msg_id == None:
|
||||
msg_id = random.randint(0x100, 0x200)
|
||||
|
||||
st = time.time()
|
||||
p.can_send_many([(0x1aa, 0, "\xaa"*8, bus)]*msg_count)
|
||||
p.can_send_many([(msg_id, 0, "\xaa"*8, bus)]*msg_count)
|
||||
r = []
|
||||
|
||||
while len(r) < (msg_count*2) and (time.time() - st) < 3:
|
||||
r.extend(precv.can_recv())
|
||||
|
||||
sent_echo = filter(lambda x: x[3] == 0x80 | bus, r)
|
||||
loopback_resp = filter(lambda x: x[3] == bus, r)
|
||||
sent_echo = filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r)
|
||||
loopback_resp = filter(lambda x: x[3] == bus and x[0] == msg_id, r)
|
||||
|
||||
assert_equal(len(sent_echo), msg_count)
|
||||
assert_equal(len(loopback_resp), msg_count)
|
||||
|
|
Loading…
Reference in New Issue