Skip to content

Commit

Permalink
Merge pull request #116 from commaai/revert-114-new_panda_code
Browse files Browse the repository at this point in the history
Revert "Pulled in new panda firmware and updated boardd to support the changes."
  • Loading branch information
geohot authored Jul 18, 2017
2 parents 317ae0f + 1581fdc commit 68485aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 87 deletions.
2 changes: 1 addition & 1 deletion cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct CanData {
address @0 :UInt32;
busTime @1 :UInt16;
dat @2 :Data;
src @3 :UInt8;
src @3 :Int8;
}

struct ThermalData {
Expand Down
2 changes: 1 addition & 1 deletion panda
Submodule panda updated 59 files
+1 −5 .gitignore
+8 −23 README.md
+10 −30 TODO
+0 −3 __init__.py
+1 −0 board/.gitignore
+3 −1 board/Makefile
+1 −1 board/Makefile.legacy
+0 −0 board/__init__.py
+1 −0 board/adc.h
+1 −0 board/bootstub.c
+37 −37 board/build.mk
+0 −487 board/can.c
+117 −85 board/can.h
+0 −21 board/config.h
+1 −0 board/dac.h
+0 −122 board/early.c
+98 −14 board/early.h
+1 −2 board/get_sdk.sh
+0 −144 board/gpio.c
+251 −5 board/gpio.h
+7 −18 board/honda_safety.h
+0 −66 board/libc.c
+69 −8 board/libc.h
+0 −37 board/llgpio.c
+0 −23 board/llgpio.h
+462 −121 board/main.c
+13 −0 board/panda_safety.h
+0 −39 board/rev.h
+0 −96 board/safety.c
+0 −27 board/safety.h
+0 −51 board/spi.c
+44 −6 board/spi.h
+0 −2 board/spi_flasher.h
+1 −0 board/timer.h
+20 −26 board/tools/enter_download_mode.py
+0 −209 board/uart.c
+69 −47 board/uart.h
+0 −661 board/usb.c
+541 −50 board/usb.h
+3 −14 boardesp/proxy.c
+0 −12 boardesp/tools/esptool.py
+1 −2 boardesp/webserver.c
+ buy.png
+0 −6 drivers/linux/.gitignore
+0 −6 drivers/linux/Makefile
+0 −618 drivers/linux/panda.c
+0 −2 drivers/linux/test/Makefile
+0 −120 drivers/linux/test/main.c
+0 −4 drivers/linux/test/run.sh
+0 −0 lib/__init__.py
+65 −86 lib/panda.py
+0 −2 setup.cfg
+0 −63 setup.py
+0 −0 tests/__init__.py
+0 −37 tests/can_printer.py
+7 −12 tests/debug_console.py
+47 −78 tests/loopback_test.py
+9 −11 tests/standalone_test.py
+14 −18 tests/throughput_test.py
40 changes: 9 additions & 31 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ pthread_mutex_t usb_lock;

bool spoofing_started = false;
bool fake_send = false;
bool loopback_can = false;

// double the FIFO size
#define RECV_SIZE (0x1000)
#define TIMEOUT 0

#define SAFETY_NOOUTPUT 0x0000
#define SAFETY_HONDA 0x0001
#define SAFETY_ALLOUTPUT 0x1337

bool usb_connect() {
int err;

Expand All @@ -53,36 +48,22 @@ bool usb_connect() {
err = libusb_claim_interface(dev_handle, 0);
if (err != 0) { return false; }

if(loopback_can) {
libusb_control_transfer(dev_handle, 0xc0, 0xe5, 1, 0, NULL, 0, TIMEOUT);
}

// power off ESP
libusb_control_transfer(dev_handle, 0xc0, 0xd9, 0, 0, NULL, 0, TIMEOUT);

// forward CAN1 to CAN3...soon
//libusb_control_transfer(dev_handle, 0xc0, 0xdd, 1, 2, NULL, 0, TIMEOUT);

// set UART modes for Honda Accord
for (int uart = 2; uart <= 3; uart++) {
// 9600 baud
libusb_control_transfer(dev_handle, 0x40, 0xe1, uart, 9600, NULL, 0, TIMEOUT);
libusb_control_transfer(dev_handle, 0xc0, 0xe1, uart, 9600, NULL, 0, TIMEOUT);
// even parity
libusb_control_transfer(dev_handle, 0x40, 0xe2, uart, 1, NULL, 0, TIMEOUT);
libusb_control_transfer(dev_handle, 0xc0, 0xe2, uart, 1, NULL, 0, TIMEOUT);
// callback 1
libusb_control_transfer(dev_handle, 0x40, 0xe3, uart, 1, NULL, 0, TIMEOUT);
libusb_control_transfer(dev_handle, 0xc0, 0xe3, uart, 1, NULL, 0, TIMEOUT);
}

// TODO: Boardd should be able to set the baud rate
int baud = 500000;
libusb_control_transfer(dev_handle, 0x40, 0xde, 0, 0,
(unsigned char *)&baud, sizeof(baud), TIMEOUT); // CAN1
libusb_control_transfer(dev_handle, 0x40, 0xde, 1, 0,
(unsigned char *)&baud, sizeof(baud), TIMEOUT); // CAN2

// TODO: Boardd should be able to be told which safety model to use
libusb_control_transfer(dev_handle, 0x40, 0xdc, SAFETY_HONDA, 0, NULL, 0, TIMEOUT);

return true;
}

Expand All @@ -109,7 +90,7 @@ void can_recv(void *s) {

// do recv
pthread_mutex_lock(&usb_lock);

do {
err = libusb_bulk_transfer(dev_handle, 0x81, (uint8_t*)data, RECV_SIZE, &recv, TIMEOUT);
if (err != 0) { handle_usb_issue(err, __func__); }
Expand Down Expand Up @@ -146,13 +127,13 @@ void can_recv(void *s) {
canData[i].setBusTime(data[i*4+1] >> 16);
int len = data[i*4+1]&0xF;
canData[i].setDat(kj::arrayPtr((uint8_t*)&data[i*4+2], len));
canData[i].setSrc((data[i*4+1] >> 4) & 0xff);
canData[i].setSrc((data[i*4+1] >> 4) & 0xf);
}

// send to can
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
zmq_send(s, bytes.begin(), bytes.size(), 0);
zmq_send(s, bytes.begin(), bytes.size(), 0);
}

void can_health(void *s) {
Expand Down Expand Up @@ -200,7 +181,7 @@ void can_health(void *s) {
// send to health
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
zmq_send(s, bytes.begin(), bytes.size(), 0);
zmq_send(s, bytes.begin(), bytes.size(), 0);
}


Expand Down Expand Up @@ -335,10 +316,6 @@ int main() {
fake_send = true;
}

if(getenv("BOARDD_LOOPBACK")){
loopback_can = true;
}

// init libusb
err = libusb_init(&ctx);
assert(err == 0);
Expand Down Expand Up @@ -380,3 +357,4 @@ int main() {
libusb_close(dev_handle);
libusb_exit(ctx);
}

6 changes: 1 addition & 5 deletions selfdrive/boardd/boardd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

# TODO: rewrite in C to save CPU

SAFETY_NOOUTPUT = 0
SAFETY_HONDA = 1
SAFETY_ALLOUTPUT = 0x1337

# *** serialization functions ***
def can_list_to_can_capnp(can_msgs, msgtype='can'):
dat = messaging.new_message()
Expand Down Expand Up @@ -98,7 +94,6 @@ def can_init():
if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddcc:
handle = device.open()
handle.claimInterface(0)
handle.controlWrite(0x40, 0xdc, SAFETY_HONDA, 0, b'')

if handle is None:
print "CAN NOT FOUND"
Expand Down Expand Up @@ -195,3 +190,4 @@ def main(gctx=None):

if __name__ == "__main__":
main()

49 changes: 0 additions & 49 deletions selfdrive/boardd/test_boardd_loopback.py

This file was deleted.

0 comments on commit 68485aa

Please sign in to comment.