Home page / Legoģ / Robotics / emulegOS / Porting Guide

How to port emulegOS

We tried and designed emulegOS for maximum portability. Here you find some hints to help you in this task.

The core of emulegOS, the emuLegOs.cpp (and . h ) files should not need any conversion at all. The same for the Program and RealWorld units that are simply wrappers for the final userís code.

emurcx.cpp contains the WinMain entry point of the application. This file should be quite plain to convert.

emurcx.bpp is the makefile in the Borland C++Builder style. Probably you better start your makefile or project file from scratch.

Main.cpp, Main.h and Main.dfm contain the user interface. Here is where the hard work is. Actually you donít need to mimic our graphic choices for your interface. What you really have to do is to create some functions to pass to emuLegOs as callbacks to make it update your interface when something happens.

// Called to update sensor status on Rcx emulator
void (*updateSensorStatus)(int) = NULL;
void setCallbackUpdateSensorStatus( void (*_updateSensorStatus)(int) );

// Called to update motor direction on Rcx emulator
void (*updateMotorDir)(int, MotorDirection) = NULL;
void setCallbackUpdateMotorDir( void (*_updateMotorDir) ( int , MotorDirection ) );

// Called to update motor speed on Rcx emulator
void (*updateMotorSpeed) ( int, unsigned char ) = NULL;
void setCallbackUpdateMotorSpeed( void (*_updateMotorSpeed) ( int, unsigned char ) );

// Called to update raw sensor values on Rcx emulator
void (*updateSensorRawValues) ( int, unsigned, int ) = NULL;
void setCallbackUpdateSensorRawValues( void (*_updateSensorRawValues) ( int, unsigned, int ) );

// Called to update lcd on Rcx emulator
void (*updateLcd) ( string ) = NULL;
void setCallbackUpdateLcd( void (*_updateLcd) ( string ) );

// Called to show some error message during program emulation
void (*showErrorMessage) ( string ) = NULL;
void setCallbackShowErrorMessage( void (*_showErrorMessage) ( string ) )

About updating the sensor values from the interface, we chose the approach to directly modify the sensor[] public array defined in emuLegOs.h .

Donít forget you need a copy of the pthreads library. If you stay with the Windows OS the supplied one is OK.

Have luck.


1