Searching a UART Rinig_Buffer for a specific character

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Searching a UART Rinig_Buffer for a specific character

663 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dizgah on Mon Feb 29 01:11:46 MST 2016
Hi,
I initialed UART peripheral with Ring_Buffer, I need to searching in the  received data which are stored in the ring buffer ,When i pop an item it cleared from buffer which is not desired for me, i only need to move on the buffer and investigate characters without changing it's content,copying complete buffer is not desired too & data stream is coming in unregulated time.whats your suggestion?
WBR.
Labels (1)
0 Kudos
7 Replies

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by miccio on Thu Mar 10 10:35:05 MST 2016
without seeing the code it's hard to say, especially with such cryptic and seemingly-random error.

Please post some code, and we'll be able to help you out :)
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dizgah on Sun Mar 06 22:11:54 MST 2016
I don't have accessing to my code right now but as i remember ,it showed:
-> instruction is undefined!
thank for your answers.
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Mar 06 00:13:26 MST 2016

Quote: dizgah
Are you mean external accessing to this structure is impossible?
Can you please explain more ?



You are describing that there's a buffer structure and you want to access received data, right?

So where's the problem? Use this structure...

You are talking about compiler errors but not showing your code / project :~
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dizgah on Sat Mar 05 23:35:13 MST 2016

Quote: R2D2

Quote: dizgah
As i know Ring_Buffer is a structure but when i want to acces to it's content with e.g. Ring_Buffer->data compiler return error.



:quest:

The just use this structure...


excuse me ,but i don't understand your mind.
Are you mean external accessing to this structure is impossible?
Can you please explain more ?
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat Mar 05 02:35:09 MST 2016

Quote: dizgah
As i know Ring_Buffer is a structure but when i want to acces to it's content with e.g. Ring_Buffer->data compiler return error.



:quest:

The just use this structure...
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dizgah on Sat Mar 05 01:06:05 MST 2016

Quote: miccio
Hi dizgah,

You could deploy your own IRQ handler and perform the validation/check in there.
Just check what's inside the default LPCOpen handler function, dump its content in the IRQ, and check the content of each received byte before storing it into the buffer
However, remember to leave the TX part unchanged.

Here's a starting point:

void UART0_IRQHandler(void) {
// handles tx - same as default handler
if ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(_uart_ptr, &_txring);

if (RingBuffer_IsEmpty(&_txring)) {
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_TXRDY);
}
}

// handles rx
while ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_RXRDY) != 0) {
uint8_t current_char = Chip_UART_ReadByte(_uart_ptr);
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_RXRDY);
if(current_char == YOUR_CHAR) {
// do something 
} else {
// otherwise, store it in the ring buffer
RingBuffer_Insert(&_rxring, &current_char );
}
Chip_UART_IntEnable(_uart_ptr, UART_INTEN_RXRDY);
}
}



Good luck!


ِDear miccio
I think this is a wise scenario to searching for my desired byte in IRQ handler (& then i can sore it's place on the buffer) but my problem is selective accessing to Ring_Buffer elements.
i need to access to each item & read it's content,Change,search,Replace,Copy&... it.
As i know Ring_Buffer is a structure but when i want to acces to it's content with e.g. Ring_Buffer->data compiler return error.
WBR.
0 Kudos

569 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by miccio on Tue Mar 01 18:00:45 MST 2016
Hi dizgah,

You could deploy your own IRQ handler and perform the validation/check in there.
Just check what's inside the default LPCOpen handler function, dump its content in the IRQ, and check the content of each received byte before storing it into the buffer
However, remember to leave the TX part unchanged.

Here's a starting point:

void UART0_IRQHandler(void) {
// handles tx - same as default handler
if ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(_uart_ptr, &_txring);

if (RingBuffer_IsEmpty(&_txring)) {
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_TXRDY);
}
}

// handles rx
while ((Chip_UART_GetStatus(_uart_ptr) & UART_STAT_RXRDY) != 0) {
uint8_t current_char = Chip_UART_ReadByte(_uart_ptr);
Chip_UART_IntDisable(_uart_ptr, UART_INTEN_RXRDY);
if(current_char == YOUR_CHAR) {
// do something 
} else {
// otherwise, store it in the ring buffer
RingBuffer_Insert(&_rxring, &current_char );
}
Chip_UART_IntEnable(_uart_ptr, UART_INTEN_RXRDY);
}
}



Good luck!
0 Kudos