Пример #1
0
int serialPortWriteFrom(int portNum, int count, void *startPtr)
{
  char serialPortName[PORT_NAME_SIZE];
	
  if ((portNum < 0) || (portNum >= MAX_SERIAL_PORTS))
    {
      success(false);
      return 0;
    }
	
  make_portname_from_portnum(serialPortName, portNum);
        
  return serialPortWriteFromByName(serialPortName, count, startPtr);
}
Пример #2
0
EXPORT(sqInt) primitiveSerialPortWriteByName(void) {
	sqInt bytesWritten;
	char * cString;
	char *deviceName;
	char *array;
	sqInt startIndex;
	sqInt count;
	sqInt _return_value;
	char *p;
	sqInt len;
	sqInt terminatedString;

	interpreterProxy->success(interpreterProxy->isBytes(interpreterProxy->stackValue(3)));
	deviceName = ((char *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(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())) {
		/* begin allocateTerminatedString: */
		len = interpreterProxy->sizeOfSTArrayFromCPrimitive(deviceName);
		terminatedString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), len + 1);
		p = interpreterProxy->arrayValueOf(terminatedString);
		p[len] = 0;
		while (len >= 0) {
			len -= 1;
			p[len] = (deviceName[len]);
		}
		cString = p;
		bytesWritten = serialPortWriteFromByName(cString, count, (array + startIndex) - 1);
	}
	_return_value = interpreterProxy->integerObjectOf(bytesWritten);
	if (interpreterProxy->failed()) {
		return null;
	}
	interpreterProxy->popthenPush(5, _return_value);
	return null;
}
Пример #3
0
primitiveSerialPortWriteByName(void)
{
	char *array;
	char * arrayPtr;
	sqInt bytesWritten;
	sqInt count;
	char *port;
	char *portName;
	sqInt portNameSize;
	sqInt startIndex;
	sqInt _return_value;

	bytesWritten = 0;
	success(isBytes(stackValue(3)));
	portName = ((char *) (firstIndexableField(stackValue(3))));
	success(isBytes(stackValue(2)));
	array = ((char *) (firstIndexableField(stackValue(2))));
	startIndex = stackIntegerValue(1);
	count = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize)));
	port = calloc(portNameSize+1, sizeof(char));
	memcpy(port, portName, portNameSize);
	success((startIndex >= 1)
	 && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize)))));
	if (!(failed())) {
		arrayPtr = (array + startIndex) - 1;
		bytesWritten = serialPortWriteFromByName(port, count, arrayPtr);
	}
	free(port);
	if (failed()) {
		return null;
	}
	_return_value = integerObjectOf(bytesWritten);
	popthenPush(5, _return_value);
	return null;
}