summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-01-20 06:26:28 +0100
committerUros Majstorovic <majstor@majstor.org>2018-01-20 06:26:28 +0100
commit1847482a7bc975e8a171cd1df9257647ab6b66f5 (patch)
tree028901a5d4c6944f29d79b9774f3cb38d1263cf2 /code
parent116a4e241861dd35a61a822adb7badc42e8c81ee (diff)
foxed esp32 semaphore bug
Diffstat (limited to 'code')
-rw-r--r--code/esp32/components/eos/fe310.c5
-rwxr-xr-xcode/esp32/components/eos/transport.c4
-rw-r--r--code/fe310/eos/eos.c2
-rw-r--r--code/test/client.c22
4 files changed, 27 insertions, 6 deletions
diff --git a/code/esp32/components/eos/fe310.c b/code/esp32/components/eos/fe310.c
index a3552f9..b13d653 100644
--- a/code/esp32/components/eos/fe310.c
+++ b/code/esp32/components/eos/fe310.c
@@ -161,8 +161,9 @@ void eos_fe310_init(void) {
assert(ret==ESP_OK);
eos_msgq_init(&send_q, send_q_array, EOS_FE310_SIZE_Q);
- mutex = xSemaphoreCreateMutex();
- xTaskCreate(&worker, "fe310_receiver", 4096, NULL, 5, NULL);
+ mutex = xSemaphoreCreateBinary();
+ xSemaphoreGive(mutex);
+ xTaskCreatePinnedToCore(&worker, "fe310_receiver", 4096, NULL, 5, NULL, 1);
}
int eos_fe310_send(unsigned char cmd, unsigned char *buffer, uint16_t len) {
diff --git a/code/esp32/components/eos/transport.c b/code/esp32/components/eos/transport.c
index 9a9309c..597be61 100755
--- a/code/esp32/components/eos/transport.c
+++ b/code/esp32/components/eos/transport.c
@@ -158,7 +158,7 @@ static esp_err_t esp32_wifi_event_handler(void *ctx, system_event_t *event) {
ESP_LOGI(TAG, "* - Our IP address is: " IPSTR, IP2STR(&event->event_info.got_ip.ip_info.ip));
ESP_LOGI(TAG, "********************************************");
t_open();
- xTaskCreate(&receiver, "receiver", 4096, NULL, 5, &receiver_task);
+ xTaskCreatePinnedToCore(&receiver, "receiver", 4096, NULL, 5, &receiver_task, 1);
eos_fe310_send(EOS_FE310_CMD_CONNECT, NULL, 0);
break;
@@ -175,7 +175,7 @@ void eos_net_init(void) {
memset(&wifi_config, 0, sizeof(wifi_config));
tcpip_adapter_init();
- ESP_ERROR_CHECK( nvs_flash_init() );
+// ESP_ERROR_CHECK( nvs_flash_init() );
ESP_ERROR_CHECK( esp_event_loop_init(esp32_wifi_event_handler, NULL) );
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
diff --git a/code/fe310/eos/eos.c b/code/fe310/eos/eos.c
index 8dbfdac..5ad40cc 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(255);
+ eos_net_start(31);
} \ No newline at end of file
diff --git a/code/test/client.c b/code/test/client.c
index 3ec6eb7..b8a2ba5 100644
--- a/code/test/client.c
+++ b/code/test/client.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <sys/time.h>
#include "core.h"
#include "util.h"
@@ -16,6 +17,10 @@ ECPConnection conn;
#define CTYPE_TEST 0
#define MTYPE_MSG 8
+int counter = 0;
+uint64_t t_start = 0;
+uint64_t t_end = 0;
+
ssize_t handle_open_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s, ECP2Buffer *b) {
uint32_t seq = 0;
@@ -31,17 +36,32 @@ ssize_t handle_open_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsign
strcpy((char *)buf, msg);
ssize_t _rv = ecp_send(conn, MTYPE_MSG, buf, 1000);
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ t_start = tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
+
return s;
}
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);
+ counter++;
+ // 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);
+ if (counter % 100 == 0) {
+ struct timeval tv;
+ uint64_t t_time;
+
+ gettimeofday(&tv, NULL);
+ t_end = tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
+ t_time = t_end - t_start;
+ printf("T:%f\n", (float)t_time/1000000);
+ t_start = t_end;
+ }
return s;
}