User Tools

Site Tools

한국어

moacon:comlen:index

comLen

u16 comLen (u8 comCh)

comCh : Channel number

Gets the amount of data in receive buffer for channel comCh. If data is not taken out of the receive buffer with functions like comGet, and the receive buffer is filled, any additional incoming data will be discarded. To avoid losing incoming data, be sure to read data as it arrives.

#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.
   }
 }
}

go MOACON home

moacon/comlen/index.txt · Last modified: 2016/04/14 11:07 (external edit)