Dear Pharoisten, I have a couple of questions about my understanding about Pharo, the VM and COG.
the COG VM is the "normal virtual machine as I understand" At least my Pharo give me: 'Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.35]' It is my understanding that the Cog sources do not contain the actual SerialPlugin stuff from SergeStinckwicj- At least I can not find anything like OpenPortByname or writeToNamed port or the like. So I fetched the Squeak sources and the Cog sources and indeed they are different. The Cog version defines: #ifdef SQUEAK_BUILTIN_PLUGIN void* SerialPlugin_exports[][3] = { {"SerialPlugin", "getModuleName", (void*)getModuleName}, {"SerialPlugin", "initialiseModule", (void*)initialiseModule}, {"SerialPlugin", "primitiveSerialPortClose", (void*)primitiveSerialPortClose}, {"SerialPlugin", "primitiveSerialPortOpen", (void*)primitiveSerialPortOpen}, {"SerialPlugin", "primitiveSerialPortRead", (void*)primitiveSerialPortRead}, {"SerialPlugin", "primitiveSerialPortWrite", (void*)primitiveSerialPortWrite}, {"SerialPlugin", "setInterpreter", (void*)setInterpreter}, {"SerialPlugin", "shutdownModule", (void*)shutdownModule}, {NULL, NULL, NULL} }; #endif /* ifdef SQ_BUILTIN_PLUGIN */ Whereas the Squeal-vm version contains e.g: #ifdef SQUEAK_BUILTIN_PLUGIN void* SerialPlugin_exports[][3] = { {"SerialPlugin", "primitiveSerialPortWrite", (void*)primitiveSerialPortWrite}, {"SerialPlugin", "primitiveSerialPortClose", (void*)primitiveSerialPortClose}, {"SerialPlugin", "primitiveSerialPortOpenByName", (void*)primitiveSerialPortOpenByName}, {"SerialPlugin", "primitiveSerialPortWriteByName", (void*)primitiveSerialPortWriteByName}, {"SerialPlugin", "primitiveSerialPortReadByName", (void*)primitiveSerialPortReadByName}, {"SerialPlugin", "shutdownModule", (void*)shutdownModule}, {"SerialPlugin", "primitiveSerialPortOpen", (void*)primitiveSerialPortOpen}, {"SerialPlugin", "initialiseModule", (void*)initialiseModule}, {"SerialPlugin", "setInterpreter", (void*)setInterpreter}, {"SerialPlugin", "getModuleName", (void*)getModuleName}, {"SerialPlugin", "primitiveSerialPortCloseByName", (void*)primitiveSerialPortCloseByName}, {"SerialPlugin", "primitiveSerialPortRead", (void*)primitiveSerialPortRead}, {NULL, NULL, NULL} }; #endif So now it seems the Cog version is for building an internal plugin. (I may be mistaken of course) but the code for primitiveSerialPortOpen looks like this: EXPORT(sqInt) primitiveSerialPortOpen(void) { sqInt baudRate; sqInt dataBits; sqInt inFlowControl; sqInt outFlowControl; sqInt parityType; sqInt portNum; sqInt stopBitsType; sqInt xOffChar; sqInt xOnChar; portNum = interpreterProxy->stackIntegerValue(8); baudRate = interpreterProxy->stackIntegerValue(7); stopBitsType = interpreterProxy->stackIntegerValue(6); parityType = interpreterProxy->stackIntegerValue(5); dataBits = interpreterProxy->stackIntegerValue(4); inFlowControl = interpreterProxy->stackIntegerValue(3); outFlowControl = interpreterProxy->stackIntegerValue(2); xOnChar = interpreterProxy->stackIntegerValue(1); xOffChar = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { whereas the Squeak sources looks like this: int serialPortOpen(int portNum, int dataRate, int stopBitsType, int parityType, int dataBits, int inFlowCtrl, int outFlowCtrl, int xOnChar, int xOffChar) { char serialPortName[PORT_NAME_SIZE]; make_portname_from_portnum(serialPortName, portNum); return serialPortOpenByName(serialPortName, dataRate, stopBitsType, parityType, dataBits, inFlowCtrl, outFlowCtrl, xOnChar, xOffChar); } So I assume one has to make the changes as in the cog examples to make this plugin workable in Cog. Is that a correct impression. Well then it comes to the questions of how to properly write a plugin for the COG vm. Are there any tutorials about it, or is the best I can hope for the sources for Cog itself? My understanding is that stackIntegerValue, picks out a parameter from a Cogs primitive. Is that a correct impression? It seems that at least the following things have to be exported from a plugin: getModuleName setInterpreter and maybe initializeModule shutdownModule The latter are probably for cleaning up.... But maybe I'm on the complete wrong track. Because at the beginning I can read: /* Automatically generated by SmartSyntaxPluginCodeGenerator VMMaker-oscog.40 uuid: 637db40c-33c6-4263-816e-1b8cc19e3c99 from SerialPlugin VMMaker-oscog.40 uuid: 637db40c-33c6-4263-816e-1b8cc19e3c99 */ So is this code not written in C but maybe somewhere else? As you can see I'm more than less clueless. So what is the "supposed" way to migrat that kind of code? Regards Friedrich -- Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus