Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker-oscog-EstebanLorenzano.166.mcz
==================== Summary ====================
Name: VMMaker-oscog-EstebanLorenzano.166 Author: EstebanLorenzano Time: 2 November 2012, 1:56:26.517 pm UUID: 5773fcb9-2982-4507-8a9e-4308ec33731e Ancestors: VMMaker-oscog-EstebanLorenzano.165
- SerialPlugin now understands *ByName primitives
=============== Diff against VMMaker-oscog-EstebanLorenzano.165 ===============
Item was changed: SmartSyntaxInterpreterPlugin subclass: #SerialPlugin instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'VMMaker-Plugins'!
+ !SerialPlugin commentStamp: '<historical>' prior: 0! + Implement the serial port primitives. Since it requires platform support it will only be built when supported on your platform. + + IMPORTANT: So far, we are converting everytime a string into a char* and then we look for it in the ports array. That can be optimized a lot by just answering the external handler (the position in the array perhaps) after open and using it instead the name. + Also, using open by id functions doesn't help because internally they are also converted into a char* (using sprintf). + + If needed, that can be optimized then. ! - !SerialPlugin commentStamp: 'tpr 5/2/2003 15:49' prior: 0! - Implement the serial port primitives. Since it requires platform support it will only be built when supported on your platform!
Item was added: + ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') ----- + primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType: outFlowControl xOnByte: xOnChar xOffByte: xOffChar + <var: #port type: 'char *'> + + | port portNameSize | + + self primitive: 'primitiveSerialPortOpenByName' + parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ). + + portNameSize := interpreterProxy slotSizeOf: (portName asOop: String). + port := self cCode: 'calloc(portNameSize, sizeof(char))'. + self cCode: 'memcpy(port, portName, portNameSize)'. + + self cCode: 'serialPortOpenByName( + portName, baudRate, stopBitsType, parityType, dataBits, + inFlowControl, outFlowControl, xOnChar, xOffChar)'. + + self free: port.!
Item was added: + ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') ----- + primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count + <var: #port type: 'char *'> + + | port portNameSize bytesRead arrayPtr | + + self primitive: 'primitiveSerialPortReadByName' + parameters: #(String ByteArray SmallInteger SmallInteger ). + + interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]). + "adjust for zero-origin indexing" + + portNameSize := interpreterProxy slotSizeOf: (portName asOop: String). + port := self cCode: 'calloc(portNameSize, sizeof(char))'. + self cCode: 'memcpy(port, portName, portNameSize)'. + + arrayPtr := array asInteger + startIndex - 1. + bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'. + + self free: port. + + ^ bytesRead asSmallIntegerObj!
Item was added: + ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') ----- + primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count + <var: #port type: 'char *'> + + | bytesWritten arrayPtr portNameSize port | + + self primitive: 'primitiveSerialPortWriteByName' + parameters: #(String ByteArray SmallInteger SmallInteger ). + + portNameSize := interpreterProxy slotSizeOf: (portName asOop: String). + port := self cCode: 'calloc(portNameSize, sizeof(char))'. + self cCode: 'memcpy(port, portName, portNameSize)'. + + interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]). + interpreterProxy failed + ifFalse: [arrayPtr := array asInteger + startIndex - 1. + bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ]. + + self free: port. + + ^ bytesWritten asSmallIntegerObj!
vm-dev@lists.squeakfoundation.org