REQ help: circular buffer
Posted: Thu Mar 19, 2020 6:28 pm
Hey there,
I've started a project I was working on last summer again.
But my old brain sometimes jumps from here to there.
I don't know what I was doing at that time
The project I was working on did almost what I wanted, but then failed and because of other priorities I left it alone all this time.
The one thing I always struggle is the use of the circular buffer.
- My project receives via RS232 data on it's RX pin from a wireless device.
- After a while, after first receiving data, a certain pin on the wireless device pin goes low (as a sign that there is data being received) after a few ms.
- I want to store the data the Arduino receives in a variable (text) on which I can act later.
But the problem is that the CB doesn't work like I expect to.
I can't seem to get it working.
Is there anyone that can make an example that does the following?
As soon as there is data on the RX pin (interupt?) the data gets stored in a circular buffer.
As soon as the data stops, and a certain IO pin goes back high, there is time to search the CB for a string (let"s say the string "start") and returns the 15 next positions from the CB as a string.
So this is what it should do.
1- First data is received on the RX pin
2- Store data in CB
3- Meanwhile a certain pin is low on a connected device.
4- Keep reading data until the datastream stops and put this in the CB
5- A few ms after the last received data the IO pin goes high again.
6- Now the CB has to be searched for a specific search string (let's say "start")
7- The data after the first instance for this search string should be stored in a textstring (the next 15 positions in the CB)
8- This textstring should be ready to act on.
9- Maybe the buffer must be flushed after this action
Is there anyone that can make an example for me to study?
I need to find out the right structure to work with the CB and get the data in a string variable.
Thanks for your help
I've started a project I was working on last summer again.
But my old brain sometimes jumps from here to there.
I don't know what I was doing at that time
The project I was working on did almost what I wanted, but then failed and because of other priorities I left it alone all this time.
The one thing I always struggle is the use of the circular buffer.
- My project receives via RS232 data on it's RX pin from a wireless device.
- After a while, after first receiving data, a certain pin on the wireless device pin goes low (as a sign that there is data being received) after a few ms.
- I want to store the data the Arduino receives in a variable (text) on which I can act later.
But the problem is that the CB doesn't work like I expect to.
I can't seem to get it working.
Is there anyone that can make an example that does the following?
As soon as there is data on the RX pin (interupt?) the data gets stored in a circular buffer.
As soon as the data stops, and a certain IO pin goes back high, there is time to search the CB for a string (let"s say the string "start") and returns the 15 next positions from the CB as a string.
So this is what it should do.
1- First data is received on the RX pin
2- Store data in CB
3- Meanwhile a certain pin is low on a connected device.
4- Keep reading data until the datastream stops and put this in the CB
5- A few ms after the last received data the IO pin goes high again.
6- Now the CB has to be searched for a specific search string (let's say "start")
7- The data after the first instance for this search string should be stored in a textstring (the next 15 positions in the CB)
8- This textstring should be ready to act on.
9- Maybe the buffer must be flushed after this action
Is there anyone that can make an example for me to study?
I need to find out the right structure to work with the CB and get the data in a string variable.
Thanks for your help