EXPORT(sqInt) primitiveSerialPortWrite(void) { sqInt bytesWritten; sqInt portNum; char *array; sqInt startIndex; sqInt count; sqInt _return_value; portNum = interpreterProxy->stackIntegerValue(3); interpreterProxy->success(interpreterProxy->isBytes(interpreterProxy->stackValue(2))); array = ((char *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(2)))); startIndex = interpreterProxy->stackIntegerValue(1); count = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } interpreterProxy->success((startIndex >= 1) && (((startIndex + count) - 1) <= (interpreterProxy->byteSizeOf((oopForPointer( array ) - BASE_HEADER_SIZE))))); if (!(interpreterProxy->failed())) { bytesWritten = serialPortWriteFrom(portNum, count, (array + startIndex) - 1); } _return_value = interpreterProxy->integerObjectOf(bytesWritten); if (interpreterProxy->failed()) { return null; } interpreterProxy->popthenPush(5, _return_value); return null; }
primitiveSerialPortWrite(void) { char *array; char * arrayPtr; sqInt bytesWritten; sqInt count; sqInt portNum; sqInt startIndex; sqInt _return_value; bytesWritten = 0; portNum = stackIntegerValue(3); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); if (!(failed())) { arrayPtr = (array + startIndex) - 1; bytesWritten = serialPortWriteFrom(portNum, count, arrayPtr); } if (failed()) { return null; } _return_value = integerObjectOf(bytesWritten); popthenPush(5, _return_value); return null; }
/* Write count bytes from the named byte array to the given serial port's output buffer. Return the number of bytes written. This implementation is asynchronous: it may return before the entire packet has been sent. */ int serialPortWriteFromByName(const char *portName, int count, void *startPtr) { int portNum = portNumberForName(portName); if (portNum < 0) { success(false); return 0; } return serialPortWriteFrom(portNum, count, startPtr); }