While working on robots, we needed to work with a sensor that uses a serial communication protocol. However, we also needed UDP sockets to work with other parts of the robot. The problem is:
- SerialPlugin only work in squeak VM (old VM) and not in the Cog VM
- UDP sockets only work in Cog VM and not in squeak VM
I decided to take the bull by the horns and modify the Cog VM so that the SerialPlugin works. In this post, I will quickly explain what I did.
1. Get the VM sources
git clone git://gitorious.org/cogvm/blessed.git
I cloned the git repository of Cog. I did not used the svn repository (http://squeakvm.org/svn/squeak/trunk) because the git repository also includes useful scripts. Then, I followed the steps described in the HOWTOBUILD file.
2. Create your own VMMaker image
cd image
PHARO_VM=/Applications/SmalltalkVMs/CogVM.app/Contents/MacOS/CogVM ./newImage.sh
You should specify your own VM path. Then, you can use the generator.image that has loaded the right VMMaker package.
3. Generate C source code from Slang
In the generator.image, a workspace contains a lot of useful snippets. Execute the right one depending on your setup. For me it was:
"Configuration for OSX"
CogCocoaIOSConfig new
addExternalPlugins: #( FT2Plugin );
addInternalPlugins: #( UnixOSProcessPlugin );
"generateForDebug;"
generateSources; generate.
You can analyse the generated C source code in the src/ directory.
4. Compile C code
# as of 10.7 llvm is the default but incompatible compiler
export CC='/usr/bin/gcc-4.2'
export MACOSX_DEPLOYMENT_TARGET=10.5
cd build
sh ../codegen-scripts/extract-commit-info.sh
cmake .
make
5. Check your new VM
In the result/ directory you should find your new VM.
6. Modify VM sources
You can now either modify the C source code (plugins, …) or the Slang code. In my case, I changed a single method in the SerialPlugin class. Then I rebuilt a new modified VM and tested it. I also verified that I worked on the latest version.
Note: In my case, I worked on the VMMaker-oscog branch (Pharo branch?) and not the VMMaker.oscog (Eliot’s branch).
7. Publish your patch
I am not sure that I followed the “right” process in this step. What I did is to fill a bug entry in the Cog bug tracker https://code.google.com/p/cog/issues/list and I attached a .mcz (or .st) file to the bug entry.
Thanks to Igor, Esteban and others who made this process simple.
Luc, is this the patch?
https://code.google.com/p/cog/issues/detail?id=119&q=luc
Santi was looking at it the other day :)