473,583 Members | 3,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing interrupt driven circular buffer

Can someone point out source code for a safe circular buffer receiver
transmitter? It's for sending and receiving bytes via RS232.

Thanks in advance.

Oct 27 '07 #1
12 7116
Sven wrote:
Can someone point out source code for a safe circular buffer receiver
transmitter? It's for sending and receiving bytes via RS232.

Thanks in advance.
http://home.planet.nl/~burry004/COMPORT.ZIP
Does not need an interrupt, does need port access, and you can
modify it to your harts desire.
Oct 28 '07 #2
Sven wrote:
Can someone point out source code for a safe circular buffer receiver
transmitter? It's for sending and receiving bytes via RS232.

Thanks in advance.
Sven,

What you ask for is off-topic on comp.lang.c. Things like interrupts,
receivers, transmitters and RS232 are platform dependent and hence not
covered by the ISO/ANSI C Standard. Your best bet is finding a newsgroup
that discusses your platform.

It is all covered in the FAQ, which can be found at http://c-faq.com/

Your question pertains to Qs 19.7 and 19.40b, but I recommend reading
the whole section 19.

<off-topic>
When I was doing something like that back in '96, I found great help in
a book "Serial Communication" by Peter W Gofton, SYBEX Inc., 1994. It
covers DOS and Windows (but see the publishing date). I am sure there
are better and more up-to-date books available now.
</off-topic>

Good luck,
Peter
Oct 28 '07 #3
Sven wrote:
>
Can someone point out source code for a safe circular buffer
receiver transmitter? It's for sending and receiving bytes via
RS232.
All you need to do is disable interrupts (or their equivalents)
before altering the counters and flags.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
--
Posted via a free Usenet account from http://www.teranews.com

Oct 28 '07 #4
Sjouke Burry wrote, On 28/10/07 00:53:
Sven wrote:
>Can someone point out source code for a safe circular buffer receiver
transmitter? It's for sending and receiving bytes via RS232.

Thanks in advance.

http://home.planet.nl/~burry004/COMPORT.ZIP
Does not need an interrupt, does need port access, and you can
modify it to your harts desire.
That code is highly DOS specific. Since it has function definitions
(rather than declarations) in a header file I would also suggest it is
badly written.

Sven would be best asking somewhere like comp.arch.embed ded and
specifying what his target is and rather more about his requirements. I
know how I've implemented serial communications and it has been
radically different depending on what the processor was capable of and
what the requirements were.
--
Flash Gordon
Oct 28 '07 #5
CBFalconer wrote:
Sven wrote:
>Can someone point out source code for a safe circular buffer
receiver transmitter? It's for sending and receiving bytes via
RS232.

All you need to do is disable interrupts (or their equivalents)
before altering the counters and flags.
In fact, you don't, if volatile (and of course atomic) read and write
indexes are modified exclusively by the read routine and the write
routine respectively. Good encapsulation saves messing with disabling
interrupts.

--
Ark
Oct 28 '07 #6
Ark Khasin wrote:
CBFalconer wrote:
>Sven wrote:
>>Can someone point out source code for a safe circular buffer
receiver transmitter? It's for sending and receiving bytes via
RS232.

All you need to do is disable interrupts (or their equivalents)
before altering the counters and flags.

In fact, you don't, if volatile (and of course atomic) read and
write indexes are modified exclusively by the read routine and
the write routine respectively. Good encapsulation saves messing
with disabling interrupts.
No it doesn't. Consider, for example, something with multiple
readers and one transmitter.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 28 '07 #7
CBFalconer wrote:
Ark Khasin wrote:
>CBFalconer wrote:
>>Sven wrote:

Can someone point out source code for a safe circular buffer
receiver transmitter? It's for sending and receiving bytes via
RS232.
All you need to do is disable interrupts (or their equivalents)
before altering the counters and flags.
In fact, you don't, if volatile (and of course atomic) read and
write indexes are modified exclusively by the read routine and
the write routine respectively. Good encapsulation saves messing
with disabling interrupts.

No it doesn't. Consider, for example, something with multiple
readers and one transmitter.
And... what those multiple readers would end up reading?
Oct 28 '07 #8
Ark Khasin wrote:
CBFalconer wrote:
>Ark Khasin wrote:
>>CBFalconer wrote:
Sven wrote:

Can someone point out source code for a safe circular buffer
receiver transmitter? It's for sending and receiving bytes via
RS232.

All you need to do is disable interrupts (or their equivalents)
before altering the counters and flags.

In fact, you don't, if volatile (and of course atomic) read and
write indexes are modified exclusively by the read routine and
the write routine respectively. Good encapsulation saves messing
with disabling interrupts.

No it doesn't. Consider, for example, something with multiple
readers and one transmitter.

And... what those multiple readers would end up reading?
For example, the keyboard. How else can the single keyboard be
attached to various processes?

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 28 '07 #9
CBFalconer wrote:
Ark Khasin wrote:
>>CBFalconer wrote:
>>>Consider, for example, something with multiple
readers and one transmitter.

And... what those multiple readers would end up reading?

For example, the keyboard. How else can the single keyboard be
attached to various processes?
This is deeply in the OT-land, but... I doubt the multiple processes
read a single keyboard simultaneously. Usually only one process at a
time has a keyboard focus. Even if they *do* all receive keystrokes,
they do so via some queueing mechanism. They do *not* access the
keyboard directly.
Oct 28 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1919
by: Ben Jeurissen | last post by:
Hello, I have to deal with the following issue in C++: Two threads are started from the main thread, both capturing images from a different firewire camera. Both threads take shots of 460800 bytes at a rate of 30 frames per second. This works fine, without frame loss, and I can display the two framestreams on screen. Now I would like...
1
12831
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
2
6614
by: William Stacey | last post by:
Working with implementing a circular buffer for a producer/consumer deal. Have not done one in a while. The following seems to work. However, I remember and have seen other implementation that make the buffer 1 more then the needed capacity so that a full buffer and an empty buffer can be differentiated. However this implementation does not...
1
1277
by: Reny | last post by:
Can any one tell me how do i write an interrpt driven program with .net?
11
4039
by: Kenneth Lantrip | last post by:
Anyone got any ideas as to how this process could be improved for speed? this is what I have... Dim j, q As Integer Dim x(16), y(16) As Byte x.CopyTo(y, 0) ' shift left circular 24 bits
3
1252
by: Reny J Joseph Thuthikattu | last post by:
Hi, I want to write a interrupt driven program with .NET .Can any one help? Reny
7
20003
by: toton | last post by:
Hi, I want a circular buffer or queue like container (queue with array implementation). Moreover I want random access over the elements. And addition at tail and remove from head need to be low cost. STL vector is suitable for removing form tail? or it is as costly as removing from middle? any other std container to serve this purpose?...
2
7756
by: marco.furlan | last post by:
Hi there, I have to write an optimized circular buffer to log events in C++. The elements are of type std::string. This should run under Linux on an ARM embedded system. I can dedicate to this circular log a preallocated block of fixed size and work in there. Can anybody indicate me an example or technique to do this ? Thanks Marco
5
8489
by: shofu_au | last post by:
Dear readers, Before poorly reinventing the wheel I thought I would ask if a class already exists. I need to use a circular byte buffer that is thread safe. I cannot use MSMQ, my regular choice, due to complicated reasons - don't go there.
0
7895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8327
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8193
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5374
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.