From 5537f5d246106869e6e034ee4df2e8c24ce9459e Mon Sep 17 00:00:00 2001 From: Mateusz Lubecki Date: Tue, 16 Aug 2022 22:09:31 +0200 Subject: [PATCH] sketch of kiss diagnostics communication --- STM32L476_ParaMETEO/src/subdir.mk | 6 +- .../example_configs/station_config_example.h | 10 +++- include/kiss_callback.h | 11 ++++ ...ssCommunication.h => kiss_communication.h} | 17 ++++-- include/main.h | 2 +- ...ssCommunication.c => kiss_communication.c} | 57 ++++++++++++++----- src/main.c | 4 +- system/src/aprs/ax25.c | 2 +- 8 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 include/kiss_callback.h rename include/{KissCommunication.h => kiss_communication.h} (73%) rename src/{KissCommunication.c => kiss_communication.c} (80%) diff --git a/STM32L476_ParaMETEO/src/subdir.mk b/STM32L476_ParaMETEO/src/subdir.mk index 2850c32..6c5d5fd 100644 --- a/STM32L476_ParaMETEO/src/subdir.mk +++ b/STM32L476_ParaMETEO/src/subdir.mk @@ -4,7 +4,6 @@ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ -../src/KissCommunication.c \ ../src/LedConfig.c \ ../src/PathConfig.c \ ../src/TimerConfig.c \ @@ -20,6 +19,7 @@ C_SRCS += \ ../src/float_to_string.c \ ../src/io.c \ ../src/it_handlers.c \ +../src/kiss_communication.c \ ../src/main.c \ ../src/packet_tx_handler.c \ ../src/pwr_save.c \ @@ -35,7 +35,6 @@ C_SRCS += \ ../src/wx_pwr_switch.c OBJS += \ -./src/KissCommunication.o \ ./src/LedConfig.o \ ./src/PathConfig.o \ ./src/TimerConfig.o \ @@ -51,6 +50,7 @@ OBJS += \ ./src/float_to_string.o \ ./src/io.o \ ./src/it_handlers.o \ +./src/kiss_communication.o \ ./src/main.o \ ./src/packet_tx_handler.o \ ./src/pwr_save.o \ @@ -66,7 +66,6 @@ OBJS += \ ./src/wx_pwr_switch.o C_DEPS += \ -./src/KissCommunication.d \ ./src/LedConfig.d \ ./src/PathConfig.d \ ./src/TimerConfig.d \ @@ -82,6 +81,7 @@ C_DEPS += \ ./src/float_to_string.d \ ./src/io.d \ ./src/it_handlers.d \ +./src/kiss_communication.d \ ./src/main.d \ ./src/packet_tx_handler.d \ ./src/pwr_save.d \ diff --git a/include/example_configs/station_config_example.h b/include/example_configs/station_config_example.h index 970fb31..77a1529 100644 --- a/include/example_configs/station_config_example.h +++ b/include/example_configs/station_config_example.h @@ -5,6 +5,13 @@ * Author: mateusz */ +/** + * Important warning for ParaMETEO target!! Starting from EA15 software the configuration is kept in separate NvMem area, + * outside application software area. It isn't erased or reprogrammed during loading HEX file generated with this build. + * After NvMem is initialized, changing only this configuration won't affect ParaMETEO. To force update flash mass erase + * shall be performed. + */ + #ifndef STATION_CONFIG_H_ #define STATION_CONFIG_H_ @@ -26,9 +33,6 @@ /* MODES OF OPERATION */ /* ------------------ */ -//#define PARATNC_HWREV_C -#define PARAMETEO - /* ---------------------------- */ /* WEATHER/METEO CONFIGURATION */ diff --git a/include/kiss_callback.h b/include/kiss_callback.h new file mode 100644 index 0000000..1d34380 --- /dev/null +++ b/include/kiss_callback.h @@ -0,0 +1,11 @@ +#ifndef KISSCALLBACK_H_ +#define KISSCALLBACK_H_ + +#include "kiss_communication.h" + +#include + +void kiss_callback_get_running_config(); +int16_t kiss_pool_callback_get_running_config(uint8_t * output_buffer, uint16_t buffer_size, uint8_t current_segment ); + +#endif diff --git a/include/KissCommunication.h b/include/kiss_communication.h similarity index 73% rename from include/KissCommunication.h rename to include/kiss_communication.h index 80f37dc..6e0e666 100644 --- a/include/KissCommunication.h +++ b/include/kiss_communication.h @@ -14,7 +14,7 @@ #include "stdint.h" -#define KISS_BUFFER_LN 256 +//#define KISS_BUFFER_LN 256 #define KISS_TOO_LONG_FRM -1 @@ -23,12 +23,22 @@ #define TFEND (uint8_t)0xDC #define TFESC (uint8_t)0xDD +#define KISS_DATA (uint8_t) 0x00 +#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x20 +#define KISS_RUNNING_CONFIG (uint8_t) 0x70 + +#define KISS_GET_VERSION (uint8_t) 0x15 + +#define KISS_RETURN_IDLE 1 + /* C++ detection */ #ifdef __cplusplus extern "C" { #endif - int32_t SendKISSToHost(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* output, uint16_t output_len); + uint8_t kiss_async_pooler(uint8_t* output, uint16_t output_len ); + + int32_t kiss_send_ax25_to_host(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* output, uint16_t output_len); int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a); void kiss_reset_buffer(uint8_t* output, uint16_t output_len, uint16_t* current_len); @@ -37,9 +47,6 @@ void kiss_put_call(const AX25Call *addr, uint8_t is_last, uint8_t* output, uint16_t output_len, uint16_t* current_len, uint16_t* crc); void kiss_finalize_buffer(uint8_t* output, uint16_t output_len, uint16_t* current_len); - - uint8_t* kiss_get_buff_ptr(void); - #ifdef __cplusplus } #endif diff --git a/include/main.h b/include/main.h index 8d67f3f..f5e9c71 100644 --- a/include/main.h +++ b/include/main.h @@ -18,7 +18,7 @@ #define PWR_SWITCH_BOTH -#define OWN_APRS_MSG_LN 160 +#define OWN_APRS_MSG_LN 256 // backup registers (ParaMETEO) // 0 -> powersave status diff --git a/src/KissCommunication.c b/src/kiss_communication.c similarity index 80% rename from src/KissCommunication.c rename to src/kiss_communication.c index ef4b97a..6928196 100644 --- a/src/KissCommunication.c +++ b/src/kiss_communication.c @@ -5,7 +5,8 @@ * Author: mateusz */ -#include "KissCommunication.h" +#include +#include "kiss_callback.h" #include "main.h" @@ -22,13 +23,43 @@ extern unsigned short tx10m; -#define KISS_DATA (uint8_t) 0x00 -#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x20 -#define KISS_RUNNING_CONFIG (uint8_t) 0x70 +/** + * ID of asynchronous message which is currently transmitteed asynchronously do host PC. + * If it is set to 0xFF then no async message is transmitted + */ +uint8_t kiss_current_async_message = 0xFF; -uint8_t kiss_buffer[KISS_BUFFER_LN]; +/** + * This an id of segment of multiframe message, like running config + */ +uint8_t kiss_current_message_frame_segment = 0; -int32_t SendKISSToHost(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* output, uint16_t output_len) { +uint8_t kiss_async_pooler(uint8_t* output, uint16_t output_len ) { + + int16_t pooling_result = 0; + + uint8_t out = 0; + + if (kiss_current_async_message == 0xFF) { + return KISS_RETURN_IDLE; + } + + switch(kiss_current_async_message) { + case KISS_RUNNING_CONFIG: + pooling_result = kiss_pool_callback_get_running_config(output, output_len, kiss_current_message_frame_segment); + + break; + } + + // positive return value + if (pooling_result > 0) { + + } + + return out; +} + +int32_t kiss_send_ax25_to_host(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* output, uint16_t output_len) { #define FEND (uint8_t)0xC0 #define FESC (uint8_t)0xDB #define TFEND (uint8_t)0xDC @@ -72,18 +103,17 @@ int32_t SendKISSToHost(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a) { int i/* zmienna do poruszania sie po buforze odbiorczym usart */; int j/* zmienna do poruszania sie po lokalnej tablicy do przepisywania*/; -// uint8_t FrameBuff[100]; if (input_frame_from_host == 0x00 || ax25 == 0x00 || a == 0x00) { return 2; } - uint8_t *FrameBuff = kiss_buffer; + uint8_t *FrameBuff = (uint8_t *)main_own_aprs_msg; uint8_t frame_type = *(input_frame_from_host+1); // check if frame from host is not too long - if (input_len >= KISS_BUFFER_LN) + if (input_len >= OWN_APRS_MSG_LN) return 1; if (*(input_frame_from_host) != FEND) { @@ -91,9 +121,11 @@ int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, } // check input frame type - switch (frame_type != 0x00) { + switch (frame_type) { case KISS_DATA: { + memset(FrameBuff, 0x00, OWN_APRS_MSG_LN); + // if this is data frame for (i=2, j=0; (i #define SOH 0x01 @@ -1017,7 +1017,7 @@ int main(int argc, char* argv[]){ if (main_kiss_enabled == 1) { // convert message to kiss format and send it to host - srl_start_tx(main_kiss_srl_ctx_ptr, SendKISSToHost(ax25_rxed_frame.raw_data, (ax25_rxed_frame.raw_msg_len - 2), main_kiss_srl_ctx.srl_tx_buf_pointer, main_kiss_srl_ctx.srl_tx_buf_ln)); + srl_start_tx(main_kiss_srl_ctx_ptr, kiss_send_ax25_to_host(ax25_rxed_frame.raw_data, (ax25_rxed_frame.raw_msg_len - 2), main_kiss_srl_ctx.srl_tx_buf_pointer, main_kiss_srl_ctx.srl_tx_buf_ln)); } } diff --git a/system/src/aprs/ax25.c b/system/src/aprs/ax25.c index c39b4e8..cdb4faf 100644 --- a/system/src/aprs/ax25.c +++ b/system/src/aprs/ax25.c @@ -8,10 +8,10 @@ #include #include #include +#include #include "station_config.h" -#include "KissCommunication.h" AX25Msg ax25_rxed_frame; char ax25_new_msg_rx_flag;