Skip to main content

writing new Drivers for SqVM

4 replies [Last post]
mazx
Offline
Joined: 2008-03-25
Points: 0

Hi,

I finally managed to build Squawk on windows and ran the tests successfully. What a relief :)

Now, I'm trying to figure out how to write drivers for Squawk. Can you point me to an example or existing driver source because my initial search through the source tree returned only Driver interface, DriverLoader and JavaDriverManager.

Also is there a config file that needs to be modified so SqVM will load appropriate drivers?

Thank you in advance.

Andre

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mazx
Offline
Joined: 2008-03-25
Points: 0

WOW! :)

Thanks for the info. This should get me started.

I'll be posting back comment/questions as I will be coming across the staff.

Thanks again.

Andre

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

There are a couple of options for providing drivers. The preferred way is to write it in Java using NativeUnsafe to bit bash registers. The other way is through the channel interface using ChannelConstants.

There are a number of examples in the Sun SPOT source tree. Check out the https://spots-sensorboard-library.dev.java.net/svn/spots-sensorboard-lib... tree using SVN and look at code in transducerlib/src/com/sun/spot/sensorboard/peripheral for different examples.

We should really write a how-to on this, just keep posting questions and we will answer as best we can.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Oops, forgot to answer how you add the new drivers. This will be done in two parts. The first here, and the second in a separate post I will make after this.

The command
d rom cldc imp
Takes care to create a bootstrap suite as well as the squawk executable. The cldc imp part of the command defines which classes will be included in the bootstrap. So to add your own code to the bootstrap, you can simply do a
d rom cldc imp mymodule myapp

The rom command looks inside the mymodule directory and looks for a j2meclasses and resources directory and includes the content into the bootstrap. I will make a post on how to create your own module right after this.

Squawk supports suite chaining, but this requires a couple more commands that I can post later. So you could build a bootstrap suite that contains your library based code, and a separate suite that contains your application. The advantage of this approach is that the VM would not have to be rebuild when you modify your application. However, keep in mind that if you change the bootstrap, you need to re-create the VM AND the suites dependent on that bootstrap, which would be the application suite in this example.

You can also specify a .jar file that contains the pre-verified classes you wish to include.

derek_white
Offline
Joined: 2006-09-08
Points: 0

BTW, Driver interface, DriverLoader and JavaDriverManager are red herrings.

They were sketch of one approach that isn't currently used. (see KERNEL_SQUAWK build property for the rest of the unused code, if you're interested.)