void SerialModule::serialDataReceived(const var & data) { inActivityTrigger->trigger(); switch (port->mode) { case SerialDevice::LINES: processDataLine(data.toString()); break; case SerialDevice::DATA255: case SerialDevice::RAW: case SerialDevice::COBS: Array<uint8> bytes((const uint8_t *)data.getBinaryData()->getData(), (int)data.getBinaryData()->getSize()); processDataBytes(bytes); break; } }
void FileReaderTXT::nextLine(bool strip) { data = false; section = false; string line = ""; while (line.empty() || line[0] == '#') { if (inputFile->eof()) { endOfFile = true; return; } lineNumber++; getline(*inputFile, line); string::size_type invalidCharPos = 0; // CTRL+Z removing while ((invalidCharPos = line.find(char(26), invalidCharPos)) != line.npos) { line.erase(invalidCharPos, 1); } if (!line.empty() && line[line.size() - 1] == '\r') { line.erase(line.size() - 1); } if (strip) { while (!line.empty() && (line[line.size() - 1] == ' ' || line[line.size() - 1] == '\t')) { line.erase(line.size() - 1); } } } if (line[0] == '[') { processSection(line); } else { processDataLine(line); } }