Every year the Universidade de Brasilia (UnB) hold a workshop for all of its researchers. The name of the event is WPOS (Workshop de POS-graduação). Even though the focus is on Masters and PhD researchers, every year we also receive some very interesting results from undergrads.
This year was the first year that it was held in Brasilia itself, usually it's sited on a nearby city like Pirinópolis. Being so close is very fruitful for the ease of transport but don't come with the same atmosphere of engagement that the prior issues held.
During this edition the UnBiquitous was represented by myself (Fabricio Buzeto) and Ana Ozaki. Ana presented her results regarding Ontologies for smartspaces (in special de uOS). My job was to present my idea of a Code Mobility extension to the DSOA. The ideas were well accepted and received some valuable feedback.
Highlighting the some interesting parts of the day i can present: The talk from Professor Rohit Gheyi about its SafeRefactor tool. The always amazing speedup results from Alba Melo students regarding GPU and Clustering techniques and Deborah Mendes study regarding the W-Entropy Index for Social Networks.
And lets hope for the next year.
Monday, November 14, 2011
Wednesday, November 9, 2011
uOS/EPOS Termometer
Since we've put our hands in some nice EPOS-Motes came the idea of building a simple application to test-drive the gizmo.
The idea is not much original, but illustrate how the uOS and the EPOS mote can talk with each other using the SerialPort (of course the best option would be to use the 802.15.4, but it'll come in the future). Taking advantage of the fact that the StarterKit comes with a temperature sensor, we've created a simple Temperature Driver and Application in the uOS as follows.
The UART Communication
The EPOS code is very simple, consisting of a simple request-response serial communication that waits for the 'T' character as request token.
class UosUartTemperatureDriver {
private:
OStream cout;
UART uart;
Temperature_Sensor sensor;
public:
void run(){
while(true){
char c = uart.get();
if (c == 'T'){
int sample = sensor.sample();
uart.put(sample);
}
}
}
};
The Synchronous Temperature Service
For the synchronous (query) temperature service the driver side stays as follows:
public void sense(ServiceCall req, ServiceResponse res,
UOSMessageContext uosMessageContext) {
Integer temperature;
synchronized (communicator) {
communicator.send('T');
temperature = communicator.receive();
}
res.addParameter("temperature", temperature.toString());
}
The application side is just a driver check and a call.
String driverName = "org.unbiquitous.driver.temperature";
List<RemoteDriverData> drivers = gateway.listDrivers(driverName);
if (drivers != null && !drivers.isEmpty()) {
RemoteDriverData data = drivers.get(0);
ServiceCall call = new ServiceCall(driverName, "sense");
ServiceResponse response = gateway.callService(data.getDevice(), call);
System.out.println("Now is "+response.getResponseData("temperature")+"°C")
The Asynchronous Temperature Service
Asynchronous (publish-subscribe) happens in three steps. First the application need to register (subscribe) for the desired event (temperature change).
String driverName = "org.unbiquitous.driver.temperature";
List<RemoteDriverData> drivers = gateway.listDrivers(driverName);
if (drivers != null && !drivers.isEmpty()) {
RemoteDriverData data = drivers.get(0);
gateway.registerForEvent(this, data.getDevice(), driverName, data.getInstanceID(), "temperature_change");
}else{
System.out.println("No driver available.");
}
Then the driver must be able to respond for such changes. This is done in a temperature listener thread.
Thread sensor = new Thread(){
public void run() {
while (running) {
Integer temp;
synchronized (communicator) {
communicator.send('T');
temp = communicator.receive();
}
if (temp != lastTemp) {
lastTemp = temp;
Notify temperatureChange = new Notify("temperature_change", driver.getName(),TemperatureDriver.this.instanceId);
temperatureChange.addParameter("temperature", lastTemp.toString());
notifyListeners(temperatureChange);
}
}
}
private void notifyListeners(Notify temperatureChange) {
if (listeners != null){
for (NetworkDevice nd : listeners) {
UpDevice device = new UpDevice("DummyDevice");
device.addNetworkInterface(nd.getNetworkDeviceName(),nd.getNetworkDeviceType());
try {
TemperatureDriver.this.gateway.sendEventNotify(temperatureChange, device);
} catch (NotifyException e) {logger.error("Not posible to send event", e);}
}
}
};
};
Then the application is notified every time a temperature change happens.
public void handleEvent(Notify event) {
if (event.getEventKey().equals("temperature_change")){
System.out.println("Temperature changed to "+event.getParameter("temperature")+"°C");
}
The full code of both the application and the driver can be found at our github account.
The idea is not much original, but illustrate how the uOS and the EPOS mote can talk with each other using the SerialPort (of course the best option would be to use the 802.15.4, but it'll come in the future). Taking advantage of the fact that the StarterKit comes with a temperature sensor, we've created a simple Temperature Driver and Application in the uOS as follows.
The UART Communication
The EPOS code is very simple, consisting of a simple request-response serial communication that waits for the 'T' character as request token.
class UosUartTemperatureDriver {
private:
OStream cout;
UART uart;
Temperature_Sensor sensor;
public:
void run(){
while(true){
char c = uart.get();
if (c == 'T'){
int sample = sensor.sample();
uart.put(sample);
}
}
}
};
The Synchronous Temperature Service
For the synchronous (query) temperature service the driver side stays as follows:
public void sense(ServiceCall req, ServiceResponse res,
UOSMessageContext uosMessageContext) {
Integer temperature;
synchronized (communicator) {
communicator.send('T');
temperature = communicator.receive();
}
res.addParameter("temperature", temperature.toString());
}
The application side is just a driver check and a call.
String driverName = "org.unbiquitous.driver.temperature";
List<RemoteDriverData> drivers = gateway.listDrivers(driverName);
if (drivers != null && !drivers.isEmpty()) {
RemoteDriverData data = drivers.get(0);
ServiceCall call = new ServiceCall(driverName, "sense");
ServiceResponse response = gateway.callService(data.getDevice(), call);
System.out.println("Now is "+response.getResponseData("temperature")+"°C")
The Asynchronous Temperature Service
Asynchronous (publish-subscribe) happens in three steps. First the application need to register (subscribe) for the desired event (temperature change).
String driverName = "org.unbiquitous.driver.temperature";
List<RemoteDriverData> drivers = gateway.listDrivers(driverName);
if (drivers != null && !drivers.isEmpty()) {
RemoteDriverData data = drivers.get(0);
gateway.registerForEvent(this, data.getDevice(), driverName, data.getInstanceID(), "temperature_change");
}else{
System.out.println("No driver available.");
}
Then the driver must be able to respond for such changes. This is done in a temperature listener thread.
Thread sensor = new Thread(){
public void run() {
while (running) {
Integer temp;
synchronized (communicator) {
communicator.send('T');
temp = communicator.receive();
}
if (temp != lastTemp) {
lastTemp = temp;
Notify temperatureChange = new Notify("temperature_change", driver.getName(),TemperatureDriver.this.instanceId);
temperatureChange.addParameter("temperature", lastTemp.toString());
notifyListeners(temperatureChange);
}
}
}
private void notifyListeners(Notify temperatureChange) {
if (listeners != null){
for (NetworkDevice nd : listeners) {
UpDevice device = new UpDevice("DummyDevice");
device.addNetworkInterface(nd.getNetworkDeviceName(),nd.getNetworkDeviceType());
try {
TemperatureDriver.this.gateway.sendEventNotify(temperatureChange, device);
} catch (NotifyException e) {logger.error("Not posible to send event", e);}
}
}
};
};
Then the application is notified every time a temperature change happens.
public void handleEvent(Notify event) {
if (event.getEventKey().equals("temperature_change")){
System.out.println("Temperature changed to "+event.getParameter("temperature")+"°C");
}
The full code of both the application and the driver can be found at our github account.
Monday, November 7, 2011
EPOS Mote
During the last months we've received some nice gifts by our friends from the south. Professor Fröhlich from the Lisha (Software and Hardware Integrated Lab, Laboratório Integrado de Software e HArdware in portuguese) laboratory at UFSC sent us three Epos-Motes version 2.
The EPOS (Embedded Parallel Operating System) is an Object-Oriented OS focused on the development of sensors and other specialist software/hardware applications. It follows a ADESD (Application-Driven Embedded System Design) approach, which focus on a better way to build such applications. The OS can be used in a wide variety of platforms and processors.
The documentation present on the EPOS Wiki has many information about how to develop using EPOS, what you don't find there you can ask in the discussion list, which is very active in helping new users.
The EPOS-Mote version 2 we've received are equiped with a ARM-7 processor with 96 MB RAM and 128 MB Flash. It has a 802.15.4 RF TX/RX and a YYYY. The Start Kit comes with a USB/UART for embedding applications (and serial communication) along with a Thermometer, Accelerometer, LEDs and a Button.
Installing the EPOS environment is just as described in the documentation.
Before everything you'll have to register to the EPOS website and agree with their license.
For installing the development environment at a Linux SO follwo these steps:
1: Install the arm cross compiler:
Download it from the the site onto the /usr/local/arm/gcc folder.
2: Install g++:
Download the latest version of the OpenEPOS source code and Unzip it on a folder of your choice.
Set the EPOS variable to the OpenEPOS folder.
Configuration:
The EPOS environment comes already set to the EPOS-Mote-2 but any changes on the architecture used can be modified at the makedefs file and choosing the option that best suits you.
HelloWorld:
For testing the environment compile the following code.
Save it to a helloworld.cc file in the app folder.
The run make APPLICATION=helloworld.
To embed the application in the mote you must convert the image file to an arm binary and then transpit it to the mote using the USB/UART cable using the followinf commands.
That's it for now. More news about our use of the EPOS-Mote in a near future.
The EPOS (Embedded Parallel Operating System) is an Object-Oriented OS focused on the development of sensors and other specialist software/hardware applications. It follows a ADESD (Application-Driven Embedded System Design) approach, which focus on a better way to build such applications. The OS can be used in a wide variety of platforms and processors.
The documentation present on the EPOS Wiki has many information about how to develop using EPOS, what you don't find there you can ask in the discussion list, which is very active in helping new users.
The EPOS-Mote version 2 we've received are equiped with a ARM-7 processor with 96 MB RAM and 128 MB Flash. It has a 802.15.4 RF TX/RX and a YYYY. The Start Kit comes with a USB/UART for embedding applications (and serial communication) along with a Thermometer, Accelerometer, LEDs and a Button.
Installing the EPOS environment is just as described in the documentation.
Before everything you'll have to register to the EPOS website and agree with their license.
For installing the development environment at a Linux SO follwo these steps:
1: Install the arm cross compiler:
Download it from the the site onto the /usr/local/arm/gcc folder.
sudo mkdir /usr/local/arm
cd /usr/local/arm/
sudo wget http://www.lisha.ufsc.br/~arliones/arm-gcc-4.4.4.tgz
sudo tar xzfv arm-gcc-4.4.4.tgz
sudo ln -s /usr/local/arm/gcc gcc-4.4.4 gcc
sudo rm arm-gcc-4.4.4.tgz
2: Install g++:
sudo apt-get install g++3: Install EPOS Environment:
Download the latest version of the OpenEPOS source code and Unzip it on a folder of your choice.
sudo mkdir /opt/EPOS
sudo chown <user> /opt/EPOS/
mv ~/Donwload/OpenEPOS-1.1RC.tgz /opt/EPOS/
cd /opt/EPOS
tar xzfv OpenEPOS-1.1RC.tgz
rm OpenEPOS-1.1RC.tgz
Set the EPOS variable to the OpenEPOS folder.
export EPOS=/opt/EPOS/OpenEPOS-1.1RC/Add EPOS tools and arm-gcc to the PATH
export PATH=$PATH:$EPOS/bin
export PATH=$PATH:/usr/local/arm/gcc/binFor testing your environment run a make veryclean all.
Configuration:
The EPOS environment comes already set to the EPOS-Mote-2 but any changes on the architecture used can be modified at the makedefs file and choosing the option that best suits you.
HelloWorld:
For testing the environment compile the following code.
#include <utility/ostream.h>
__USING_SYS
int main() {
OStream cout;
while (true)
cout << "Hi EPOS\n";
return 0;
}
Save it to a helloworld.cc file in the app folder.
The run make APPLICATION=helloworld.
To embed the application in the mote you must convert the image file to an arm binary and then transpit it to the mote using the USB/UART cable using the followinf commands.
arm-objcopy -I elf32-little -O binary img/helloworld.img img/helloworld.bin
python bin/red-bsl.py -t /dev/ttyUSB0 -f img/helloworld.binTo check your application running you can use a serial application like cutecom (or minicom). Set it to 9600 baud-rate and see your output on the screen.
That's it for now. More news about our use of the EPOS-Mote in a near future.
Labels:
epos
Subscribe to:
Posts (Atom)