-void add_to_buffer(buffer *p_Buffer, char *message,char message_level){
- unsigned int x=0;
- /*move the head up one. the head always points at the last written data*/
- p_Buffer->head++;
-
-// printf("p_Buffer->tail=%d\n",p_Buffer->tail);
-// printf("p_Buffer->head=%d\n",p_Buffer->head);
- if (p_Buffer->head >=BUFFER_SIZE-1) {
-// printf("buffer overflow\n");
- p_Buffer->head -= (BUFFER_SIZE-1); /*wrap the head around the buffer*/
-// printf("new p_Buffer->head=%d\n",p_Buffer->head);
- }
- /*if the buffer is full then delete last entry by moving the tail*/
- if (p_Buffer->head==p_Buffer->tail){
-// printf("moving buffer tail from %d to ",p_Buffer->tail);
- p_Buffer->tail++;
- if (p_Buffer->tail >=BUFFER_SIZE) p_Buffer->tail -= BUFFER_SIZE;/*wrap the tail around the buffer*/
-// printf("%d\n",p_Buffer->tail);