From 97a7e6617f8ad06b7bff495603200b853766ecc8 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 17 Jan 2018 07:45:32 +0100 Subject: basic test for eos & fe310 passed --- code/ecp/fe310/transport.c | 1 + code/esp32/components/eos/fe310.c | 6 +++--- code/esp32/components/eos/transport.c | 2 +- code/fe310/eos/ecp.c | 4 ++++ code/fe310/eos/ecp.h | 3 ++- code/fe310/eos/eos.c | 2 +- code/fe310/eos/spi.h | 4 ++-- code/test/client.c | 6 ++++++ 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/code/ecp/fe310/transport.c b/code/ecp/fe310/transport.c index 9ff04ca..99a1b10 100644 --- a/code/ecp/fe310/transport.c +++ b/code/ecp/fe310/transport.c @@ -34,6 +34,7 @@ static ssize_t t_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr if (packet && packet->buffer) buf = packet->buffer-addr_len; } else { buf = eos_net_alloc(); + memcpy(buf+addr_len, packet->buffer, msg_size); } if (buf == NULL) return ECP_ERR; memcpy(buf, addr->host, sizeof(addr->host)); diff --git a/code/esp32/components/eos/fe310.c b/code/esp32/components/eos/fe310.c index 6dceb51..a3552f9 100644 --- a/code/esp32/components/eos/fe310.c +++ b/code/esp32/components/eos/fe310.c @@ -23,8 +23,8 @@ static EOSMsgQ send_q; static EOSMsgItem send_q_array[EOS_FE310_SIZE_Q]; -#define SPI_GPIO_RTS 4 -#define SPI_GPIO_CTS 2 +#define SPI_GPIO_RTS 16 +#define SPI_GPIO_CTS 17 #define SPI_GPIO_MOSI 23 #define SPI_GPIO_MISO 19 #define SPI_GPIO_SCLK 18 @@ -92,7 +92,7 @@ static void worker(void *pvParameters) { xSemaphoreTake(mutex, portMAX_DELAY); } else { - ESP_LOGI(TAG, "FE310 RECV NULL"); + // ESP_LOGI(TAG, "FE310 RECV NULL"); } // vTaskDelay(5000 / portTICK_PERIOD_MS); } diff --git a/code/esp32/components/eos/transport.c b/code/esp32/components/eos/transport.c index 162fe86..9a9309c 100755 --- a/code/esp32/components/eos/transport.c +++ b/code/esp32/components/eos/transport.c @@ -60,7 +60,7 @@ static int t_open(void) { memset((char *)&_myaddr, 0, sizeof(_myaddr)); _myaddr.sin_family = AF_INET; _myaddr.sin_addr.s_addr = htonl(INADDR_ANY); - _myaddr.sin_port = htons(0); + _myaddr.sin_port = htons(3000); int rv = bind(udp_sock, (struct sockaddr *)&_myaddr, sizeof(_myaddr)); if (rv < 0) { diff --git a/code/fe310/eos/ecp.c b/code/fe310/eos/ecp.c index 433e693..190d1f0 100644 --- a/code/fe310/eos/ecp.c +++ b/code/fe310/eos/ecp.c @@ -63,4 +63,8 @@ int ecp_init(ECPContext *ctx) { eos_evtq_set_handler(EOS_EVT_MASK_NET | EOS_NET_CMD_PKT, packet_handler); return ECP_OK; +} + +void ecp_sock_set(ECPSocket *s) { + _sock = s; } \ No newline at end of file diff --git a/code/fe310/eos/ecp.h b/code/fe310/eos/ecp.h index 95aed31..9cc84db 100644 --- a/code/fe310/eos/ecp.h +++ b/code/fe310/eos/ecp.h @@ -1,3 +1,4 @@ #include -int ecp_init(ECPContext *ctx); \ No newline at end of file +int ecp_init(ECPContext *ctx); +void ecp_sock_set(ECPSocket *s); \ No newline at end of file diff --git a/code/fe310/eos/eos.c b/code/fe310/eos/eos.c index 3ad3b68..8dbfdac 100644 --- a/code/fe310/eos/eos.c +++ b/code/fe310/eos/eos.c @@ -13,5 +13,5 @@ void eos_init(void) { } void eos_start(void) { - eos_net_start(15); + eos_net_start(255); } \ No newline at end of file diff --git a/code/fe310/eos/spi.h b/code/fe310/eos/spi.h index 88e54bb..7e281b8 100644 --- a/code/fe310/eos/spi.h +++ b/code/fe310/eos/spi.h @@ -11,8 +11,8 @@ #define SPI_SIZE_BUF 1500 #define SPI_SIZE_CHUNK 4 #define SPI_SIZE_BUFQ 4 -#define SPI_GPIO_CTS_OFFSET PIN_2_OFFSET -#define SPI_GPIO_RTS_OFFSET PIN_3_OFFSET +#define SPI_GPIO_RTS_OFFSET PIN_8_OFFSET +#define SPI_GPIO_CTS_OFFSET PIN_7_OFFSET #define SPI_IOF_MASK (((uint32_t)1 << IOF_SPI1_SCK) | ((uint32_t)1 << IOF_SPI1_MOSI) | ((uint32_t)1 << IOF_SPI1_MISO)) typedef struct SPIBuffer { diff --git a/code/test/client.c b/code/test/client.c index 03b459f..3ec6eb7 100644 --- a/code/test/client.c +++ b/code/test/client.c @@ -36,6 +36,12 @@ ssize_t handle_open_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsign ssize_t handle_msg_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s, ECP2Buffer *b) { printf("MSG C:%s size:%ld\n", p, s); + char *msg = "PERA JE CAR!"; + unsigned char buf[1000]; + + strcpy((char *)buf, msg); + ssize_t _rv = ecp_send(conn, MTYPE_MSG, buf, 1000); + return s; } -- cgit v1.2.3