static void sensorTimedReportCallBack(YSensor *fct, YMeasure measure) { const char *header = (Globalp.encodeNMEA ? "$YS" : ""); char buf[512]; snprintf(buf, sizeof(buf), "%s%s,%.3f,%s", header, fct->get_logicalName().c_str(), measure.get_averageValue(), fct->get_unit().c_str()); if(Globalp.encodeNMEA) { // NMEA format: compute checksum and append it to the message int i, len = (int)strlen(buf); unsigned chksum = 0; for(i = 1; i < len; i++) { chksum ^= (unsigned char)buf[i]; } snprintf(buf+len, sizeof(buf)-len, "*%02X\r\n", chksum); } else { // raw format, just append CR-LF strcat(buf, "\r\n"); } TCPBroadcast(buf); }
static void sensorTimedReportCallBack(YSensor *fct, YMeasure measure) { cout << fct->get_hardwareId() << " : " << measure.get_averageValue() << " " << fct->get_unit() << " (timed report)" << endl; }