GEOS SDK TechDocs
|
|
2 Connecting
|
4 Receiving Data
To send data, MTalk does the following:
ModemSend()
(defined in modem.goc) to send the dataCode Display 9-2 Sending Data Over A Serial Connection
/*
* textBlock - Handle of block containing text to send.
* textPtr - Pointer to text to send.
* textSize - Size of text to send.
*/
MemHandle textBlock;
char * textPtr;
int textSize;
/*
* Get text that user has typed and put it into a newly created memory block.
* Lock the block down on the heap and obtain a pointer to it.
*/
textBlock = @call MTalkSendText::MSG_VIS_TEXT_GET_ALL_BLOCK( NullHandle );
textPtr = MemLock( textBlock );
/*
* Get the size of the text then send it.
*/
textSize = LocalStringSize( textPtr );
if ( ModemSend( textSize, (byte*)textPtr ) != STREAM_NO_ERROR )
{
/* handle the error */
}
/*
* Once the text has been sent, free its block.
*/
MemFree( textBlock );
ModemSend()
calls the VirtualSerial Library routine,
VirtualSerialWrite()
, to send the passed data.
VirtualSerialWrite()
writes the passed data to stream and, if necessary, blocks until enough space in the stream becomes available. (If you don't want to block, pass STREAM_NO_BLOCK in
VirtualSerialWrite()
.)
ModemSend()
takes two arguments:
ModemSend()
returns a
StreamError
value:
GEOS SDK TechDocs
|
|
2 Connecting
|
4 Receiving Data