1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

I need to write a command protocol divided in 3 layers

Discussion in 'Embedded' started by billy, Apr 30, 2009.

  1. billy

    billy Guest

    Hello

    I need to write a command protocol divided in 3 layers. A data link layer, a
    network layer and an upper layer.

    I'm programming this in C.

    I would like some internet links that shows some examples of how to signal
    between the different layers.

    I'm planning to have different state machines in the different layers. The
    state machines are called by an interrupt timer every 1ms.

    They are going to send signals (reguests, indications and confirmation).

    What is the best way to write the signaling?
    billy, Apr 30, 2009
    #1
    1. Advertising

  2. billy

    Chris H Guest

    In message <49f9fc17$0$90265$>, billy
    <> writes
    >Hello
    >
    >I need to write a command protocol divided in 3 layers. A data link
    >layer, a network layer and an upper layer.
    >
    >I'm programming this in C.
    >
    >I would like some internet links that shows some examples of how to
    >signal between the different layers.
    >
    >I'm planning to have different state machines in the different layers.
    >The state machines are called by an interrupt timer every 1ms.
    >
    >They are going to send signals (reguests, indications and confirmation).
    >
    >What is the best way to write the signaling?
    >


    Is it September already ?

    --
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Chris H, Apr 30, 2009
    #2
    1. Advertising

  3. billy

    billy Guest

    > Is it September already ?

    No, silly man. Did you think so? :p
    billy, May 1, 2009
    #3
  4. billy

    Chris H Guest

    In message <>, Grant Edwards
    <> writes
    >On 2009-04-30, Chris H <> wrote:
    >> In message <49f9fc17$0$90265$>, billy
    >>
    >>>I need to write a command protocol divided in 3 layers. A data
    >>>link layer, a network layer and an upper layer.
    >>>
    >>>[...]
    >>>
    >>>They are going to send signals (reguests, indications and
    >>>confirmation).
    >>>
    >>>What is the best way to write the signaling?

    >>
    >> Is it September already ?

    >
    >It's always September somewhere...


    I though it was always mid-day somewhere.....

    --
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    Chris H, May 1, 2009
    #4
  5. billy wrote:
    > Hello
    >
    > I need to write a command protocol divided in 3 layers. A data link
    > layer, a network layer and an upper layer.
    >
    > I'm programming this in C.
    >
    > I would like some internet links that shows some examples of how to
    > signal between the different layers.
    >
    > I'm planning to have different state machines in the different layers.
    > The state machines are called by an interrupt timer every 1ms.
    >
    > They are going to send signals (reguests, indications and confirmation).
    >
    > What is the best way to write the signaling?
    >

    Callbacks using function pointers and object handles.
    Edwin van den Oetelaar, May 1, 2009
    #5
  6. billy

    billy Guest

    billy, May 1, 2009
    #6
  7. billy

    CBFalconer Guest

    billy wrote:
    >
    >> Is it September already ?

    >
    > No, silly man. Did you think so? :p


    He seems to be correct in his speculation.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.
    CBFalconer, May 2, 2009
    #7
  8. billy

    Frank Buss Guest

    billy wrote:

    > I found something about protothreads that can be used to simplify the state
    > machines.
    >
    > http://www.sics.se/~adam/pt/expansion-print.html
    >
    > This is maby something I can use. :)


    Is this a homework? As the article wrote, this is weird code, don't use it.
    The simplest solution for a statemachine would be to use an enum with
    meaningful names and just a big switch-case.

    I assume Edwin means something like the state pattern, as you can implement
    it easily in object oriented languages like C++, Java or Lisp:

    http://en.wikipedia.org/wiki/State_pattern

    In C you'll need function pointers and object handles.

    --
    Frank Buss,
    http://www.frank-buss.de, http://www.it4-systems.de
    Frank Buss, May 2, 2009
    #8
  9. billy

    billy Guest

    > Is this a homework? As the article wrote, this is weird code, don't use
    > it.


    No
    billy, May 2, 2009
    #9
  10. billy

    Nobody Guest

    On Sat, 02 May 2009 07:52:58 -0500, Grant Edwards wrote:

    >> As the article wrote, this is weird code, don't use it.

    >
    > Why not?


    It produces illegible code. Actually, it's worse than that, as it's likely
    to trick you into thinking that you know what the code is doing.

    C macros are an abomination at the best of times, but macros which expand
    to partial control structures are much, much worse.

    > I've used protothreads in products, and it works very
    > nicely. You end up with code that's a lot more readable and
    > more easily maintained than complex, explicit state machines.


    Most things are more readable than an explicit state machine. But the
    protothreads code has to be one of the few cases which aren't; what the
    code appears to be doing and what it's actually doing are very different
    things. At least with an explicit state machine you'll probably know that
    you don't understand it, rather than deceiving yourself into thinking that
    you do.
    Nobody, May 2, 2009
    #10
  11. billy

    Thad Smith Guest

    billy wrote:

    > I need to write a command protocol divided in 3 layers. A data link
    > layer, a network layer and an upper layer.
    >
    > I'm programming this in C.
    >
    > I would like some internet links that shows some examples of how to
    > signal between the different layers.
    >
    > I'm planning to have different state machines in the different layers.
    > The state machines are called by an interrupt timer every 1ms.
    >
    > They are going to send signals (reguests, indications and confirmation).
    >
    > What is the best way to write the signaling?


    I don't know what you have already done, but I recommend that you ensure
    that you have a good set of (initial) requirements and do an analysis to
    determine a good solution structure before making low-level
    implementation choices.

    Is the command protocol function specified, including initialization,
    timing, and error recovery? Why implement in three layers, rather than
    one or five?

    Can you adapt an existing protocol stack?

    --
    Thad
    Thad Smith, May 5, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. funkymunky

    why is freq Internally divided in uPs?

    funkymunky, Dec 28, 2004, in forum: Embedded
    Replies:
    9
    Views:
    254
    Everett M. Greene
    Dec 30, 2004
  2. H

    BGA on 4-layers?

    H, Oct 8, 2005, in forum: Embedded
    Replies:
    12
    Views:
    667
    linnix
    Oct 12, 2005
  3. ElderUberGeek
    Replies:
    6
    Views:
    456
    Paul Carpenter
    Feb 14, 2006
  4. Howard Kaikow

    Divided we stand, united we fall!

    Howard Kaikow, Nov 4, 2004, in forum: Laptops
    Replies:
    5
    Views:
    266
    ikenfixit
    Nov 8, 2004
  5. kunil

    V Cut for multiple layers PCB

    kunil, Mar 11, 2007, in forum: Embedded
    Replies:
    7
    Views:
    355
    Spehro Pefhany
    Mar 11, 2007
Loading...

Share This Page