tf update and some progress

sipo
Ondřej Hruška 7 years ago
parent d6c4372755
commit ccbff578b3
  1. 3
      TinyFrame/TF_Config.h
  2. 8
      TinyFrame/TF_Integration.c
  3. 8
      TinyFrame/TinyFrame.c
  4. 2
      comm/messages.c
  5. 1
      framework/unit_registry.c
  6. 6
      freertos.c
  7. 7
      tasks/task_msg.c
  8. 3
      units/test/unit_test.c

@ -5,6 +5,7 @@
#ifndef TF_CONFIG_H #ifndef TF_CONFIG_H
#define TF_CONFIG_H #define TF_CONFIG_H
#include "platform.h"
#include <stdint.h> #include <stdint.h>
//#include <esp8266.h> // when using with esphttpd //#include <esp8266.h> // when using with esphttpd
@ -65,7 +66,7 @@ typedef uint8_t TF_COUNT;
// Timeout for receiving & parsing a frame // Timeout for receiving & parsing a frame
// ticks = number of calls to TF_Tick() // ticks = number of calls to TF_Tick()
#define TF_PARSER_TIMEOUT_TICKS 10 #define TF_PARSER_TIMEOUT_TICKS 250
//------------------------- End of user config ------------------------------ //------------------------- End of user config ------------------------------

@ -7,6 +7,7 @@
#include "platform.h" #include "platform.h"
#include "task_main.h" #include "task_main.h"
#include "utils/hexdump.h"
#include "USB/usbd_cdc_if.h" #include "USB/usbd_cdc_if.h"
#include "TinyFrame.h" #include "TinyFrame.h"
@ -20,9 +21,10 @@ void TF_WriteImpl(TinyFrame *tf, const uint8_t *buff, size_t len)
int32_t total = (int32_t) len; int32_t total = (int32_t) len;
while (total > 0) { while (total > 0) {
assert_param(osOK == osSemaphoreWait(semVcomTxReadyHandle, 5000)); assert_param(osOK == osSemaphoreWait(semVcomTxReadyHandle, 5000));
assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, (uint16_t) MIN(total, CHUNK))); uint16_t chunksize = (uint16_t) MIN(total, CHUNK);
buff += CHUNK; assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, chunksize));
total -= CHUNK; buff += chunksize;
total -= chunksize;
} }
} }

@ -1,8 +1,6 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "TinyFrame.h" #include "TinyFrame.h"
#include <malloc.h> #include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Compatibility with ESP8266 SDK // Compatibility with ESP8266 SDK
@ -245,7 +243,6 @@ bool _TF_FN TF_AddIdListener(TinyFrame *tf, TF_Msg *msg, TF_Listener cb, TF_TICK
return true; return true;
} }
} }
fprintf(stderr,"TF failed to add ID listener\n");
return false; return false;
} }
@ -375,8 +372,7 @@ static void _TF_FN TF_HandleReceivedMessage(TinyFrame *tf)
if (res == TF_RENEW) { if (res == TF_RENEW) {
renew_id_listener(ilst); renew_id_listener(ilst);
} }
else if (res == TF_CLOSE) {
if (res == TF_CLOSE) {
// Set userdata to NULL to avoid calling user for cleanup // Set userdata to NULL to avoid calling user for cleanup
ilst->userdata = NULL; ilst->userdata = NULL;
ilst->userdata2 = NULL; ilst->userdata2 = NULL;
@ -489,6 +485,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
} }
#endif #endif
//@formatter:off
switch (tf->state) { switch (tf->state) {
case TFState_SOF: case TFState_SOF:
if (c == TF_SOF_BYTE) { if (c == TF_SOF_BYTE) {
@ -592,6 +589,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
} }
break; break;
} }
//@formatter:on
// we get here after finishing HEAD, if no data are to be received - handle and clear // we get here after finishing HEAD, if no data are to be received - handle and clear
if (tf->len == 0 && tf->state == TFState_DATA) { if (tf->len == 0 && tf->state == TFState_DATA) {

@ -57,7 +57,7 @@ static void job_unhandled_resp(Job *job)
static TF_Result lst_default(TinyFrame *tf, TF_Msg *msg) static TF_Result lst_default(TinyFrame *tf, TF_Msg *msg)
{ {
dbg("!! Unhandled msg type %d, frame_id %d", (int)msg->type, (int)msg->frame_id); dbg("!! Unhandled msg type %02"PRIx8", frame_id 0x%04"PRIx16, msg->type, msg->frame_id);
Job job = { Job job = {
.cb = job_unhandled_resp, .cb = job_unhandled_resp,
.frame_id = msg->frame_id, .frame_id = msg->frame_id,

@ -2,6 +2,7 @@
// Created by MightyPork on 2017/11/26. // Created by MightyPork on 2017/11/26.
// //
#include <utils/hexdump.h>
#include "platform.h" #include "platform.h"
#include "utils/avrlibc.h" #include "utils/avrlibc.h"
#include "comm/messages.h" #include "comm/messages.h"

@ -59,9 +59,9 @@
/* Variables -----------------------------------------------------------------*/ /* Variables -----------------------------------------------------------------*/
#define STACK_MAIN 160 #define STACK_MAIN 160
#define STACK_MSG 170 #define STACK_MSG 230
#define STACK_LP 128 #define STACK_LP 180
#define STACK_HP 128 #define STACK_HP 150
osThreadId tskMainHandle; osThreadId tskMainHandle;
uint32_t mainTaskBuffer[ STACK_MAIN ]; uint32_t mainTaskBuffer[ STACK_MAIN ];

@ -2,8 +2,9 @@
// Created by MightyPork on 2017/12/22. // Created by MightyPork on 2017/12/22.
// //
#include <comm/messages.h>
#include "platform.h" #include "platform.h"
#include "comm/messages.h"
#include "utils/hexdump.h"
#include "task_msg.h" #include "task_msg.h"
#include "sched_queue.h" #include "sched_queue.h"
@ -15,6 +16,10 @@ void TaskMessaging(const void * argument)
while (1) { while (1) {
xQueueReceive(queRxDataHandle, &slot, osWaitForever); xQueueReceive(queRxDataHandle, &slot, osWaitForever);
assert_param(slot.len>0 && slot.len<=64); // check the len is within bounds assert_param(slot.len>0 && slot.len<=64); // check the len is within bounds
hexDump("MSG", slot.data, slot.len);
TF_Accept(comm, slot.data, slot.len); TF_Accept(comm, slot.data, slot.len);
} }
} }

@ -183,6 +183,7 @@ static bool Tst_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, Paylo
switch (command) { switch (command) {
case CMD_PING: case CMD_PING:
dbg("Ping msg!");
tf_respond_ok(frame_id); tf_respond_ok(frame_id);
//sched_respond_suc(frame_id); //sched_respond_suc(frame_id);
break; break;
@ -198,7 +199,7 @@ static bool Tst_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, Paylo
.len = len, .len = len,
}; };
PRINTF("Rx len %d: ", (int)len); PRINTF("ECHO, len %d: ", (int)len);
PUTSN((char *) cpy, len); PUTSN((char *) cpy, len);
PUTS("\r\n"); PUTS("\r\n");

Loading…
Cancel
Save