Thread: [Embedlets-dev] Re: JAPL versus Embedlet integration....
Status: Alpha
Brought to you by:
tkosan
|
From: Andrzej J. T. <an...@ch...> - 2003-03-30 15:55:28
|
> The JAPL devices are abstract peripherals, not device drivers. Whatever....I'm using the term interchangeably in my posts. I see the abstract peripheral API's as being just a generic version of a specific device driver. > Lets set aside > Robocode for the moment and discuss a JAPL UART because I think it is more > typical of what most JAPL devices will look like. A normal UART device driver > can a) configure the UART by placing data into its internal registers, b) > query the state of the UART by looking at its internal registers and c) the > UART can asynchronously notify its device driver that it needs to be serviced > by asserting the interrupt line. The JAPL API for a UART should provide get/set methods for the internal registers, but suitably "abstracted" so that you don't see the metal (actual registers) from the other side of the API. In other words, the JAPL API should be functional in appearance, not tied to the specific hardware implementation of the functions. For example: japl.setFlowControl( true ); japl.setParity( false ); are much better than more "hardware oriented" stuff like: int flags = 0x01 | 0x04 // eg. Flags for flow control and Parity device.setFlags( flags ); As for the asynchronous notifications (interrupts basically), see my last post about using a JAPL Wrapper class as a mediation layer that converts such an async callback into an Embedlet Event. There is MASSIVE benefit to using such an approach....the principal one being keeping the JAPL and Embedlet layers nicely decoupled and flexible (so that JAPL can be used outside of an Embedlet Container). > The Architecture document gives an Embedlet 2/3 of the capabilities it needs > to serve as a JAPL UART device driver because it allows the Embedlet to have a > direct reference to the JAPL UART and so enables it to do 'a' and 'b' above. That is true. And assembler code could do the same, but that does not mean you should use that technique even though you could. And Embedlets were always intended to be where you put your "application logic", not driver logic. Driver stuff should be performed (and hidden/encapsulated, eg. how do you talk to a device at a low level) in the JAPL layer. Application stuff should be in an Embedlet (eg. what you do when something happens...a temp sensor flips, process bytes that have been read by a UART). Architecturally, the better way is to integrate Embedlets and JAPL peripherals is to use a JAPL wrapper to "bridge" the gap per my other email. > As for the UART interrupt, in all the conventional low level device drivers I > have written, the interrupt is always channeled directly into the device > driver that is also responsible for doing 'a' and 'b' for any given device and > it is always a one-to-one bidirectional binding. No other piece of code > besides the peripheral's device driver should be interested in the interrupt. We're in violent agreement here, Ted! Kewl! The JAPL Wrapper approach I have outlined resolves this, since the Wrapper class is more a part of the JAPL layer than the Embedlet layer, even though it does bridge those two worlds. So the combo of the JAPL driver/peripheral code and the Wrapper perform all of a/b/c in your example. The Embedlet doesn't do any of these operations. The Embedlet reacts in an application-specific way to an Embedlet Event that the wrapper may or may not send as a result of an interrupt. (note: an interrupt may not always generate an Embedlet Event....if a switch state didn't change, or you are buffering I/O in the JAPL layer, then events are not always sent when an interrupt arrives). > But you are saying that Embedlets should not be used as device drivers either > (see below). EXACTLY what I am saying. JAPL should implement the device driver level and Embedlets should know NOTHING about that. Use a JAPL Wrapper class to translate hardware driver level events of interest into an Embedlet Event that will be propagated throughout the Outpost container. One of the benefits of this approach is that you can easily and transparently add additional Embedlets that are interested in a particular Embedlet Event originated by a JAPL device. You can add a logging Embedlet that streams out JAPL status info across an HTTP connection to the outside world without having to touch one line of your JAPL code or your other application-specific Embedlets, if you use this architectural model. > Again, a JAPL peripheral is just a peripheral, not a device driver. From some perspective, I see the JAPL peripheral as doing a lot of low level device driver types of things and exposing a higher level API (see example of what I mean by this above). So in that sense, JAPL is a device driver to a great degree. > Besides this, the JAPL peripheral can't convert its interrupts into > Embedlet events > or any other specific system's events because the JAPL is > a generalized, > system neutral technology. I should have explained myself more fully in my first response (but was hoping that everyone would figure it out). Use a JAPL Wrapper class to bridge the two worlds and all is wonderful! ;-) > If an Embedlet is being used as a device driver for a JAPL device then I would > say that device drivers commonly have bidirectional references to the devices > they are controlling. My current thinking is that routing a peripheral's > interrupt only to the device driver that is directly responsible for it > maintains complete encapsulation but allowing this interrupt to be arbitrarily > routed to other pieces of software in the system breaks it. But an Embedlet should NOT be used as a device driver....it is intended to be used for application specific code. Not low level hardware interfacing stuff. Design patterns to the rescue....use a JAPL Wrapper class. > What I hear you saying, though, is that Embedlets should not be used as JAPL > device drivers and I can certainly go along with this philosophy if Embedlets > are blocked from having direct references to JAPL peripherals. Grasshoppa....you are missing the point. Embedlets can and have to have references to JAPL peripherals. They need to do get/set properties on JAPL devices (using a higher level device API that JAPL exposes). It's the reverse that is verbotten....the JAPL device is NOT allowed to have a reference to an Embedlet. The Wrapper approach resolves this impedence mismatch. > If an Embedlet > is being constrained as only operating as a high level piece of code then how > can it be ok to give it a direct reference to a low level peripheral like a > UART? For the same reason that a higher level routine can reference lower level subroutines/methods to do it's work. However, the reverse is considered a very bad practices. Higher level components can employ lower level components to do their work. The reverse is not a good idea. Keep in mind that the data coming in on the UART is typically application specific, (medical data? shop floor sensors? engine sensors?) and so at some level has to be processed by app-level code....meaning an Embedlet. Maybe I am misinterpreting what JAPL does. If all it provides is a thin generalization layer for specific classes of peripherals, then we may need a Device Driver level of code layered on top of that. But I see that as still in the JAPL domain, and not part of the Embedlet container, and you still need a wrapper approach to bridge the two worlds. If such a Device Driver is needed on top of JAPL, it should also be independent of the Embedlet Container so that it can be used in non-embedlet based code. > Assuming that a JAPL peripheral can not be its own device driver Why not? In fact, there are a lot of good reasons for the JAPL peripheral to act as it's own device driver. Maybe we are just using different definitions of what a device driver is/does? > Embedlets are not permitted to be device drivers, then we still need some kind > of a device driver that is part of the Embedlet framework that can do the > following: I believe such a driver should be part of the JAPL layer and not the Embedlet layer. > 1) Hold direct references to JAPL peripherals. > 2) Accept interrupt events from these peripherals. > 4) Convert the peripheral's interrupt events into Embedlet events. The combination of the JAPL peripheral (and any "device driver code) and the proposed JAPL wrapper approach nicely handle all of the above situations. But an Embedlet can hold a reference to a JAPL peripheral (so as to issue API method calls on it to get it's work done. eg. japl.setSwitch( true ) ). Keep in mind that what Embedlet Event(s) an interrupt is mapped to is application specific, so it does not belong in the JAPL peripheral/driver code. > 3) Convert Embedlet events into method calls on the peripheral. That is not required since it presumes that low level devices understand Embedlet Events which they have no need to. There is nothing wrong with an Embedlet doing method calls on a peripheral as requried. I think some of the problem is that we had a stated design goal of keeping JAPL independent of Embedlets. If we drop that requirement, then sure, we can create a new Embedlet-level component (eg. DeviceDriver) that understands Embedlet Events (both as producer and consumer), but then that code would not be useable outside of the container. > The current Adapter might be suitable for this purpose and if not the Adapter > then perhaps an Embedlet Container DeviceDriver? Adapters are specifically intended to be used for integration of external systems/communications, not attached devices. > Anyway, I am going to hold off doing more work in this area until we get > this JAPL issue resolved. Actually I have been hitting JGraph fairly hard > during the past week in preparation for beginning work on the Wiring Tool > and so I have plenty to keep me busy. ;-) Have my explanations of the use of a JAPL Wrapper class helped resolve this? Glad to hear that you are pushing down the Wiring road. Kewlness! Andrzej Jan Taramina Chaeron Corporation: Enterprise System Solutions http://www.chaeron.com |
|
From: Brill P. <bri...@ro...> - 2003-03-31 05:16:16
|
> > The JAPL devices are abstract peripherals, not device drivers. > > Whatever....I'm using the term interchangeably in my posts. I see the > abstract peripheral API's as being just a generic version of a specific > device driver. The distinction is pretty blurry ;) I tend to think of the peripherals as contracts to drivers if I have to separate them contextually, so a peripheral could look the same, but be implemented in several different way in the "driver" code. - Brill Pappin |
|
From: Ted K. <tk...@ya...> - 2003-03-31 06:50:07
|
Andrzej,
>Have my explanations of the use of a JAPL Wrapper class helped resolve this?
Well, we are getting there but I still have some more questions so I hope you
will bear with me! ;-)
>Maybe I am misinterpreting what JAPL does. If all it provides is a
>thin generalization layer for specific classes of peripherals,
>then we may need a Device Driver level of code layered on top of that.
The understanding of JAPL peripherals that I have been working under is that
they are generic, standardized interfaces for any kind of peripheral I/O
circuits from simple I/O ports through medium complexity devices like UARTs and
up to highly sophisticated I/O systems like a RobotScanner.
My working definition of what a device driver means in the context of
Embedlets is that it is the piece of software that is responsible for doing the
impedance matching between the I/O level semantics of the JAPL peripheral and
the application level semantics of the Embedlet based application.
For example, if a cannon were attached to bit 3 of a JAPL I/O port, then an
event like fire forward cannon from the FireControl Embedlet would eventually
get translated into something like JaplPort.setBit(3, true);
>As for the asynchronous notifications (interrupts basically), see my
>last post about using a JAPL Wrapper class as a mediation layer that
>converts such an async callback into an Embedlet Event. There is
>MASSIVE benefit to using such an approach....the principal one being
>keeping the JAPL and Embedlet layers nicely decoupled and flexible
>(so that JAPL can be used outside of an Embedlet Container).
Well, I am trying to understand how the Embedlet implementing a JAPL interface
and registering itself as a listener for Events coming from a JAPL peripheral
(that it already has a reference to) using this interface makes the JAPL
peripheral at all dependent on the Embedlet code base? My approach was to have
the JAPL library contain an interface like the following:
package org.japl;
public interface JaplEventListener
{
void receiveJaplEvent(Object japlEvent);
}//end method
and then the Embedlet would implement this interface and then register itself
as a JaplEventListener just like any other JAPL client would. If the Embedlet
already has a dependency on the JAPL peripheral, what is the harm of allowing
it to have a further dependency on a JAPL interface (again, there are no
Embedlet dependencies in the JAPL code)?
My thought was that for any given JAPL peripheral, one Embedlet in the
application would be used to wrap around it and then all the code needed to
perform the semantic impedance matching with this JAPL peripheral would be
isolated inside of this single Embedlet (including messaging code and JAPL
event handling code).
>> 1) Hold direct references to JAPL peripherals.
>> 2) Accept interrupt events from these peripherals.
>> 4) Convert the peripheral's interrupt events into Embedlet events.
>The combination of the JAPL peripheral (and any "device driver code)
>and the proposed JAPL wrapper approach nicely handle all of the
>above situations. But an Embedlet can hold a reference to a JAPL
>peripheral (so as to issue API method calls on it to get it's work
>done. eg. japl.setSwitch( true ) ).
I am still trying to understand what the benefit is of allowing an Embedlet to
send sub-application-semantic-level messages directly to a JAPL peripheral but
to have sub-application-semantic-level asynchronous events coming from the JAPL
peripheral to be broadcast to an arbitrary number of Embedlets via the
Embedlets event mechanism?
I think you are going to say that the JAPL wrapper will convert between the I/O
level semantics of the JAPL peripheral and the application-level semantics of
the application but I still can't see why all of this impedance matching is not
happening in one place (either all in one Embedlet or all in the JAPL wrapper)?
From my perspective, this is the kind of situation that is confusing me:
- A SerialTerminalEmbedlet instantiates a JaplUart peripheral and initializes
it to 9600,8,N,1 in its initialize() method using I/O level semantics.
- All application-semantic-level data that is sent to the terminal's screen by
other Embedlets in the application is sent via Embedlet events to the
SerialTerminalEmbedlet because it is the only piece of software in the
application that has a reference to the JaplUart and so can send messages to
it.
- As asynchronous I/O level semantic data comes in from the JaplUart, it is
routed through the JAPL wrapper and then published to the Embedlet event
system. As posted in earlier emails, only application level semantics should
be sent through the Embedlet event system so the JAPL wrapper would need to
convert the I/O event semantics into application level semantics before
publishing to the application.
So, why does all of the outgoing Embedlet/JAPL impedance matching happen in an
Embedlet and all of the incoming JAPL/Embedlet impedance matching happen in a
completely separate and unrelated piece of software (the JAPL wrapper)? Why
not let one Embedlet handle impedance matching in both directions since having
an Embedlet implement something like the JaplEventListener interface completely
prevents JAPL peripherals from having dependencies on Embedlets?
Again, my main goal here is to completely understand the reasoning behind the
decisions being made in this part of the architecture so please bear with me
because I am having a tough time with it! ;-)
Ted
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
|
|
From: Brill P. <bri...@ro...> - 2003-03-31 13:21:46
|
> >Maybe I am misinterpreting what JAPL does. If all it provides is a > >thin generalization layer for specific classes of peripherals, > >then we may need a Device Driver level of code layered on top of that. > > The understanding of JAPL peripherals that I have been working under is that > they are generic, standardized interfaces for any kind of peripheral I/O > circuits from simple I/O ports through medium complexity devices like UARTs and > up to highly sophisticated I/O systems like a RobotScanner. See my message (March 29, 2003 1:36 AM) with the subject "Re: [Embedlets-dev] Re: JAPL part of specification". I have attached the current API docs for JAPL (not including the docs for the platform-tini, which is separate). the layout your interested in is: org.japl.peripheral <= contains the generic interfaces org.japl.peripheral.<name> <= contains concrete implementations of some devices (mostly I2C). The device drivers are platform independant, and will run on any platform implementation (e.g. the platform-tini impl). > My working definition of what a device driver means in the context of > Embedlets is that it is the piece of software that is responsible for doing the > impedance matching between the I/O level semantics of the JAPL peripheral and > the application level semantics of the Embedlet based application. > > For example, if a cannon were attached to bit 3 of a JAPL I/O port, then an > event like "fire forward cannon" from the FireControl Embedlet would eventually > get translated into something like JaplPort.setBit(3, true); Thats what I'm asking about ;) I think we're all on the same wavelength, jhust struggeling to understand the different APIs. - Brill Pappin |