Welcome, Guest. Please login or register.

Author Topic: Buffers in general and this case....  (Read 1974 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Buffers in general and this case....
« on: June 07, 2004, 05:41:41 PM »
Ok, I must admit I never read almost anything about them, but I just would like your opinions on this...

I want to receive some data over (say the serial devivce for example) and store it somewhere. Then analyse it and depending on the result do some action or get the next unit of data to repeat the process. The analysis I want to make compares the data with the previous one.

Two main doubts:

1- At some point when the buffer gets filled it has to return to the initial address again right? So the code should expect that special case... Kinda like this: Successively fill each buffer space corresponding to the size of the data I'm receiving starting at the lowest address of the buffer. Then compare each one with the previous one as it gets filled. When reach end of buffer start filling buffer from the start address again and compare the last buffer data with the first one (the special case).
This buffer would have the advantage of when analysis of data gets more slow it would still be getting data (filling the buffer), maybe with DMA (?). When it's the data comming in that gets slow I'd already have a buffer to compensate.
If this doesnt make sense at all let me know too:-D

2- Since, just for now, for experimenting, I'm using an already existing DOS program to get the data from the serial port, and it saves it on a file, should I use the ramdisk to store the files in succession and then compare them? I guess that's the only choice anyway.

3- Ok just by curiosity, isn't that the way buffers work in general anyway?...

Thx for the patiente... 8-)
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Sidewinder

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 241
    • Show only replies by Sidewinder
    • http://www.liquido2.com
Re: Buffers in general and this case....
« Reply #1 on: June 08, 2004, 12:40:11 AM »
In general a buffer is simply a temporary storage place for data before it is processed.  Most buffers act just like a queue, that is "first in, first out" (FIFO).  The way this is actually accomplished depends on the implementation.

Some buffers are created using linked lists.  This offers the most flexability, but it uses more memory.

If a large block of memory is reserved as the buffer (such as an array) then a strict FIFO implementation would be quite slow because memory would have to be shifted each time data is added to the buffer.

The solution that you describe would be more complex but would be much faster than the strict FIFO implementation and use less memory than the linked list.

Let me know if you have any questions or would like some code examples.

Sidewinder
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Re: Buffers in general and this case....
« Reply #2 on: June 08, 2004, 09:47:34 AM »
"...The solution that you describe would be more complex but would be much faster than the strict FIFO implementation and use less memory than the linked list."

Wow! Just comes to prove that even when one doesn't know anything about what already is out there sometimes one also can make cool stuff:-D  

"
Let me know if you have any questions or would like some code examples."

Thx. Not for now. I'll return to the thread later...

 
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show only replies by Noster
Re: Buffers in general and this case....
« Reply #3 on: June 08, 2004, 10:39:16 AM »
Hi

The buffer you described is known as so called ring-buffer and a usual buffer for serial input.

If you use an existing DOS program to get the data from the serial port you should think about writing this data into a PIPE instead of the ramdisk and read the data to be compared from this PIPE. There is an existing device called PIPE: implemented in the AmigaOS, I'm not shure about the restrictions of this device but it might be used for this purpose.

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis
 

Offline Sidewinder

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 241
    • Show only replies by Sidewinder
    • http://www.liquido2.com
Re: Buffers in general and this case....
« Reply #4 on: June 08, 2004, 08:05:11 PM »
Quote
Wow! Just comes to prove that even when one doesn't know anything about what already is out there sometimes one also can make cool stuff:-D


Yes!  Now, to be honest, it isn't a totally new idea, but for someone who doesn't deal with algorithems very often it shows a great aptitude for creative problem solving.  You can go far in the world of programming with a thought process like that!

Sidewinder
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Re: Buffers in general and this case....
« Reply #5 on: June 09, 2004, 06:42:15 PM »
@Noster
Cool, I'll take the advice and read something about the Amiga's PIPE when I have more time...

@Sidewinder
It would be cool to belive that, but even if it was true, as a compensation my lazyness beats that by ten fold easily :-D

\\"We made Amiga, they {bleep}ed it up\\"