예제 #1
0
void
IpcLogReader::run()
{
#if defined(Q_OS_WIN)

	const WCHAR* name = L"\\\\.\\pipe\\SynergyLog";

	HANDLE pipe = CreateFile(
		name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);

	if (pipe == INVALID_HANDLE_VALUE)
	{
		receivedLine(
			QString("ERROR: could not connect to service log, error: ") +
			QString::number(GetLastError()));
		return;
	}

	char buffer[1024];
	DWORD bytesRead;

	while (true)
	{
		if (!ReadFile(pipe, buffer, sizeof(buffer), &bytesRead, NULL)) {
			break;
		}

		buffer[bytesRead] = '\0';

		QString text = QString::fromAscii(buffer, bytesRead);
		text = text.trimmed().append("\n");
		receivedLine(text);
	}
#endif
}
void GsmModuleController::initMembers(QString *devicePath,
									  QString *defaultTelNum)
{
	device = new GsmModule(*devicePath, this);
	busyTime = 0;
	defaultNumber = *defaultTelNum;

	connect(device, SIGNAL(receivedLine(QString)),
			this, SLOT(onReceivedLine(QString)));
	connect(device, SIGNAL(occuredError(const int)),
			this, SIGNAL(occuredError(const int)));
}
예제 #3
0
void ProtocolView::processOutput()
{
    int pos;
    while ( (pos = buf.find('\n')) != -1)
	{
	    QString line = buf.left(pos);
	    if (!line.isEmpty())
                {
		    appendLine(line);
                    emit receivedLine(line);
                }
	    buf = buf.right(buf.length()-pos-1);
	}
}
void GsmModule::readData(int fd)
{
	// Read the byte
	char byte;
	if (read(fd, &byte, 1) != 1)
	{
		emit occuredError(Serial_Read_Error);
		return;
	}

	// Check if is an end-of character; if so, signal a receivedLine() event
	if (byte == '\n')
	{
		// If the last character in the buffer is '\r', this is a \r\n
		//  combination, we remove it
		int last = bufferIn.length() - 1;
		if (bufferIn.endsWith('\r'))
			bufferIn.remove(last);

		// Signal line receiving event if needed
		if (bufferIn.length() > 0)
			emit receivedLine(bufferIn);
		bufferIn.clear();
	}
	else if (byte == '\x1a')
	{
		// If the character is EOF (ASCII 0x1a), this is the end of an SMS
		//  input. Break this as a line too.
		if (bufferIn.length() > 0)
			emit receivedLine(bufferIn);
		bufferIn.clear();
	}

	// Otherwise just append the byte to the end of the buffer
	bufferIn.append(byte);
}
예제 #5
0
bool ProtocolView::startJob(bool isUpdateJob)
{
    m_isUpdateJob = isUpdateJob;

    // get command line and add it to output buffer
    QString cmdLine = job->cvsCommand();
    buf += cmdLine;
    buf += '\n';
    processOutput();

    // disconnect 3rd party slots from our signals
    disconnect( SIGNAL(receivedLine(QString)) );
    disconnect( SIGNAL(jobFinished(bool, int)) );

    return job->execute();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ard = new QSerialPort();
    connect(ui->actionConnect_2,SIGNAL(triggered()),this,SLOT(ardConnect()));
    connect(ard,SIGNAL(readyRead()),this,SLOT(receivedLine()));
    connect(ui->actionRead_from_log,SIGNAL(triggered()),this,SLOT(readFile()));
    connect(this,SIGNAL(processDone()),this,SLOT(continueMath()));
    timesPerTic = new QList<int>;
    rpm = new QList<double>;
    angAcc = new QList<double>;
    timeStamp = new QList<double>;
    sortedAng = new QList<double>;
    sortedAngTimes = new QList<double>;
    sortedRpm = new QList<double>;
    sortedRpmTimes = new QList<double>;
}