Hello All,
I am programming a microcontroller, it get s data from a serial cable 1 byte at a time. It has been programmed to write each received byte to the buffer.
I have functions to write or read a byte from the buffer.
I have the buffer filled with data of about 102 bytes. how can I extract from the 70th byte up to the 82nd byte? the value I need is 12 bytes in total but it starts from the 70th byte?
I will appreciate any help with this task.
below is a sample of the code that removes a byte from the buffer
Code:
/****************************************************************************/
/*** Macro Definitions ***/
/****************************************************************************/
#define CIRCBUFF_PTR_MASK 0x03FFU
#define MAX_CIRCBUFF_SIZE 1024
#define NBR_QUEUES 2
/***********************************************************/
typedef struct
{
uint16 u16Head;
uint16 u16Tail;
uint8 u8Buff[MAX_CIRCBUFF_SIZE];
} tsCircBuff;
typedef enum {RX_QUEUE = 0, TX_QUEUE } eQueueRef;
PRIVATE tsCircBuff sRxQueue, sTxQueue;
PRIVATE const tsCircBuff *apsQueueList[NBR_QUEUES] = { &sRxQueue, &sTxQueue };
PUBLIC uint8 u8SerialQ_RemoveItem(eQueueRef eQueue)
{
uint8 u8Item = 0;
tsCircBuff *psQueue;
psQueue = (tsCircBuff *)apsQueueList[eQueue]; /* Set pointer to the requested queue */
if (psQueue->u16Tail != psQueue->u16Head)
{
/* Data available on queue so remove a single item */
u8Item = psQueue->u8Buff[psQueue->u16Tail];
psQueue->u16Tail = (psQueue->u16Tail + 1) & CIRCBUFF_PTR_MASK;
}
return(u8Item);
}