Motherboard Forums


Reply
Thread Tools Display Modes

I need to write a command protocol divided in 3 layers

 
 
billy
Guest
Posts: n/a
 
      04-30-2009, 07:29 PM
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?

 
Reply With Quote
 
 
 
 
Chris H
Guest
Posts: n/a
 
      04-30-2009, 09:42 PM
In message <49f9fc17$0$90265$(E-Mail Removed)>, billy
<(E-Mail Removed)> 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 /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



 
Reply With Quote
 
 
 
 
billy
Guest
Posts: n/a
 
      05-01-2009, 06:34 AM
> Is it September already ?

No, silly man. Did you think so? :-P

 
Reply With Quote
 
Chris H
Guest
Posts: n/a
 
      05-01-2009, 08:09 AM
In message <(E-Mail Removed)>, Grant Edwards
<(E-Mail Removed)> writes
>On 2009-04-30, Chris H <(E-Mail Removed)> wrote:
>> In message <49f9fc17$0$90265$(E-Mail Removed)>, 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 /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



 
Reply With Quote
 
Edwin van den Oetelaar
Guest
Posts: n/a
 
      05-01-2009, 02:21 PM
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.
 
Reply With Quote
 
billy
Guest
Posts: n/a
 
      05-01-2009, 02:25 PM
> Callbacks using function pointers and object handles.

Thank you.

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. :-)


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      05-01-2009, 11:18 PM
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.


 
Reply With Quote
 
Frank Buss
Guest
Posts: n/a
 
      05-02-2009, 06:19 AM
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, (E-Mail Removed)
http://www.frank-buss.de, http://www.it4-systems.de
 
Reply With Quote
 
billy
Guest
Posts: n/a
 
      05-02-2009, 04:20 PM
> Is this a homework? As the article wrote, this is weird code, don't use
> it.


No

 
Reply With Quote
 
Nobody
Guest
Posts: n/a
 
      05-02-2009, 05:56 PM
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
V Cut for multiple layers PCB kunil Embedded 7 03-11-2007 02:25 PM
Bit-level protocol or text-based protocol? (PC to embedded) ElderUberGeek Embedded 6 02-14-2006 10:16 AM
BGA on 4-layers? H Embedded 12 10-12-2005 05:55 PM
why is freq Internally divided in uPs? funkymunky Embedded 9 12-30-2004 06:53 PM
Divided we stand, united we fall! Howard Kaikow Laptops 5 11-08-2004 12:07 PM


All times are GMT. The time now is 03:14 AM.


Welcome!
Welcome to Motherboard Point
 

Advertisment