short comGets (u8 comCh, u8* dest, u16 length)
comCh : Channel number |
dest: Pointer to where data that is read should be stored |
length: The amount of data (in bytes) to read |
Returns –1 if data is read; 0 if data is not read. |
Reads length bytes from the receive buffer on channel comCh, and stores the data in memory at address dest.
#include "moacon500.h" void cmain(void) { char c[64]; openCom(0, 115200, C8N1); // Channel 0, 115200 Baud, // data bits: 8, no parity, stop bits: 1 while (1) // Repeat forever { if(comLen(0) > 0) // if data exists in the receive buffer { comGets(0, c, 64); // Read data from receive buffer in store it // and store it in char array, c. } } }
The example program above reads data from the receive buffer as it arrives and stores it in char array c.