serial echo test is failing

master
Firmware Batman 2017-07-18 12:15:19 -07:00
parent bd57d8be56
commit 56786dac17
4 changed files with 38 additions and 20 deletions

View File

@ -87,8 +87,6 @@ void can_init(uint8_t bus_number) {
if (tmp == CAN_TIMEOUT) {
set_led(LED_BLUE, 1);
puts("CAN init FAILED!!!!!\n");
} else {
puts("CAN init done\n");
}
// accept all filter

View File

@ -686,21 +686,8 @@ void usb_irqhandler(void) {
// now for clarity.
//TODO add default case. Should it NAK?
switch(current_int0_alt_setting){
case 0: ////// Bulk config
// *** IN token received when TxFIFO is empty
if (USBx_INEP(1)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) {
#ifdef DEBUG_USB
puts(" IN PACKET QUEUE\n");
#endif
// TODO: always assuming max len, can we get the length?
USB_WritePacket((void *)resp, usb_cb_ep1_in(resp, 0x40, 1), 1);
}
break;
case 1: ////// Interrupt config
// Check if there is anything to actually send.
if (can_rx_q.w_ptr != can_rx_q.r_ptr) {
switch (current_int0_alt_setting) {
case 0: ////// Bulk config
// *** IN token received when TxFIFO is empty
if (USBx_INEP(1)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) {
#ifdef DEBUG_USB
@ -709,8 +696,21 @@ void usb_irqhandler(void) {
// TODO: always assuming max len, can we get the length?
USB_WritePacket((void *)resp, usb_cb_ep1_in(resp, 0x40, 1), 1);
}
}
break;
break;
case 1: ////// Interrupt config
// Check if there is anything to actually send.
if (can_rx_q.w_ptr != can_rx_q.r_ptr) {
// *** IN token received when TxFIFO is empty
if (USBx_INEP(1)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) {
#ifdef DEBUG_USB
puts(" IN PACKET QUEUE\n");
#endif
// TODO: always assuming max len, can we get the length?
USB_WritePacket((void *)resp, usb_cb_ep1_in(resp, 0x40, 1), 1);
}
}
break;
}
// clear interrupts

View File

@ -78,6 +78,11 @@ class Panda(object):
SAFETY_HONDA = 1
SAFETY_ALLOUTPUT = 0x1337
SERIAL_DEBUG = 0
SERIAL_ESP = 1
SERIAL_LIN1 = 2
SERIAL_LIN2 = 3
REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE
REQUEST_OUT = usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE
@ -229,7 +234,13 @@ class Panda(object):
# ******************* serial *******************
def serial_read(self, port_number):
return self._handle.controlRead(Panda.REQUEST_IN, 0xe0, port_number, 0, 0x40)
ret = []
while 1:
lret = bytes(self._handle.controlRead(Panda.REQUEST_IN, 0xe0, port_number, 0, 0x40))
if len(lret) == 0:
break
ret.append(lret)
return b''.join(ret)
def serial_write(self, port_number, ln):
return self._handle.bulkWrite(2, chr(port_number) + ln)

View File

@ -127,6 +127,7 @@ def test_throughput():
st = time.time()
p.can_send_many([(0x1aa, 0, "\xaa"*8, 0)]*MSG_COUNT)
r = []
while len(r) < 200 and (time.time() - st) < 3:
r.extend(p.can_recv())
@ -147,3 +148,11 @@ def test_throughput():
print("loopback 100 messages at speed %d in %.2f ms, comp speed is %.2f, percent %.2f" % (speed, et, comp_kbps, saturation_pct))
def test_serial_echo():
p = connect_wo_esp()
print(p.serial_read(Panda.SERIAL_DEBUG))
p.serial_write(Panda.SERIAL_DEBUG, "swag")
assert_equal(p.serial_read(Panda.SERIAL_DEBUG), "swag")