chWrite (Function) |
Top Previous Next |
The "chWrite()" function will write a message to the specified channel. If the number of messages currently in the channel has reached the maximum as specified with chInit(), the calling thread will be blocked due to waiting for another thread to read a message by using the chRead() function. Optionally, a timeout for the write operation can be specified.
Also see chRead() and the section on Using Multithreading.
Special note on writing strings to a channel: A STRING cannot be written directly to a channel but must be converted into pure memory with the strToMemory() function before being written to a channel. When this message is received by the chRead() function, it can be converted back to a string again by using the strFromMemory() function.
Input: ch : CHANNEL The channel to write the message to.
msg : PTR Pointer to buffer where the message is to be stored.
len : INT The length of the message.
timeout : INT (default: -1) The time, in ms, to wait before giving up when the channel is full. Use -1 to wait forever. This is the default.
Returns: INT
Declaration: FUNCTION chWrite : INT;
Example: INCLUDE rtcu.inc |