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

@ -7,6 +7,7 @@
#include "platform.h"
#include "task_main.h"
#include "utils/hexdump.h"
#include "USB/usbd_cdc_if.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;
while (total > 0) {
assert_param(osOK == osSemaphoreWait(semVcomTxReadyHandle, 5000));
assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, (uint16_t) MIN(total, CHUNK)));
buff += CHUNK;
total -= CHUNK;
uint16_t chunksize = (uint16_t) MIN(total, CHUNK);
assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, chunksize));
buff += chunksize;
total -= chunksize;
}
}

@ -1,8 +1,6 @@
//---------------------------------------------------------------------------
#include "TinyFrame.h"
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
// 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;
}
}
fprintf(stderr,"TF failed to add ID listener\n");
return false;
}
@ -375,8 +372,7 @@ static void _TF_FN TF_HandleReceivedMessage(TinyFrame *tf)
if (res == TF_RENEW) {
renew_id_listener(ilst);
}
if (res == TF_CLOSE) {
else if (res == TF_CLOSE) {
// Set userdata to NULL to avoid calling user for cleanup
ilst->userdata = NULL;
ilst->userdata2 = NULL;
@ -489,6 +485,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
}
#endif
//@formatter:off
switch (tf->state) {
case TFState_SOF:
if (c == TF_SOF_BYTE) {
@ -517,15 +514,15 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
case TFState_TYPE:
CKSUM_ADD(tf->cksum, c);
COLLECT_NUMBER(tf->type, TF_TYPE) {
#if TF_CKSUM_TYPE == TF_CKSUM_NONE
#if TF_CKSUM_TYPE == TF_CKSUM_NONE
tf->state = TFState_DATA;
tf->rxi = 0;
#else
#else
// enter HEAD_CKSUM state
tf->state = TFState_HEAD_CKSUM;
tf->rxi = 0;
tf->ref_cksum = 0;
#endif
#endif
}
break;
@ -567,16 +564,16 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
}
if (tf->rxi == tf->len) {
#if TF_CKSUM_TYPE == TF_CKSUM_NONE
#if TF_CKSUM_TYPE == TF_CKSUM_NONE
// All done
TF_HandleReceivedMessage();
TF_ResetParser();
#else
#else
// Enter DATA_CKSUM state
tf->state = TFState_DATA_CKSUM;
tf->rxi = 0;
tf->ref_cksum = 0;
#endif
#endif
}
break;
@ -592,6 +589,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
}
break;
}
//@formatter:on
// we get here after finishing HEAD, if no data are to be received - handle and clear
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)
{
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 = {
.cb = job_unhandled_resp,
.frame_id = msg->frame_id,

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

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

@ -2,8 +2,9 @@
// Created by MightyPork on 2017/12/22.
//
#include <comm/messages.h>
#include "platform.h"
#include "comm/messages.h"
#include "utils/hexdump.h"
#include "task_msg.h"
#include "sched_queue.h"
@ -15,6 +16,10 @@ void TaskMessaging(const void * argument)
while (1) {
xQueueReceive(queRxDataHandle, &slot, osWaitForever);
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);
}
}

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

Loading…
Cancel
Save