User Tools

Site Tools




void startCom0UntilEvent ( u8 untilCode )
void startCom1UntilEvent ( u8 untilCode )
void startCom2UntilEvent ( u8 untilCode )

untilCode: Data to wait for (0 to 255)

Enables the data test event for serial channel 0. An event will occur when untilCode is detected in the receive buffer.

In the example depicted above, the data from “start code” through “body” will be written to the serial channel's receive buffer until the “stop code” 0x30 is received, at which time, the event will occur. In the event handler, the entire packet can be processed.

#include "moacon500.h"
void cmain(void)
 openCom(0,115200,C8N1);          // Open serial channel 0
 startCom0UntilEvent(0x30);       // Begin receiving events when data 0x30 is received
 while(1) { }                     // Run forever
void com0UntilEvent(void)         // This function is called when data 0x30
{                                 // is received on channel 0
 while (comLen(0) > 0)            // Continue until all data is processed
   comPut(0, comGet(0));          // Echo data back to sender

go MOACON home

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