Merge branch 'Dennis_CCS'

This commit is contained in:
Dennis Boekholtz 2024-04-13 23:43:03 +02:00
commit edc09d505b
3 changed files with 11 additions and 7 deletions

View File

@ -9,6 +9,7 @@
CLI_charOutFn CLI_charOut;
CMDList_t* CMDList;
FIFOBuffChar_t* FIFO;
int i;
// initilize and register the lineout print function
bool CLI_init(CLI_charOutFn lineOut, CMDList_t* cmdList)
@ -41,7 +42,7 @@ char* fifoToString(FIFOBuffChar_t* fifo)
char* out = malloc(fifo->size + 1);
char* write_p = out;
for (int i = fifo->size; i > 0; i--)
for (i = fifo->size; i > 0; i--)
{
FIFOBuffChar_get(fifo, write_p);
write_p++;
@ -74,7 +75,7 @@ int tryExecute(FIFOBuffChar_t* fifo)
{
char err[100];
sprintf(&err[0], "command not found: %s\n> ", line);
for (int i=0; err[i] != 0; i++)
for (i=0; err[i] != 0; i++)
{
char c[2] = {err[i], 0};
(*CLI_charOut)(&c[0]);
@ -139,7 +140,7 @@ bool CLI_charIn(char c)
case 27: // escape (start for arrow keys)
sprintf(&str[0], "\ninvlid char: ESC - (%i)\n", c);
for (int i=0; str[i] != 0; i++)
for (i=0; str[i] != 0; i++)
{
char ch[2] = {str[i], 0};
(*CLI_charOut)(&ch[0]);
@ -148,7 +149,7 @@ bool CLI_charIn(char c)
default:
sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c);
for (int i=0; str[i] != 0; i++)
for (i=0; str[i] != 0; i++)
{
char ch[2] = {str[i], 0};
(*CLI_charOut)(&ch[0]);

View File

@ -5,6 +5,7 @@
#include <string.h>
#include <stdio.h>
int i;
// initilises a CMDList_t with all NULL pointers
CMDList_t* CMDList_init()
{
@ -21,7 +22,7 @@ int CMDList_deinit(CMDList_t *list)
// printf("deinit %p\n", (void*)list);
// printf("deinit e %p\n", list->e);
for (int i = 0; i < 26; i++)
for (i = 0; i < 26; i++)
{
if (*(list_p + i) != NULL)
{
@ -31,7 +32,7 @@ int CMDList_deinit(CMDList_t *list)
}
//TODO: fix "free(): invalid pointer"
// free(list);
free(list);
return 0;
}

View File

@ -1,4 +1,4 @@
#include "FIFOBuffChar.h"
#include "C:\Users\denbo\git\ems31_2023-2024_groep_09_ccs\ ems31_2023-2024_groep_09_submodules_2\FIFOBuff\FIFOBuffChar.h"
#include <stdlib.h>
#include <stddef.h>
@ -141,6 +141,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo)
default: // buffer is at least 2 element big
// find the second last element
{
FIFOBuffChar_element_t* secondLastEl = fifo->FirstEl_p;
while (
secondLastEl->nextElement != fifo->LastEl_p
@ -159,6 +160,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo)
ok = true;
break;
}
}
return ok;
}