kopia lustrzana https://github.com/SP8EBC/ParaTNC
kiss diagnostics routines and some refactoring
rodzic
d9ae80c7be
commit
ab65d48579
|
@ -11,7 +11,6 @@ AllowShortLoopsOnASingleLine: 'false'
|
|||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: 'false'
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackParameters: false
|
||||
BreakBeforeBraces: Stroustrup
|
||||
ColumnLimit: '100'
|
||||
IndentWidth: '4'
|
||||
|
@ -20,5 +19,4 @@ SpaceBeforeParens: Always
|
|||
Standard: Cpp11
|
||||
TabWidth: '4'
|
||||
UseTab: Always
|
||||
|
||||
...
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
"kiss_routine_control.h": "c",
|
||||
"routine_5254_set_datetime.h": "c",
|
||||
"kiss_communication.h": "c",
|
||||
"kiss_communication_service_ids.h": "c"
|
||||
"kiss_communication_service_ids.h": "c",
|
||||
"kiss_security_access.h": "c",
|
||||
"kiss_communication_transport_t.h": "c"
|
||||
}
|
||||
}
|
|
@ -27,7 +27,8 @@ RM := rm -rf
|
|||
-include system/src/subdir.mk
|
||||
-include src/stored_configuration_nvm/subdir.mk
|
||||
-include src/nvm/subdir.mk
|
||||
-include src/kiss_protocol/routines/subdir.mk
|
||||
-include src/kiss_protocol/diagnostics_services/subdir.mk
|
||||
-include src/kiss_protocol/diagnostics_routines/subdir.mk
|
||||
-include src/kiss_protocol/subdir.mk
|
||||
-include src/subdir.mk
|
||||
-include subdir.mk
|
||||
|
|
|
@ -29,8 +29,9 @@ CPP_DEPS :=
|
|||
# Every subdirectory with source files must be described here
|
||||
SUBDIRS := \
|
||||
src \
|
||||
src/kiss_protocol/diagnostics_routines \
|
||||
src/kiss_protocol/diagnostics_services \
|
||||
src/kiss_protocol \
|
||||
src/kiss_protocol/routines \
|
||||
src/nvm \
|
||||
src/stored_configuration_nvm \
|
||||
system/src/aprs \
|
||||
|
|
|
@ -7,31 +7,19 @@ C_SRCS += \
|
|||
../src/kiss_protocol/kiss_callback.c \
|
||||
../src/kiss_protocol/kiss_communication.c \
|
||||
../src/kiss_protocol/kiss_communication_aprsmsg.c \
|
||||
../src/kiss_protocol/kiss_did.c \
|
||||
../src/kiss_protocol/kiss_nrc_response.c \
|
||||
../src/kiss_protocol/kiss_read_memory.c \
|
||||
../src/kiss_protocol/kiss_routine_control.c \
|
||||
../src/kiss_protocol/kiss_security_access.c
|
||||
../src/kiss_protocol/kiss_nrc_response.c
|
||||
|
||||
OBJS += \
|
||||
./src/kiss_protocol/kiss_callback.o \
|
||||
./src/kiss_protocol/kiss_communication.o \
|
||||
./src/kiss_protocol/kiss_communication_aprsmsg.o \
|
||||
./src/kiss_protocol/kiss_did.o \
|
||||
./src/kiss_protocol/kiss_nrc_response.o \
|
||||
./src/kiss_protocol/kiss_read_memory.o \
|
||||
./src/kiss_protocol/kiss_routine_control.o \
|
||||
./src/kiss_protocol/kiss_security_access.o
|
||||
./src/kiss_protocol/kiss_nrc_response.o
|
||||
|
||||
C_DEPS += \
|
||||
./src/kiss_protocol/kiss_callback.d \
|
||||
./src/kiss_protocol/kiss_communication.d \
|
||||
./src/kiss_protocol/kiss_communication_aprsmsg.d \
|
||||
./src/kiss_protocol/kiss_did.d \
|
||||
./src/kiss_protocol/kiss_nrc_response.d \
|
||||
./src/kiss_protocol/kiss_read_memory.d \
|
||||
./src/kiss_protocol/kiss_routine_control.d \
|
||||
./src/kiss_protocol/kiss_security_access.d
|
||||
./src/kiss_protocol/kiss_nrc_response.d
|
||||
|
||||
|
||||
# Each subdirectory must supply rules for building sources it contributes
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef FECBA2A0_59AB_4F1A_8C66_10091DC348D3
|
||||
#define FECBA2A0_59AB_4F1A_8C66_10091DC348D3
|
||||
|
||||
#include "./kiss_communication/kiss_routine_control.h"
|
||||
#include "./kiss_communication/diagnostics_services/kiss_routine_control.h"
|
||||
|
||||
/// ==================================================================================================
|
||||
/// GLOBAL MACROS
|
|
@ -27,5 +27,11 @@ void kiss_security_access_init(config_data_basic_t * config);
|
|||
*/
|
||||
uint8_t kiss_security_check_service_req_unlocking(uint8_t service_id, kiss_communication_transport_t transport_media, uint32_t lparam);
|
||||
|
||||
uint8_t kiss_security_access_get_access_unlocked_serial(void);
|
||||
|
||||
uint8_t kiss_security_access_get_access_unlocked_aprsmessage(void);
|
||||
|
||||
uint8_t kiss_security_access_get_unlocked_per_transport(kiss_communication_transport_t transport);
|
||||
|
||||
|
||||
#endif /* KISS_COMMUNICATION_KISS_SECURITY_ACCESS_H_ */
|
|
@ -6,21 +6,21 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t kiss_callback_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
int16_t kiss_pool_callback_get_running_config(uint8_t * output_buffer, uint16_t buffer_size );
|
||||
|
||||
int32_t kiss_callback_get_version_id(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_get_version_id(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
int32_t kiss_callback_erase_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_erase_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
int32_t kiss_callback_reset(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_reset(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size);
|
||||
int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "aprs/ax25.h"
|
||||
#include "aprs/afsk.h"
|
||||
|
||||
#include "kiss_communication/types/kiss_communication_transport_t.h"
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
|
@ -41,7 +43,10 @@ extern uint8_t kiss_current_async_message;
|
|||
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, uint8_t * response_buffer, uint16_t resp_buf_ln );
|
||||
|
||||
int32_t kiss_parse_received (uint8_t *input_frame_from_host, uint16_t input_len, AX25Ctx *ax25,
|
||||
Afsk *a, uint8_t *response_buffer, uint16_t resp_buf_ln,
|
||||
kiss_communication_transport_t transport_media);
|
||||
|
||||
void kiss_reset_buffer(uint8_t* output, uint16_t output_len, uint16_t* current_len);
|
||||
uint8_t kiss_put_char(uint8_t c, uint8_t* output, uint16_t output_len, uint16_t* current_len, uint16_t* crc);
|
||||
|
|
|
@ -16,5 +16,6 @@ int kiss_nrc_response_fill_request_out_of_range(uint8_t * buffer);
|
|||
int kiss_nrc_response_fill_incorrect_message_ln(uint8_t * buffer);
|
||||
int kiss_nrc_response_fill_security_access_denied(uint8_t * buffer);
|
||||
int kiss_nrc_response_fill_conditions_not_correct(uint8_t * buffer);
|
||||
int kiss_nrc_response_fill_sequence_error(uint8_t * buffer);
|
||||
|
||||
#endif /* KISS_COMMUNICATION_KISS_NRC_RESPONSE_H_ */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define SOFTWARE_VERSION_H_
|
||||
|
||||
#define SW_VER "EC01"
|
||||
#define SW_DATE "08092024"
|
||||
#define SW_DATE "15092024"
|
||||
#define SW_KISS_PROTO "C"
|
||||
|
||||
extern const char software_version_str[5];
|
||||
|
|
10
src/aprsis.c
10
src/aprsis.c
|
@ -275,8 +275,14 @@ STATIC void aprsis_receive_callback(srl_context_t* srl_context) {
|
|||
// trigger preparing ACK
|
||||
rte_main_trigger_message_ack = 1;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
// this message is not for me, so no sense in keeping in longer
|
||||
memset(&rte_main_received_message, 0x00, sizeof(message_t));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// cannot decode message, maybe it is broken
|
||||
memset(&rte_main_received_message, 0x00, sizeof(message_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "./kiss_communication/routines/routine_5254_set_datetime.h"
|
||||
#include "./kiss_communication/diagnostics_routines/routine_5254_set_datetime.h"
|
||||
|
||||
#include "tm/tm_stm32_rtc.h"
|
||||
#include "stm32l4xx_ll_rtc.h"
|
|
@ -5,7 +5,7 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "kiss_communication/kiss_read_memory.h"
|
||||
#include "kiss_communication/diagnostics_services/kiss_read_memory.h"
|
||||
|
||||
/// ==================================================================================================
|
||||
/// LOCAL DEFINITIONS
|
|
@ -27,8 +27,8 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "./kiss_communication/kiss_routine_control.h"
|
||||
#include "./kiss_communication/routines/routine_5254_set_datetime.h"
|
||||
#include "./kiss_communication/diagnostics_services/kiss_routine_control.h"
|
||||
#include "./kiss_communication/diagnostics_routines/routine_5254_set_datetime.h"
|
||||
#include "./kiss_communication/types/kiss_xmacro_helpers.h"
|
||||
|
||||
#include "./etc/kiss_routine_configuration.h"
|
||||
|
@ -113,6 +113,8 @@ static kiss_routine_control_t *kiss_routine_get_by_id (uint16_t id)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return routine;
|
||||
}
|
||||
|
||||
/// ==================================================================================================
|
|
@ -5,7 +5,7 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "kiss_communication/kiss_security_access.h"
|
||||
#include "kiss_communication/diagnostics_services/kiss_security_access.h"
|
||||
#include "kiss_communication/types/kiss_communication_service_ids.h"
|
||||
#include "backup_registers.h"
|
||||
#include "system_stm32l4xx.h"
|
||||
|
@ -88,6 +88,17 @@ static uint32_t kiss_security_access_config = 0U;
|
|||
*/
|
||||
static uint8_t kiss_security_access_encrypted_unclock = 0U;
|
||||
|
||||
/**
|
||||
* Set to one if security access for transport KISS_TRANSPORT_SERIAL_PORT is unlocked
|
||||
*/
|
||||
static uint8_t kiss_security_access_unlocked_serial = 1U;
|
||||
|
||||
/**
|
||||
* Set to one if security access for transports KISS_TRANSPORT_ENCRYPTED_HEXSTRING
|
||||
* and KISS_TRANSPORT_HEXSTRING
|
||||
*/
|
||||
static uint8_t kiss_security_access_unlocked_aprsmessage = 0U;
|
||||
|
||||
/// ==================================================================================================
|
||||
/// GLOBAL VARIABLES
|
||||
/// ==================================================================================================
|
||||
|
@ -139,13 +150,13 @@ uint8_t kiss_security_check_service_req_unlocking(uint8_t service_id, kiss_commu
|
|||
transport_media == KISS_TRANSPORT_HEXSTRING) {
|
||||
switch (service_id) {
|
||||
case KISS_RESTART:
|
||||
if (lparam == KISS_RESET_HARD) {
|
||||
if (lparam == KISS_RESET_SOFT) {
|
||||
if (system_get_rtc_date() != backup_reg_get_last_restart_date()) {
|
||||
// one restart per day is always allowed
|
||||
out = 0;
|
||||
}
|
||||
else {
|
||||
out = KISS_SECURITY_CHECK_MESSAGE(KISS_RESTART);
|
||||
out = KISS_SECURITY_CHECK_MESSAGE(KISS_SECURITY_RESTART_RESET);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -155,11 +166,13 @@ uint8_t kiss_security_check_service_req_unlocking(uint8_t service_id, kiss_commu
|
|||
out = 0;
|
||||
break;
|
||||
case KISS_READ_DID:
|
||||
out = KISS_SECURITY_CHECK_MESSAGE(KISS_READ_DID);
|
||||
out = 0; // temporary always allowed
|
||||
//out = KISS_SECURITY_CHECK_MESSAGE(KISS_READ_DID);
|
||||
break;
|
||||
case KISS_READ_MEM_ADDR:
|
||||
if (variant_validate_is_within_flash_logger_events((void*)lparam) == 1) {
|
||||
out = KISS_SECURITY_CHECK_MESSAGE(KISS_SECURITY_READ_MEM_RESTRICTED);
|
||||
out = 0; // temporary always allowed
|
||||
//out = KISS_SECURITY_CHECK_MESSAGE(KISS_SECURITY_READ_MEM_RESTRICTED);
|
||||
}
|
||||
else {
|
||||
// it is assumed that DID handler checks if address to be read
|
||||
|
@ -226,3 +239,23 @@ uint8_t kiss_security_check_service_req_unlocking(uint8_t service_id, kiss_commu
|
|||
return out;
|
||||
|
||||
}
|
||||
|
||||
uint8_t kiss_security_access_get_access_unlocked_serial(void)
|
||||
{
|
||||
return kiss_security_access_unlocked_serial;
|
||||
}
|
||||
|
||||
uint8_t kiss_security_access_get_access_unlocked_aprsmessage(void)
|
||||
{
|
||||
return kiss_security_access_unlocked_aprsmessage;
|
||||
}
|
||||
|
||||
uint8_t kiss_security_access_get_unlocked_per_transport(kiss_communication_transport_t transport)
|
||||
{
|
||||
if (transport == KISS_TRANSPORT_SERIAL_PORT) {
|
||||
return kiss_security_access_unlocked_serial;
|
||||
}
|
||||
else {
|
||||
return kiss_security_access_unlocked_aprsmessage;
|
||||
}
|
||||
}
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#include <kiss_communication/kiss_communication.h>
|
||||
#include <kiss_communication/types/kiss_communication_service_ids.h>
|
||||
#include <kiss_communication/kiss_routine_control.h>
|
||||
#include <kiss_communication/kiss_did.h>
|
||||
#include <kiss_communication/kiss_read_memory.h>
|
||||
#include <kiss_communication/diagnostics_services/kiss_routine_control.h>
|
||||
#include <kiss_communication/diagnostics_services/kiss_did.h>
|
||||
#include <kiss_communication/diagnostics_services/kiss_read_memory.h>
|
||||
#include <kiss_communication/kiss_nrc_response.h>
|
||||
#include "main.h"
|
||||
#include "rte_main.h"
|
||||
|
@ -66,7 +66,7 @@ uint8_t kiss_async_message_counter = 0;
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
#define CALLBACK_GET_RUNNING_CFG_LN 7
|
||||
|
||||
|
@ -74,32 +74,38 @@ int32_t kiss_callback_get_running_config(uint8_t* input_frame_from_host, uint16_
|
|||
|
||||
configuration_handler_region_t current_region;
|
||||
|
||||
// set current message to start pooling
|
||||
kiss_current_async_message = KISS_RUNNING_CONFIG;
|
||||
if (transport_media == KISS_TRANSPORT_SERIAL_PORT) {
|
||||
|
||||
// the rest of content of an input frame is irrevelant, but we need to send
|
||||
// a response telling how long configuration data is
|
||||
memset(response_buffer, 0x00, buffer_size);
|
||||
// set current message to start pooling
|
||||
kiss_current_async_message = KISS_RUNNING_CONFIG;
|
||||
|
||||
// get currently used configuration and its size in flash memory
|
||||
current_region = configuration_get_current(&conf_size);
|
||||
// the rest of content of an input frame is irrevelant, but we need to send
|
||||
// a response telling how long configuration data is
|
||||
memset(response_buffer, 0x00, buffer_size);
|
||||
|
||||
// reset async message counter
|
||||
kiss_async_message_counter = 0;
|
||||
// get currently used configuration and its size in flash memory
|
||||
current_region = configuration_get_current(&conf_size);
|
||||
|
||||
// construct a response
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = CALLBACK_GET_RUNNING_CFG_LN; // message lenght
|
||||
response_buffer[3] = KISS_RUNNING_CONFIG;
|
||||
response_buffer[4] = (uint8_t)(current_region & 0xFF);
|
||||
if ((conf_size % KISS_MAX_CONFIG_PAYLOAD_SIZE) == 0)
|
||||
response_buffer[5] = (uint8_t)(conf_size / KISS_MAX_CONFIG_PAYLOAD_SIZE);
|
||||
else
|
||||
response_buffer[5] = (uint8_t)(conf_size / KISS_MAX_CONFIG_PAYLOAD_SIZE + 1);
|
||||
response_buffer[6] = FEND;
|
||||
// reset async message counter
|
||||
kiss_async_message_counter = 0;
|
||||
|
||||
return CALLBACK_GET_RUNNING_CFG_LN;
|
||||
// construct a response
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = CALLBACK_GET_RUNNING_CFG_LN; // message lenght
|
||||
response_buffer[3] = KISS_RUNNING_CONFIG;
|
||||
response_buffer[4] = (uint8_t)(current_region & 0xFF);
|
||||
if ((conf_size % KISS_MAX_CONFIG_PAYLOAD_SIZE) == 0)
|
||||
response_buffer[5] = (uint8_t)(conf_size / KISS_MAX_CONFIG_PAYLOAD_SIZE);
|
||||
else
|
||||
response_buffer[5] = (uint8_t)(conf_size / KISS_MAX_CONFIG_PAYLOAD_SIZE + 1);
|
||||
response_buffer[6] = FEND;
|
||||
|
||||
return CALLBACK_GET_RUNNING_CFG_LN;
|
||||
}
|
||||
else {
|
||||
return kiss_nrc_response_fill_security_access_denied(response_buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -175,7 +181,7 @@ int16_t kiss_pool_callback_get_running_config(uint8_t * output_buffer, uint16_t
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_get_version_id(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_get_version_id(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
uint8_t config_payload_size = 0;
|
||||
|
||||
|
@ -205,50 +211,44 @@ int32_t kiss_callback_get_version_id(uint8_t* input_frame_from_host, uint16_t in
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_erase_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_erase_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
#define ERASE_STARTUP_LN 6
|
||||
|
||||
kiss_communication_nrc_t result = configuration_handler_erase_startup();
|
||||
if (transport_media == KISS_TRANSPORT_SERIAL_PORT) {
|
||||
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = ERASE_STARTUP_LN; // message lenght
|
||||
kiss_communication_nrc_t result = configuration_handler_erase_startup();
|
||||
|
||||
if (result == NRC_POSITIVE) {
|
||||
// construct a response
|
||||
response_buffer[3] = KISS_ERASE_STARTUP_CFG_RESP;
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = ERASE_STARTUP_LN; // message lenght
|
||||
|
||||
if (result == NRC_POSITIVE) {
|
||||
// construct a response
|
||||
response_buffer[3] = KISS_ERASE_STARTUP_CFG_RESP;
|
||||
}
|
||||
else {
|
||||
response_buffer[3] = KISS_NEGATIVE_RESPONSE_SERVICE;
|
||||
|
||||
}
|
||||
|
||||
response_buffer[4] = (uint8_t)result;
|
||||
response_buffer[5] = FEND;
|
||||
|
||||
return ERASE_STARTUP_LN;
|
||||
}
|
||||
else {
|
||||
response_buffer[3] = KISS_NEGATIVE_RESPONSE_SERVICE;
|
||||
|
||||
return kiss_nrc_response_fill_security_access_denied(response_buffer);
|
||||
}
|
||||
|
||||
response_buffer[4] = (uint8_t)result;
|
||||
response_buffer[5] = FEND;
|
||||
|
||||
return ERASE_STARTUP_LN;
|
||||
|
||||
}
|
||||
|
||||
/// ==================================================================================================
|
||||
/// GLOBAL VARIABLES
|
||||
/// ==================================================================================================
|
||||
|
||||
/// ==================================================================================================
|
||||
/// LOCAL FUNCTIONS
|
||||
/// ==================================================================================================
|
||||
|
||||
/// ==================================================================================================
|
||||
/// GLOBAL FUNCTIONS
|
||||
/// ==================================================================================================
|
||||
|
||||
/**
|
||||
* Callback which program configuration data block received from the Host PC. Please bear in mind that the TNC doesn't really take care
|
||||
* what it receives and program. It is up to host PC to provide senseful configuration with properly calculated checksum as this isn't
|
||||
* recalculated during programming.
|
||||
*/
|
||||
int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
#define PROGRAM_STARTUP_LN 6
|
||||
|
||||
|
@ -272,27 +272,32 @@ int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t i
|
|||
uint8_t data_size = *(input_frame_from_host + 2);
|
||||
|
||||
uint16_t config_block_offset = *(input_frame_from_host + 3) | (*(input_frame_from_host + 4) << 8);
|
||||
|
||||
if (transport_media == KISS_TRANSPORT_SERIAL_PORT) {
|
||||
result = configuration_handler_program_startup(data_ptr, data_size, config_block_offset);
|
||||
|
||||
result = configuration_handler_program_startup(data_ptr, data_size, config_block_offset);
|
||||
|
||||
// construct a response
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = PROGRAM_STARTUP_LN; // message lenght
|
||||
|
||||
if (result == NRC_POSITIVE) {
|
||||
// construct a response
|
||||
response_buffer[3] = KISS_PROGRAM_STARTUP_CFG_RESP;
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = PROGRAM_STARTUP_LN; // message lenght
|
||||
|
||||
if (result == NRC_POSITIVE) {
|
||||
// construct a response
|
||||
response_buffer[3] = KISS_PROGRAM_STARTUP_CFG_RESP;
|
||||
}
|
||||
else {
|
||||
response_buffer[3] = KISS_NEGATIVE_RESPONSE_SERVICE;
|
||||
|
||||
}
|
||||
|
||||
response_buffer[4] = (uint8_t)result;
|
||||
response_buffer[5] = FEND;
|
||||
|
||||
return PROGRAM_STARTUP_LN;
|
||||
}
|
||||
else {
|
||||
response_buffer[3] = KISS_NEGATIVE_RESPONSE_SERVICE;
|
||||
|
||||
return kiss_nrc_response_fill_security_access_denied(response_buffer);
|
||||
}
|
||||
|
||||
response_buffer[4] = (uint8_t)result;
|
||||
response_buffer[5] = FEND;
|
||||
|
||||
return PROGRAM_STARTUP_LN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -303,7 +308,7 @@ int32_t kiss_callback_program_startup(uint8_t* input_frame_from_host, uint16_t i
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
/**
|
||||
* Response frame structure
|
||||
|
@ -348,7 +353,7 @@ int32_t kiss_callback_read_did(uint8_t* input_frame_from_host, uint16_t input_le
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
/**
|
||||
* Response frame structure
|
||||
*
|
||||
|
@ -368,11 +373,15 @@ int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16
|
|||
// size
|
||||
const uint8_t size = *(input_frame_from_host + 7);
|
||||
|
||||
// if security access must be unlocked
|
||||
const uint8_t require_unlock = kiss_security_check_service_req_unlocking(KISS_READ_MEM_ADDR, transport_media, address);
|
||||
|
||||
// allow only one byte of size and four byte of address
|
||||
if (size_format == 0x14) {
|
||||
|
||||
if (size > 0 && size < KISS_CONFIG_DIAGNOSTIC_BUFFER_LN - 4) {
|
||||
if (variant_validate_is_within_read_mem_by_addr((const void*)address) == 1) {
|
||||
if ((require_unlock == 1 && kiss_security_access_get_unlocked_per_transport (transport_media) == 1) ||
|
||||
(variant_validate_is_within_read_mem_by_addr ((const void *)address) == 1)) {
|
||||
// construct DID response to an output buffer
|
||||
const uint8_t response_size = kiss_read_memory_response(address, size, response_buffer + 4, buffer_size - 5);
|
||||
|
||||
|
@ -416,20 +425,23 @@ int32_t kiss_callback_read_memory_by_addr(uint8_t* input_frame_from_host, uint16
|
|||
* @param buffer_size
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_callback_reset(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size) {
|
||||
int32_t kiss_callback_reset(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media) {
|
||||
|
||||
int32_t out = 0;
|
||||
|
||||
const uint8_t reset_type = *(input_frame_from_host + 2);
|
||||
|
||||
// if security access must be unlocked
|
||||
const uint8_t require_unlock = kiss_security_check_service_req_unlocking(KISS_RESTART, transport_media, reset_type);
|
||||
|
||||
// as for now only soft reset is allowed
|
||||
if (reset_type == KISS_RESET_SOFT) {
|
||||
|
||||
// get last bootup date
|
||||
const uint32_t last_restart_date = backup_reg_get_last_restart_date();
|
||||
|
||||
// only one restart per day is allowed
|
||||
if (RTC->DR != last_restart_date) {
|
||||
// only one restart per day is allowed, more needs security access unlock
|
||||
if ((RTC->DR != last_restart_date) || (require_unlock == 1 && kiss_security_access_get_unlocked_per_transport (transport_media) == 1)) {
|
||||
|
||||
// update last restart date
|
||||
backup_reg_set_last_restart_date();
|
||||
|
@ -457,7 +469,7 @@ int32_t kiss_callback_reset(uint8_t* input_frame_from_host, uint16_t input_len,
|
|||
/**
|
||||
*
|
||||
*/
|
||||
int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size)
|
||||
int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t input_len, uint8_t* response_buffer, uint16_t buffer_size, kiss_communication_transport_t transport_media)
|
||||
{
|
||||
/**
|
||||
* Input frame structure
|
||||
|
@ -492,7 +504,7 @@ int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t i
|
|||
routine_processing_result = kiss_routine_control_start_routine(routineid, wparam, lparam);
|
||||
|
||||
if (routine_processing_result == KISS_ROUTINE_RETVAL_SUCCESSFULLY_STARTED) {
|
||||
out = 8; // size of a response
|
||||
out = 7; // size of a response
|
||||
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
|
@ -500,7 +512,7 @@ int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t i
|
|||
response_buffer[3] = KISS_ROUTINE_CONTROL_RESP;
|
||||
response_buffer[4] = *(input_frame_from_host + 3);
|
||||
response_buffer[5] = *(input_frame_from_host + 4);
|
||||
response_buffer[7] = FEND;
|
||||
response_buffer[6] = FEND;
|
||||
}
|
||||
else if (routine_processing_result == KISS_ROUTINE_RETVAL_WRONG_PARAMS_VALUES) {
|
||||
out = kiss_nrc_response_fill_incorrect_message_ln(response_buffer);
|
||||
|
@ -512,13 +524,42 @@ int32_t kiss_callback_routine_control(uint8_t* input_frame_from_host, uint16_t i
|
|||
if (routine_processing_result == KISS_ROUTINE_RETVAL_STOP_FOR_SYNCHRO_ROUTINE) {
|
||||
// synchronous routine cannot be stopped, because it block diagnostics I/O on the
|
||||
// controller and terminates itself after everything is done
|
||||
out =
|
||||
out = kiss_nrc_response_fill_subfunction_not_supported(response_buffer);
|
||||
}
|
||||
else if (routine_processing_result == KISS_ROUTINE_RETVAL_STOP_FOR_NOT_RUNNING) {
|
||||
|
||||
// it is not possible to stop a routine which is not running now
|
||||
out = kiss_nrc_response_fill_sequence_error(response_buffer);
|
||||
}
|
||||
else {
|
||||
// success
|
||||
out = 7; // size of a response // out = KISS_ROUTINE_RETVAL_SUCCESS;
|
||||
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = out; // message lenght
|
||||
response_buffer[3] = KISS_ROUTINE_CONTROL_RESP;
|
||||
response_buffer[4] = *(input_frame_from_host + 3);
|
||||
response_buffer[5] = *(input_frame_from_host + 4);
|
||||
response_buffer[6] = FEND;
|
||||
}
|
||||
break;
|
||||
case KISS_ROUTINE_CONTROL_SUBFUNC_RESULT:
|
||||
|
||||
routine_processing_result = kiss_routine_control_get_result_routine(routineid);
|
||||
|
||||
// success
|
||||
out = 9; // size of a response // out = KISS_ROUTINE_RETVAL_SUCCESS;
|
||||
|
||||
response_buffer[0] = FEND;
|
||||
response_buffer[1] = NONSTANDARD;
|
||||
response_buffer[2] = out; // message lenght
|
||||
response_buffer[3] = KISS_ROUTINE_CONTROL_RESP;
|
||||
response_buffer[4] = *(input_frame_from_host + 3);
|
||||
response_buffer[5] = *(input_frame_from_host + 4);
|
||||
response_buffer[6] = routine_processing_result & 0xFFu;
|
||||
response_buffer[7] = (routine_processing_result & 0xFF00u) >> 8;
|
||||
response_buffer[8] = FEND;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,19 +5,19 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "station_config.h"
|
||||
|
||||
|
||||
#include <crc.h>
|
||||
#include <kiss_communication/kiss_callback.h>
|
||||
#include <kiss_communication/kiss_communication.h>
|
||||
#include <kiss_communication/kiss_callback.h>
|
||||
#include <kiss_communication/types/kiss_communication_service_ids.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stored_configuration_nvm/config_data_externs.h>
|
||||
#include <stored_configuration_nvm/configuration_handler.h>
|
||||
|
||||
#include <crc.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "station_config.h"
|
||||
|
||||
#include "variant.h"
|
||||
|
||||
extern unsigned short tx10m;
|
||||
|
@ -156,8 +156,15 @@ int32_t kiss_send_ax25_to_host(uint8_t* input_frame, uint16_t input_frame_len, u
|
|||
* @param resp_buf_ln
|
||||
* @return
|
||||
*/
|
||||
int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a, uint8_t * response_buffer, uint16_t resp_buf_ln ) {
|
||||
int i/* zmienna do poruszania sie po buforze odbiorczym usart */;
|
||||
int32_t kiss_parse_received (uint8_t *input_frame_from_host,
|
||||
uint16_t input_len,
|
||||
AX25Ctx *ax25,
|
||||
Afsk *a,
|
||||
uint8_t *response_buffer,
|
||||
uint16_t resp_buf_ln,
|
||||
kiss_communication_transport_t transport_media)
|
||||
{
|
||||
int i /* zmienna do poruszania sie po buforze odbiorczym usart */;
|
||||
int j/* zmienna do poruszania sie po lokalnej tablicy do przepisywania*/;
|
||||
|
||||
int32_t output = 0;
|
||||
|
@ -214,39 +221,39 @@ int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len,
|
|||
} break;
|
||||
|
||||
case KISS_GET_RUNNING_CONFIG: {
|
||||
output = kiss_callback_get_running_config(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_get_running_config(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
} break;
|
||||
|
||||
case KISS_GET_VERSION_AND_ID: {
|
||||
output = kiss_callback_get_version_id(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_get_version_id(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
|
||||
case KISS_ROUTINE_CONTROL: {
|
||||
output = kiss_callback_routine_control(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_routine_control(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
|
||||
case KISS_PROGRAM_STARTUP_CFG: {
|
||||
output = kiss_callback_program_startup(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_program_startup(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
|
||||
case KISS_ERASE_STARTUP_CFG: {
|
||||
output = kiss_callback_erase_startup(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_erase_startup(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
|
||||
case KISS_READ_DID: {
|
||||
output = kiss_callback_read_did(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_read_did(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
case KISS_READ_MEM_ADDR : {
|
||||
output = kiss_callback_read_memory_by_addr(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_read_memory_by_addr(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
case KISS_RESTART: {
|
||||
output = kiss_callback_reset(input_frame_from_host, input_len, response_buffer, resp_buf_ln);
|
||||
output = kiss_callback_reset(input_frame_from_host, input_len, response_buffer, resp_buf_ln, transport_media);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#define KISS_NRC_RESPONSE_INCORRECT_MESSAGE_LN 6
|
||||
#define KISS_NRC_RESPONSE_SEC_ACCESS_DENIED_LN 6
|
||||
#define KISS_NRC_RESPONSE_COND_NOT_CORRECT_LN 6
|
||||
#define KISS_NRC_RESPONSE_SEQUENCE_ERR_LN 6
|
||||
#define KISS_NRC_RESPONSE_ACCESS_DENIED_LN 6
|
||||
|
||||
/// ==================================================================================================
|
||||
/// LOCAL DATA TYPES
|
||||
|
@ -70,7 +72,7 @@ static const uint8_t kiss_nrc_response_incorrect_message_ln_or_format[KISS_NRC_R
|
|||
FEND
|
||||
};
|
||||
|
||||
//!< Negative response to incorrect message lenght or format
|
||||
//!< NRC_SECURITY_ACCESS_DENIED
|
||||
static const uint8_t kiss_nrc_response_security_access_denied[KISS_NRC_RESPONSE_SEC_ACCESS_DENIED_LN] = {
|
||||
FEND,
|
||||
NONSTANDARD,
|
||||
|
@ -80,8 +82,8 @@ static const uint8_t kiss_nrc_response_security_access_denied[KISS_NRC_RESPONSE_
|
|||
FEND
|
||||
};
|
||||
|
||||
// NRC_CONDITIONS_NOT_CORRECT
|
||||
static const uint8_t kiss_nrc_conditions_not_correct[KISS_NRC_RESPONSE_COND_NOT_CORRECT_LN] = {
|
||||
//!< NRC_CONDITIONS_NOT_CORRECT
|
||||
static const uint8_t kiss_nrc_conditions_not_correct[KISS_NRC_RESPONSE_UNKNOWN_SERVICE_LN] = {
|
||||
FEND,
|
||||
NONSTANDARD,
|
||||
KISS_NRC_RESPONSE_UNKNOWN_SERVICE_LN,
|
||||
|
@ -90,6 +92,16 @@ static const uint8_t kiss_nrc_conditions_not_correct[KISS_NRC_RESPONSE_COND_NOT_
|
|||
FEND
|
||||
};
|
||||
|
||||
//!< NRC_SEQUENCE_ERROR
|
||||
static const uint8_t kiss_nrc_sequence_error[KISS_NRC_RESPONSE_SEQUENCE_ERR_LN] = {
|
||||
FEND,
|
||||
NONSTANDARD,
|
||||
KISS_NRC_RESPONSE_SEQUENCE_ERR_LN,
|
||||
KISS_NEGATIVE_RESPONSE_SERVICE,
|
||||
NRC_REQUEST_SEQUENCE_ERROR,
|
||||
FEND
|
||||
};
|
||||
|
||||
/// ==================================================================================================
|
||||
/// GLOBAL VARIABLES
|
||||
/// ==================================================================================================
|
||||
|
@ -194,3 +206,19 @@ int kiss_nrc_response_fill_conditions_not_correct(uint8_t * buffer) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param buffer
|
||||
* @return
|
||||
*/
|
||||
int kiss_nrc_response_fill_sequence_error(uint8_t * buffer) {
|
||||
if (buffer != 0x00) {
|
||||
memcpy(buffer, kiss_nrc_sequence_error, KISS_NRC_RESPONSE_COND_NOT_CORRECT_LN);
|
||||
|
||||
return KISS_NRC_RESPONSE_COND_NOT_CORRECT_LN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
24
src/main.c
24
src/main.c
|
@ -102,6 +102,7 @@
|
|||
|
||||
#include "drivers/dallas.h"
|
||||
|
||||
#include "kiss_communication/diagnostics_services/kiss_security_access.h"
|
||||
#include <kiss_communication/kiss_communication.h>
|
||||
#include <kiss_communication/kiss_communication_aprsmsg.h>
|
||||
#include <etc/kiss_configuation.h>
|
||||
|
@ -469,7 +470,7 @@ static void main_gsm_pool_handler(
|
|||
#define KISS_RESPONSE_MESSAGE_LN retval
|
||||
|
||||
// parse KISS request
|
||||
KISS_RESPONSE_MESSAGE_LN = kiss_parse_received(from_message, *from_message_ln, NULL, NULL, response_message, MAIN_KISS_FROM_MESSAGE_LEN);
|
||||
KISS_RESPONSE_MESSAGE_LN = kiss_parse_received(from_message, *from_message_ln, NULL, NULL, response_message, MAIN_KISS_FROM_MESSAGE_LEN, type);
|
||||
|
||||
// if a response was generated
|
||||
if (KISS_RESPONSE_MESSAGE_LN > 0) {
|
||||
|
@ -1256,6 +1257,8 @@ int main(int argc, char* argv[]){
|
|||
bme280_read_calibration(bme280_calibration_data);
|
||||
}
|
||||
|
||||
kiss_security_access_init(main_config_data_basic);
|
||||
|
||||
if (main_kiss_enabled == 1) {
|
||||
// preparing initial beacon which will be sent to host PC using KISS protocol via UART
|
||||
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "=%s%c%c%s%c%c %s", main_string_latitude, main_config_data_basic->n_or_s, main_symbol_f, main_string_longitude, main_config_data_basic->e_or_w, main_symbol_s, main_config_data_basic->comment);
|
||||
|
@ -1669,26 +1672,33 @@ int main(int argc, char* argv[]){
|
|||
// if new KISS message has been received from the host
|
||||
if (main_kiss_srl_ctx_ptr->srl_rx_state == SRL_RX_DONE && main_kiss_enabled == 1) {
|
||||
// parse i ncoming data and then transmit on radio freq
|
||||
ln = kiss_parse_received(srl_get_rx_buffer(main_kiss_srl_ctx_ptr), srl_get_num_bytes_rxed(main_kiss_srl_ctx_ptr), &main_ax25, &main_afsk, main_small_buffer, KISS_CONFIG_DIAGNOSTIC_BUFFER_LN);
|
||||
ln = kiss_parse_received (srl_get_rx_buffer (main_kiss_srl_ctx_ptr),
|
||||
srl_get_num_bytes_rxed (main_kiss_srl_ctx_ptr),
|
||||
&main_ax25,
|
||||
&main_afsk,
|
||||
main_small_buffer,
|
||||
KISS_CONFIG_DIAGNOSTIC_BUFFER_LN,
|
||||
KISS_TRANSPORT_SERIAL_PORT);
|
||||
if (ln == 0) {
|
||||
kiss10m++; // increase kiss messages counter
|
||||
kiss10m++; // increase kiss messages counter
|
||||
}
|
||||
else if (ln > 0) {
|
||||
// if a response (ACK) to this KISS frame shall be sent
|
||||
|
||||
// wait for any pending transmission to complete
|
||||
srl_wait_for_tx_completion(main_kiss_srl_ctx_ptr);
|
||||
srl_wait_for_tx_completion (main_kiss_srl_ctx_ptr);
|
||||
|
||||
srl_send_data(main_kiss_srl_ctx_ptr, main_small_buffer, SRL_MODE_DEFLN, ln, SRL_INTERNAL);
|
||||
srl_send_data (main_kiss_srl_ctx_ptr, main_small_buffer, SRL_MODE_DEFLN, ln,
|
||||
SRL_INTERNAL);
|
||||
}
|
||||
|
||||
// restart KISS receiving to be ready for next frame
|
||||
srl_receive_data(main_kiss_srl_ctx_ptr, 120, FEND, FEND, 0, 0, 0);
|
||||
srl_receive_data (main_kiss_srl_ctx_ptr, 120, FEND, FEND, 0, 0, 0);
|
||||
}
|
||||
|
||||
// if there were an error during receiving frame from host, restart rxing once again
|
||||
if (main_kiss_srl_ctx_ptr->srl_rx_state == SRL_RX_ERROR && main_kiss_enabled == 1) {
|
||||
srl_receive_data(main_kiss_srl_ctx_ptr, 120, FEND, FEND, 0, 0, 0);
|
||||
srl_receive_data (main_kiss_srl_ctx_ptr, 120, FEND, FEND, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define MESSAGE_MAX_LENGHT 67
|
||||
|
||||
#define MESSAGE_NUMBER_STRING_BUFFER 5 ///!< include room of null terminator
|
||||
#define MESSAGE_NUMBER_STRING_BUFFER 7 ///!< include room of null terminator
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -22,9 +22,9 @@
|
|||
typedef enum message_source_t {
|
||||
MESSAGE_SOURCE_UNINITIALIZED = 0x0,
|
||||
MESSAGE_SOURCE_APRSIS = 0x1,
|
||||
MESSAGE_SOURCE_APRSIS_HEXCNTR = 0x2,
|
||||
MESSAGE_SOURCE_APRSIS_HEXCNTR = 0x2, //!< message counter is a hex number
|
||||
MESSAGE_SOURCE_RADIO = 0x11,
|
||||
MESSAGE_SOURCE_RADIO_HEXCNTR = 0x12
|
||||
MESSAGE_SOURCE_RADIO_HEXCNTR = 0x12 //!< mnessage counter is a hex number
|
||||
}message_source_t;
|
||||
|
||||
/**
|
||||
|
|
Ładowanie…
Reference in New Issue