Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
appleguru committed Nov 13, 2017
2 parents 4edd5c3 + 284e47e commit 207165f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 12 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
language: python

addons:
apt:
packages:
- gcc-arm-none-eabi
- libnewlib-arm-none-eabi
- gperf
- texinfo
- help2man

script:
- python setup.py install
- pushd board && make bin && popd
- pushd boardesp && git clone --recursive https://github.com/pfalcon/esp-open-sdk.git && pushd esp-open-sdk && git checkout 03f5e898a059451ec5f3de30e7feff30455f7cec && LD_LIBRARY_PATH="" make STANDALONE=y && popd && popd
- pushd boardesp && make user1.bin && popd
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?

It is 2nd gen hardware, reusing code and parts from the [NEO](https://github.com/commaai/neo) interface board.

[![Build Status](https://travis-ci.org/commaai/panda.svg?branch=master)](https://travis-ci.org/commaai/panda)

Usage
------

Expand Down
2 changes: 1 addition & 1 deletion boardesp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ flashall: user1.bin user2.bin
proxy-0x00000.bin: proxy
../panda/esptool.py elf2image $^

proxy: proxy.o
proxy: proxy.o elm327.o webserver.o sha.o

obj/proxy.o: proxy.c
$(CC) $(CFLAGS) -c $^ -o $@
Expand Down
57 changes: 46 additions & 11 deletions boardesp/webserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@

#define MAX_RESP 0x800
char resp[MAX_RESP];
char staticpage[] = "HTTP/1.0 200 OK\nContent-Type: text/html\n\n"
"<pre>This is your comma.ai panda<br/><br/>"
"It's open source. Find the code <a href=\"https://github.com/commaai/panda\">here</a><br/>"
"Designed to work with our dashcam, <a href=\"http://chffr.comma.ai\">chffr</a><br/>";
char pageheader[] = "HTTP/1.0 200 OK\nContent-Type: text/html\n\n"
"<!DOCTYPE html>\n"
"<html>\n"
"<head>\n"
"<title>Panda</title>\n"
"</head>\n"
"<body>\n"
"<pre>This is your comma.ai panda\n\n"
"It's open source. Find the code <a href=\"https://github.com/commaai/panda\">here</a>\n"
"Designed to work with our dashcam, <a href=\"http://chffr.comma.ai\">chffr</a>\n";

char pagefooter[] = "</pre>\n"
"</body>\n"
"</html>\n";

char OK_header[] = "HTTP/1.0 200 OK\nContent-Type: text/html\n\n";

static struct espconn web_conn;
static esp_tcp web_proto;
Expand Down Expand Up @@ -175,26 +187,47 @@ static void ICACHE_FLASH_ATTR web_rx_cb(void *arg, char *data, uint16_t len) {
if (memcmp(data, "GET / ", 6) == 0) {
memset(resp, 0, MAX_RESP);

strcpy(resp, staticpage);
ets_strcat(resp, "<br/>ssid: ");
strcpy(resp, pageheader);
ets_strcat(resp, "\nssid: ");
ets_strcat(resp, ssid);
ets_strcat(resp, "<br/>");
ets_strcat(resp, "\n");

ets_strcat(resp, "<br/>st version: ");
ets_strcat(resp, "\nst version: ");
uint32_t recvData[0x11];
int len = spi_comm("\x00\x00\x00\x00\x40\xD6\x00\x00\x00\x00\x40\x00", 0xC, recvData, 0x40);
ets_memcpy(resp+strlen(resp), recvData+1, len);

ets_strcat(resp, "<br/>esp version: ");
ets_strcat(resp, "\nesp version: ");
ets_strcat(resp, gitversion);
uint8_t current = system_upgrade_userbin_check();
if (current == UPGRADE_FW_BIN1) {
ets_strcat(resp, "<br/>esp flash file: user2.bin");
ets_strcat(resp, "\nesp flash file: user2.bin");
} else {
ets_strcat(resp, "<br/>esp flash file: user1.bin");
ets_strcat(resp, "\nesp flash file: user1.bin");
}

ets_strcat(resp,"\nSet USB Mode:"
"<button onclick=\"var xhr = new XMLHttpRequest(); xhr.open('GET', 'set_property?usb_mode=0'); xhr.send()\" type='button'>Client</button>"
"<button onclick=\"var xhr = new XMLHttpRequest(); xhr.open('GET', 'set_property?usb_mode=1'); xhr.send()\" type='button'>CDP</button>"
"<button onclick=\"var xhr = new XMLHttpRequest(); xhr.open('GET', 'set_property?usb_mode=2'); xhr.send()\" type='button'>DCP</button>\n");

ets_strcat(resp, pagefooter);

espconn_send_string(&web_conn, resp);
espconn_disconnect(conn);

} else if (memcmp(data, "GET /set_property?usb_mode=", 27) == 0) {
char mode_value = data[27] - '0';
if (mode_value >= '\x00' && mode_value <= '\x02') {
memset(resp, 0, MAX_RESP);
char set_usb_mode_packet[] = "\x00\x00\x00\x00\x40\xE6\x00\x00\x00\x00\x40\x00";
set_usb_mode_packet[6] = mode_value;
uint32_t recvData[1];
spi_comm(set_usb_mode_packet, 0xC, recvData, 0);
os_sprintf(resp, "%sUSB Mode set to %02x\n\n", OK_header, mode_value);
espconn_send_string(&web_conn, resp);
espconn_disconnect(conn);
}
} else if (memcmp(data, "PUT /stupdate ", 14) == 0) {
os_printf("init st firmware\n");
char *cl = strstr(data, "Content-Length: ");
Expand All @@ -210,6 +243,7 @@ static void ICACHE_FLASH_ATTR web_rx_cb(void *arg, char *data, uint16_t len) {
memset(st_firmware, 0, real_content_length);
state = RECEIVING_ST_FIRMWARE;
}

} else if ((memcmp(data, "PUT /espupdate1 ", 16) == 0) ||
(memcmp(data, "PUT /espupdate2 ", 16) == 0)) {
// 0x1000 = user1.bin
Expand Down Expand Up @@ -241,6 +275,7 @@ static void ICACHE_FLASH_ATTR web_rx_cb(void *arg, char *data, uint16_t len) {
start_address = esp_address;
}
} else {
espconn_send_string(&web_conn, "HTTP/1.0 404 Not Found\nContent-Type: text/html\n\n404 Not Found!\n");
espconn_disconnect(conn);
}
} else if (state == RECEIVING_ST_FIRMWARE) {
Expand Down

0 comments on commit 207165f

Please sign in to comment.