Esempio n. 1
0
void Widget::on_pbSend_clicked()
{
    if (netServer == NULL) return;
    QByteArray ba = qPrintable(ui->pteSend->toPlainText());
    ba = ba.replace("\n", "\r\n");
    if (ui->chkSendHexa->checkState() == Qt::Checked) ba = ba.fromHex(ba);
    netServer->write(ba);
}
Esempio n. 2
0
void widgetData::on_butExchangeData_clicked()
{
    QByteArray dat = "data ";
    QByteArray m = ui->editSend->text().toLocal8Bit();
    QByteArray temp = m.fromHex(m);

    //dat += m.number(m.fromHex(m).count()) +" " + m.fromHex(m);
    dat += m.number(temp.count()) + " " + temp.toHex();

    emit SendCom(dat);

}
Esempio n. 3
0
//
//void send_ucp_pack(uint8_t idx, uint16_t value)
//
void CComCalier::send_ucp_pack(uint8_t idx, uint16_t value)
{
    if(Uart != NULL && Uart->isOpen())
    {
        QString tempQString;
        tempQString = "55aa00";
        tempQString += QString("%1").arg(idx,2,16,QLatin1Char('0'));
        tempQString += QString("%1").arg((uint8_t)(value&0xff),2,16,QLatin1Char('0'));
        tempQString += QString("%1").arg((uint8_t)(value>>8),2,16,QLatin1Char('0'));
        tempQString += "0000";

        QByteArray tempByteArray;
        tempByteArray.append(tempQString);
        Uart->write(tempByteArray.fromHex(tempByteArray));
    }
Esempio n. 4
0
bool CWizRtfReader::load(const QString& strFile, QString& strText)
{
    QByteArray ba = file_load (strFile);

    QString text;
    text.reserve (ba.size());

    int i = 0;
    int l = ba.size();

    QString ansicgp;
    int n = ba.indexOf ("ansicpg");
    if (n != -1)
    {
        int m = ba.indexOf ('\\', n);
        n += 7;
        ansicgp = ba.mid (n, m - n);
    }

    if (ansicgp.isEmpty()) //assuming unicode
    {
        while (i < l)
            if ((ba.at(i) == '\\') && (ba.at(i + 1) == 'u'))
            {
                QByteArray ta = ba.mid (i, 7);
                ta = ta.mid (2, 4);
                QChar c (ta.toInt());
                text.append (c);
                i += 7 + 3;
            }
            else
            {
                text.append (ba.at(i));
                i++;
            }
    }
    else
    {
        ansicgp.prepend ("CP");

        QTextCodec *codec = QTextCodec::codecForName (ansicgp.toUtf8().data());
        qDebug() << "not unicode!";

        while (i < l)
            if ((ba.at(i) == '\\') && (ba.at(i + 1) == '\''))
            {
                QByteArray ta = ba.mid (i, 4);
                ta = ta.mid (2, 2);
                QByteArray bh = ta.fromHex (ta);
                text.append (codec->toUnicode (bh));
                i += 4;
            }
            else
            {
                text.append (ba.at(i));
                i++;
            }
    }

    strText = rtf_strip (text);

    return true;
}