weird behavior... message handling not working currently

stable
Penguin 3 years ago
parent b5ef056990
commit 4bc852b44a

@ -20,7 +20,7 @@ AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false

@ -104,3 +104,129 @@ q
b 411
r
q
b 145
r
s
n
q
b 146
q
b 146
b main.c:146
r
q
b main.c:146
r
s
del
b main.c:147
r
q
b main.c:147
r
b p_serial_mgr.c:43
r
p rxc
p/c rxc
p/x rxc
c
c
n
r
p rxc
del
b p_serial_mgr.c:113
r
b p_serial_mgr.c:68
r
q
b p_serial_mgr.c:68
r
p rxc
c
q
b p_serial_mgr.c:113
r
q
q
b p_serial_mgr.c:119
r
q
b p_serial_mgr.c:87
r
p serial_pkt_cb.buffer[serial_pkt_cb.head]
q
b p_serial_mgr.c:87
r
b p_serial_mgr.c:122
r
q
q
b p_serial_mgr.c:100 if frame_index_tracker > 5
r
b p_serial_mgr.c:100 if frame_index_tracker > 0
r
q
b p_serial_mgr.c:79
r
b p_serial_mgr.c:100 if frame_index_tracker > 5
r
r
b p_serial_mgr.c:110 if frame_index_tracker > 5
r
del
b p_serial_mgr.c:79
r
del
b p_serial_mgr.c:86
r
p rxc
p serial_pkt_cb.buffer[serial_pkt_cb.head]
p serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data
p/x serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data
q
b p_serial_mgr.c:86
r
p rxc
p serial_pkt_cb.buffer[serial_pkt_cb.head]
p/x serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data
q
b p_serial_mgr.c:86
r
p/x serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data
p/x serial_pkt_cb.buffer
p\ serial_pkt_cb.buffer
p\ serial_pkt_cb.buffer
p\serial_pkt_cb.buffer
pserial_pkt_cb.buffer
p serial_pkt_cb.buffer
p serial_pkt_cb.buffer[0]
p/x serial_pkt_cb.buffer[0]
q
b p_serial_mgr.c:44
r
p serial_pkt_cb.head
p serial_pkt_cb.buffer[serial_pkt_cb.head]
p/x serial_pkt_cb.buffer[serial_pkt_cb.head]
p sizeof(serial_pkt_t)
q
b p_serial_mgr.c:44
r
p sizeof(serial_pkt_t)
c
c
r
make
r
c
r
p sizeof(serial_pkt_t)
p/x serial_pkt_cb.buffer[serial_pkt_cb.head]
make
r
p/x serial_pkt_cb.buffer[serial_pkt_cb.head]
c
r
c
del
q

@ -126,6 +126,8 @@ int main(void)
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
HAL_TIM_Base_Start_IT(&htim6);
p_serial_mgr_start();
uint16_t motor_degrees = 0;
/* USER CODE END 2 */

5213
gdb.txt

File diff suppressed because it is too large Load Diff

@ -29,8 +29,8 @@ static UART_HandleTypeDef *_serial_huart_inst = NULL;
static serial_state_t sstate = SS_IDLE;
static uint8_t rxc = '\0';
static serial_pkt_t pkt_bank[10];
static p_cb_serial_pkt_t serial_pkt_cb;
volatile serial_pkt_t pkt_bank[10];
volatile p_cb_serial_pkt_t serial_pkt_cb;
static volatile uint8_t start_index_tracker = 0;
static volatile uint8_t frame_index_tracker = 0;
@ -56,24 +56,27 @@ void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
case 0: // source addr
{
serial_pkt_cb.buffer[serial_pkt_cb.head].src_addr = rxc;
start_index_tracker++;
}
break;
case 1:
{
serial_pkt_cb.buffer[serial_pkt_cb.head].dest_addr = rxc;
start_index_tracker++;
}
break;
case 2:
{
serial_pkt_cb.buffer[serial_pkt_cb.head].len = rxc;
start_index_tracker = 0;
frame_index_tracker = 0;
serial_pkt_cb.buffer[serial_pkt_cb.head].len = rxc;
sstate = SS_FRAME;
}
break;
default:
{
// shouldnt get here
for (;;) {}
asm volatile("nop");
}
};
}
@ -82,8 +85,11 @@ void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (rxc == 0x7E)
{
asm volatile("nop");
// error occured. bail
#pragma message(Reminder "add a safe escape routine for this")
sstate = SS_IDLE;
memset(&serial_pkt_cb.buffer[serial_pkt_cb.head], 0, sizeof(serial_pkt_t));
}
else if (rxc == 0x7D)
{
@ -92,7 +98,7 @@ void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
else
{
serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data[frame_index_tracker++] = rxc;
if (frame_index_tracker + 1 == serial_pkt_cb.buffer[serial_pkt_cb.head].len)
if (frame_index_tracker >= serial_pkt_cb.buffer[serial_pkt_cb.head].len)
{
sstate = SS_CHECKSUM;
}
@ -102,17 +108,23 @@ void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
case SS_ESC:
{
serial_pkt_cb.buffer[serial_pkt_cb.head].frame_data[frame_index_tracker++] = rxc ^ 0x20;
if (frame_index_tracker + 1 == serial_pkt_cb.buffer[serial_pkt_cb.head].len)
if (frame_index_tracker >= serial_pkt_cb.buffer[serial_pkt_cb.head].len)
{
sstate = SS_CHECKSUM;
}
else
{
sstate = SS_FRAME;
}
}
break;
case SS_CHECKSUM:
{
frame_index_tracker = 0;
serial_pkt_cb.buffer[serial_pkt_cb.head].checksum = rxc;
serial_pkt_cb.buffer[serial_pkt_cb.head].b_ready = true;
serial_pkt_cb.head = (serial_pkt_cb.head + 1) % serial_pkt_cb.max_len;
sstate = SS_IDLE;
}
break;
default:
@ -134,6 +146,7 @@ void p_serial_mgr_init(UART_HandleTypeDef *huart)
_serial_huart_inst = huart;
_serial_huart_inst->RxCpltCallback = UART1_RxCpltCallback;
memset(pkt_bank, 0, sizeof(serial_pkt_t) * 10);
p_cb_serial_pkt_init(&serial_pkt_cb, pkt_bank, 10);
}
@ -144,7 +157,7 @@ serial_pkt_t *p_serial_mgr_service(void)
{
if (serial_pkt_cb.buffer[ind].b_ready)
{
return &serial_pkt_cb.buffer;
return &serial_pkt_cb.buffer[ind];
}
}
return NULL;

@ -6,11 +6,11 @@
typedef struct serial_pkt_t
{
uint8_t frame_data[256];
uint8_t src_addr;
uint8_t dest_addr;
int len;
uint8_t frame_data[256];
uint8_t checksum;
uint8_t len;
bool b_ready;
} serial_pkt_t;
@ -18,4 +18,6 @@ void p_serial_mgr_init(UART_HandleTypeDef *huart);
serial_pkt_t *p_serial_mgr_service(void);
void p_serial_mgr_start();
#endif

@ -122,6 +122,10 @@ PB_CB_STATUS p_cb_serial_pkt_init(p_cb_serial_pkt_t *inst, serial_pkt_t *buff, u
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
for (int ind = 0; ind < max_length; ind++)
{
memset(inst->buffer[ind].frame_data, 0, 256);
}
} while (0);
// Debugging

Loading…
Cancel
Save