ECRobot C/C++ API for nxtOSEK

 

 

nxtOSEK provides C/C++ API which is called ECRobot. ECRobot C API is originally designed to develop a MATLAB&Simulink based Model-Based Design environment (called Embedded Coder Robot) for LEGO MINDSTORMS NXT, so the C API was not well designed for hand coding C programmers. However, the new C++ API is designed for C++ programmers, so API structure and naming are more comprehensive and easy of use.

 

ECRobot C API Reference


ECRobot C++ API Reference

ECRobot C++ API provides the following features:

- Object oriented device classes for NXT Sensors (includes RCX Light Sensor, HiTechnic Sensors...), Motor, NXT (buttons and battery), LCD, Clock, Speaker, USB and Bluetooth.

Note that some (but not all) device class objects have to be constructed as global object because constructors/destructors need to initialize/(especially,) shut down the device hardware. The constructor/destructor of global objects are automatically invoked when a nxtOSEK application begins/ends.

Note that since v2.09, when a device class object which must be constructed as global is constructed as a non global object, an assertion will be displayed in the LCD and stops the system automatically. This mechanism can ensure the usages of the device classes being more expected.

- Utility classes for R/C and DAQ which work with NXT GamePad, and VectorT template.

- I2C device base class which can be used to develop a derived/compositted class for third party I2C device.

- Designed for real-time embedded applications (C++ RTTI can not be used. Exception can not be used. new/delete overloaded...)

- More than 10 samples include NXTway-GS++, SmartPointer and more (see samples_c++\cpp)

- .cpp file extension is used instead of .cc

- New build makefile ecrobot++.mak for .c/.cpp files is used instead of ecrobot.mak for .c/.cc files.

- ecrobot namespace distinguishes the API from other C++ library.
Note that ECRobot C++ API and the existing .cc API can't be used together in a C++ source file.

- Comprehensive HTML API reference doc generated by doxygen (it also bundled with the nxtOSEK packege. See ecrobot\c++\html\index.html)

- Support for only TOPPERS/ATK(OSEK). (ecrobot/c/rtoscalls.c needs to be modified to support for TOPPERS/JSP)


As a C++ code example, here is the HelloWorld using ECRobot C++ API:

/* sample.cpp for TOPPERS/ATK(OSEK) */

// ECRobot++ API

#include
"Lcd.h"
using namespace
ecrobot;

extern "C"
{
#include "kernel.h"
#include "kernel_id.h"
#include "ecrobot_interface.h"

// nxtOSEK hook to be invoked from an ISR in category 2
void user_1ms_isr_type2(void){}

TASK(TaskMain)
{
  Lcd lcd;

  lcd.clear();
  lcd.putf("s", "Hello World");
  lcd.disp();

  while(1);
}
}


 

Home