• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ codec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中codec函数的典型用法代码示例。如果您正苦于以下问题:C++ codec函数的具体用法?C++ codec怎么用?C++ codec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了codec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TestViterbiDecodingSamples

void TestViterbiDecodingSamples() {
  {
    std::vector<int> polynomials;
    polynomials.push_back(7);
    polynomials.push_back(5);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec,
                        "0011100001100111111000101100111011",
                        "010111001010001");

    // Inject 1 error bit.
    TestViterbiDecoding(codec,
                        "0011100001100111110000101100111011",
                        "010111001010001");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(7);
    polynomials.push_back(6);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec, "1011010100110000", "101100");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(6);
    polynomials.push_back(5);

    ViterbiCodec codec(3, polynomials);

    TestViterbiDecoding(codec, "011011011101101011", "1001101");

    // Inject 2 error bits.
    TestViterbiDecoding(codec, "111011011100101011", "1001101");
  }

  {
    std::vector<int> polynomials;
    polynomials.push_back(91);
    polynomials.push_back(117);
    polynomials.push_back(121);

    ViterbiCodec codec(7, polynomials);

    TestViterbiDecoding(codec,
                        "111100101110001011110101111111001011100111",
                        "10110111");

    // Inject 4 error bits.
    TestViterbiDecoding(codec,
                        "100100101110001011110101110111001011100110",
                        "10110111");
  }
}
开发者ID:xukmin,项目名称:viterbi,代码行数:59,代码来源:viterbi_test.cpp


示例2: readSettings

/*!
  Serialize the account information to the current group of
  the given QSettings file \a conf.

  \sa readSettings()
*/
void AccountConfiguration::saveSettings(QSettings *conf) const
{
    conf->setValue("name", _userName );
    conf->setValue("email", _emailAddress );
    conf->setValue("mailuser", _mailUserName );
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        QByteArray encoded = codec.encode(_mailPassword, "ISO-8859-1");
        QString plain;
        plain = QString::fromLatin1(encoded.constData(), encoded.length());
        conf->setValue("mailpasswordobs", plain);
    }
    conf->setValue("mailserver", _mailServer );
    conf->setValue("mailport", _mailPort);
    conf->setValue("basefolder", _baseFolder);

    conf->setValue("smtpserver", _smtpServer );
    conf->setValue("smtpport", _smtpPort);
#ifndef QT_NO_OPENSSL
    conf->setValue("smtpUsername",_smtpUsername);
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        QByteArray encoded = codec.encode(_smtpPassword, "ISO-8859-1");
        QString plain;
        plain = QString::fromLatin1(encoded.constData(), encoded.length());
        conf->setValue("smtpPasswordObs", plain);
    }
    conf->setValue("smtpAuthentication",_smtpAuthentication);
    conf->setValue("smtpEncryption",_smtpEncryption);
    conf->setValue("mailEncryption",_mailEncryption);
#endif
    conf->setValue("usesig", _useSig);
    conf->setValue("maxmailsize", _maxMailSize);
    conf->setValue("checkinterval", _checkInterval);
    conf->setValue("intervalCheckRoamingEnabled", _intervalCheckRoamingEnabled);
    conf->setValue("pushEnabled", _pushEnabled);
    conf->remove("defaultmailserver");

    if (_useSig) {
        QString path = Qtopia::applicationFileName("qtopiamail", "") + "sig_" + QString::number(_id.toULongLong());
        QFile file(path);
        if ( file.open(QIODevice::WriteOnly) ) {    // file opened successfully
            QTextStream t( &file );        // use a text stream
            t << _sig;
            file.close();
        }
    }

    conf->setValue("synchronize", _synchronize);
    conf->setValue("deletemail", _deleteMail);

    conf->setValue("networkConfig", _networkCfg);
    conf->setValue("autoDownload", _autoDL);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:60,代码来源:accountconfiguration.cpp


示例3: encode

static QByteArray encode(const QByteArray& input, QMailMessageBody::TransferEncoding encoding)
{
    if (encoding == QMailMessageBody::Base64)
    {
        QMailBase64Codec codec(QMailBase64Codec::Text);
        return codec.encode(input);
    }
    else if (encoding == QMailMessageBody::QuotedPrintable)
    {
        QMailQuotedPrintableCodec codec(QMailQuotedPrintableCodec::Text, QMailQuotedPrintableCodec::Rfc2045);
        return codec.encode(input);
    }

    return input;
}
开发者ID:jose-g,项目名称:qt-labs-messagingframework,代码行数:15,代码来源:tst_qmailmessagebody.cpp


示例4: codec

SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader* chunkReader) {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
    if (nullptr == codec) {
        return nullptr;
    }

    switch (codec->getEncodedFormat()) {
#ifdef SK_CODEC_DECODES_PNG
        case kPNG_SkEncodedFormat:
        case kICO_SkEncodedFormat:
#endif
#ifdef SK_CODEC_DECODES_JPEG
        case kJPEG_SkEncodedFormat:
#endif
#ifdef SK_CODEC_DECODES_GIF
        case kGIF_SkEncodedFormat:
#endif
        case kBMP_SkEncodedFormat:
        case kWBMP_SkEncodedFormat:
            return new SkSampledCodec(codec.detach());
#ifdef SK_CODEC_DECODES_WEBP
        case kWEBP_SkEncodedFormat:
            return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
#endif
#ifdef SK_CODEC_DECODES_RAW
        case kRAW_SkEncodedFormat:
            return new SkRawAdapterCodec((SkRawCodec*)codec.detach());
#endif
        default:
            return nullptr;
    }
}
开发者ID:YangchenVR,项目名称:skia,代码行数:32,代码来源:SkAndroidCodec.cpp


示例5: test_dimensions

static void test_dimensions(skiatest::Reporter* r, const char path[]) {
    // Create the codec from the resource file
    SkAutoTDelete<SkStream> stream(resource(path));
    if (!stream) {
        SkDebugf("Missing resource '%s'\n", path);
        return;
    }
    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.detach()));
    if (!codec) {
        ERRORF(r, "Unable to create codec '%s'", path);
        return;
    }

    // Check that the decode is successful for a variety of scales
    for (int sampleSize = 1; sampleSize < 32; sampleSize++) {
        // Scale the output dimensions
        SkISize scaledDims = codec->getSampledDimensions(sampleSize);
        SkImageInfo scaledInfo = codec->getInfo()
                .makeWH(scaledDims.width(), scaledDims.height())
                .makeColorType(kN32_SkColorType);

        // Set up for the decode
        size_t rowBytes = scaledDims.width() * sizeof(SkPMColor);
        size_t totalBytes = scaledInfo.getSafeSize(rowBytes);
        SkAutoTMalloc<SkPMColor> pixels(totalBytes);

        SkAndroidCodec::AndroidOptions options;
        options.fSampleSize = sampleSize;
        SkCodec::Result result =
                codec->getAndroidPixels(scaledInfo, pixels.get(), rowBytes, &options);
        REPORTER_ASSERT(r, SkCodec::kSuccess == result);
    }
}
开发者ID:atyenoria,项目名称:skia,代码行数:33,代码来源:CodexTest.cpp


示例6: getString

void LLFloaterBuyCurrencyHTML::navigateToFinalURL()
{
	// URL for actual currency buy contents is in XUI file
	std::string buy_currency_url = getString( "buy_currency_url" );

	// replace [LANGUAGE] meta-tag with view language
	LLStringUtil::format_map_t replace;

	// viewer language
	replace[ "[LANGUAGE]" ] = LLUI::getLanguage();

	// flag that specific amount requested 
	replace[ "[SPECIFIC_AMOUNT]" ] = ( mSpecificSumRequested ? "y":"n" );

	// amount requested
	std::ostringstream codec( "" );
	codec << mSum;
	replace[ "[SUM]" ] = codec.str();

	// users' current balance
	codec.clear();
	codec.str( "" );
	codec << gStatusBar->getBalance();
	replace[ "[BAL]" ] = codec.str();

	// message - "This cost L$x,xxx for example
	replace[ "[MSG]" ] = LLURI::escape( mMessage );
	LLStringUtil::format( buy_currency_url, replace );

	// write final URL to debug console
	llinfos << "Buy currency HTML prased URL is " << buy_currency_url << llendl;

	// kick off the navigation
	mBrowser->navigateTo( buy_currency_url, "text/html" );
}
开发者ID:jimjesus,项目名称:kittyviewer,代码行数:35,代码来源:llfloaterbuycurrencyhtml.cpp


示例7: get_bitmap

bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fileBits));
    if (!codec) {
        SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (!resource.fBitmap.setInfo(codec->getInfo().makeColorType(kN32_SkColorType))) {
        SkDebugf("ERROR: could not set bitmap info for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (sizeOnly) {
        return true;
    }

    if (!resource.fBitmap.tryAllocPixels()) {
        SkDebugf("ERROR: could not allocate pixels for <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    if (SkCodec::kSuccess != codec->getPixels(resource.fBitmap.info(),
            resource.fBitmap.getPixels(), resource.fBitmap.rowBytes())) {
        SkDebugf("ERROR: codec failed for basePath <%s>\n", resource.fFullPath.c_str());
        resource.fStatus = DiffResource::kCouldNotDecode_Status;
        return false;
    }

    resource.fStatus = DiffResource::kDecoded_Status;
    return true;
}
开发者ID:aseprite,项目名称:skia,代码行数:34,代码来源:skdiff_utils.cpp


示例8: QByteArray

void PlayerSubtitle::onPlayerStart()
{
    if (!m_enabled)
        return;
    if (!autoLoad()) {
        if (m_file == m_sub->fileName())
            return;
        m_sub->setFileName(m_file);
        m_sub->setFuzzyMatch(false);
        if (m_file.isEmpty()) {
            const int n = m_player->currentSubtitleStream();
            if (n >= 0 && !m_tracks.isEmpty() && m_tracks.size() <= n) {
                m_sub->processHeader(QByteArray(), QByteArray()); // reset
                return;
            }
            QVariantMap track = m_tracks[n].toMap();
            QByteArray codec(track.value("codec").toByteArray());
            QByteArray data(track.value("extra").toByteArray());
            m_sub->processHeader(codec, data);
        } else {
            m_sub->loadAsync();
        }
        return;
    }
    if (m_file != m_sub->fileName())
        return;
    if (!m_player)
        return;
    // autoLoad was false then reload then true then reload
    // previous loaded is user selected subtitle
    m_sub->setFileName(getSubtitleBasePath(m_player->file()));
    m_sub->setFuzzyMatch(true);
    m_sub->loadAsync();
    return;
}
开发者ID:elearning2015,项目名称:QtAV,代码行数:35,代码来源:PlayerSubtitle.cpp


示例9: attributes

void EntityEditor::submitChanges()
{
	if (mRootAdapter->hasChanges()) {
		Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements();
		if (rootElement.isMap()) {
			std::map<std::string, ::Atlas::Message::Element> attributes(rootElement.asMap());
			if (attributes.size()) {

				std::stringstream ss;

				Atlas::Message::QueuedDecoder decoder;

				Atlas::Codecs::XML codec(ss, decoder);
				Atlas::Formatter formatter(ss, codec);
				Atlas::Message::Encoder encoder(formatter);
				formatter.streamBegin();
				encoder.streamMessageElement(attributes);
				formatter.streamEnd();
				S_LOG_VERBOSE("Sending attribute update to server:\n" << ss.str());

				EmberServices::getSingleton().getServerService().setAttributes(&mEntity, attributes);
			}
		}
	}
}
开发者ID:Laefy,项目名称:ember,代码行数:25,代码来源:EntityEditor.cpp


示例10: main

int main( int argc, char* argv[] )
{
  //! [Creating a Convolutional code]
  //! [Creating a Convolutional code structure]
  //! [Creating a trellis]
  /*
   We are creating a trellis structure with 1 input bit.
   The constraint length is 4, which means there are 3 registers associated
   with the input bit.
   There are two output bits, the first one with generator 4 (in octal) associated
   with the input bit.
   */
  fec::Trellis trellis({4}, {{013, 017}}, {015});
  //! [Creating a trellis]
  
  /*
   The trellis is used to create a code structure.
   We specify that one bloc will conatins 1024 branches before being terminated.
   */
  auto options = fec::Convolutional::Options(trellis, 1024);
  options.termination(fec::Convolutional::Tail);
  options.algorithm(fec::Approximate);
  //! [Creating a Convolutional code structure]
  
  /*
   A code is created and ready to operate
   */
  std::unique_ptr<fec::Codec> codec(new fec::Convolutional(options));
  //! [Creating a Convolutional code]
  
  std::cout << per(codec, 3.0) << std::endl;
  
  return 0;
}
开发者ID:eti-p-doray,项目名称:FeCl,代码行数:34,代码来源:Convolutional.cpp


示例11: codec

/*!
    Returns the string \a value encoded into base-64 encoded form.
*/
QString QMailServiceConfiguration::encodeValue(const QString &value)
{
    // TODO: Shouldn't this be UTF-8?
    QMailBase64Codec codec(QMailBase64Codec::Text);
    QByteArray encoded(codec.encode(value, "ISO-8859-1"));
    return QString::fromLatin1(encoded.constData(), encoded.length());
}
开发者ID:blammit,项目名称:messagingframework,代码行数:10,代码来源:qmailserviceconfiguration.cpp


示例12: codec

void ColorCodecBench::decodeAndXformQCMS() {
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded));
#ifdef SK_DEBUG
    const SkCodec::Result result =
#endif
    codec->startScanlineDecode(fSrcInfo);
    SkASSERT(SkCodec::kSuccess == result);

    SkAutoTCallVProc<qcms_profile, qcms_profile_release>
            srcSpace(qcms_profile_from_memory(fSrcData->data(), fSrcData->size()));
    SkASSERT(srcSpace);

    SkAutoTCallVProc<qcms_transform, qcms_transform_release>
            transform (qcms_transform_create(srcSpace, QCMS_DATA_RGBA_8, fDstSpaceQCMS.get(),
                                             QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL));
    SkASSERT(transform);

#ifdef SK_PMCOLOR_IS_RGBA
    qcms_output_type outType = QCMS_OUTPUT_RGBX;
#else
    qcms_output_type outType = QCMS_OUTPUT_BGRX;
#endif

    void* dst = fDst.get();
    for (int y = 0; y < fSrcInfo.height(); y++) {
#ifdef SK_DEBUG
        const int rows =
#endif
        codec->getScanlines(fSrc.get(), 1, 0);
        SkASSERT(1 == rows);

        qcms_transform_data_type(transform, fSrc.get(), dst, fSrcInfo.width(), outType);
        dst = SkTAddOffset<void>(dst, fDstInfo.minRowBytes());
    }
}
开发者ID:aseprite,项目名称:skia,代码行数:35,代码来源:ColorCodecBench.cpp


示例13: streamDeleter

SkCodec* SkCodec::NewFromStream(SkStream* stream) {
    if (!stream) {
        return NULL;
    }

    SkAutoTDelete<SkStream> streamDeleter(stream);
    
    SkAutoTDelete<SkCodec> codec(NULL);
    for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
        DecoderProc proc = gDecoderProcs[i];
        const bool correctFormat = proc.IsFormat(stream);
        if (!stream->rewind()) {
            return NULL;
        }
        if (correctFormat) {
            codec.reset(proc.NewFromStream(streamDeleter.detach()));
            break;
        }
    }

    // Set the max size at 128 megapixels (512 MB for kN32).
    // This is about 4x smaller than a test image that takes a few minutes for
    // dm to decode and draw.
    const int32_t maxSize = 1 << 27;
    if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) {
        SkCodecPrintf("Error: Image size too large, cannot decode.\n");
        return NULL;
    } else {
        return codec.detach();
    }
}
开发者ID:webbjiang,项目名称:skia,代码行数:31,代码来源:SkCodec.cpp


示例14: main

int main(int argc, char **argv)
{
  struct stat sbuf;
  const char *fname = "test.jpg";
  FlowImage image("image");
  if (stat(fname, &sbuf))
    toast("stat error");
  printf("file has %d bytes.\n", sbuf.st_size);
  if (sbuf.st_size <= 0)
    toast("file has zero size.\n");
  image.set_data_size(sbuf.st_size);
  FILE *f = fopen(fname, "rb");
  int num_read = fread(image.data, 1, sbuf.st_size, f);
  if (num_read != sbuf.st_size)
    toast("couldn't read entire file\n");
  printf("read %d bytes\n", num_read);
  image.compression = "jpeg";
  image.colorspace = "rgb24";
  image.width = 200;
  image.height = 153;
  ImageCodec<FlowImage> codec(&image);
  uint8_t *raster;
  if (!(raster = codec.get_raster()))
    printf("couldn't get raster\n");
  else
  {
    printf("got raster of %d bytes\n", codec.get_raster_size());
    codec.write_file("out.ppm");
    codec.write_file("out.jpg", 5);
  }

  return 0;
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:33,代码来源:get_raster.cpp


示例15: TEST

TEST(TextCodecLatin1Test, QuestionMarksAndSurrogates) {
  WTF::TextEncoding encoding("windows-1252");
  std::unique_ptr<WTF::TextCodec> codec(newTextCodec(encoding));

  {
    const LChar testCase[] = {0xd1, 0x16, 0x86};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("\xd1\x16?", result.data());
  }
  {
    const UChar testCase[] = {0xd9f0, 0xdcd9};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("?", result.data());
  }
  {
    const UChar testCase[] = {0xd9f0, 0xdcd9, 0xd9f0, 0xdcd9};
    size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
    CString result = codec->encode(testCase, testCaseSize,
                                   WTF::QuestionMarksForUnencodables);
    EXPECT_STREQ("??", result.data());
  }
}
开发者ID:mirror,项目名称:chromium,代码行数:26,代码来源:TextCodecLatin1Test.cpp


示例16: stripTrailingSpaces

bool SciDoc::save(QString& error) {
//	LOGGER;

	if ( isNoname() ) {
		error = "This is a Noname file and shouldn't be saved directly";
		return false;
	}

	if ( MainSettings::get(MainSettings::StripTrailingSpaces) )
		stripTrailingSpaces();

	bool result;
	stopWatcher();
	QFile file(fileName());
	if ( file.open(QIODevice::WriteOnly) ) {
		QString text("");
		text = int_->edit1_->text();
		file.write(codec()->fromUnicode(text));
		file.close();
//		Document::save(error);
		int_->edit1_->setModified(false);
		result = true;
	}
	else {
		error = tr("Can't open file for writing");
		result = false;
	}
	startWatcher();

	return result;
}
开发者ID:MikeTekOn,项目名称:juffed,代码行数:31,代码来源:SciDoc.cpp


示例17: DEF_TEST

DEF_TEST(BadImage, reporter) {
    const char* const badImages [] = {
        "sigabort_favicon.ico",
        "sigsegv_favicon.ico",
        "sigsegv_favicon_2.ico",
        "ico_leak01.ico",
        "ico_fuzz0.ico",
        "ico_fuzz1.ico",
        "skbug3442.webp",
        "skbug3429.webp",
    };

    const char* badImagesFolder = "invalid_images";

    for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
        SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]);
        SkAutoTDelete<SkStream> stream(GetResourceAsStream(resourcePath.c_str()));
        SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));

        // These images are corrupt.  It's not important whether we succeed/fail in codec
        // creation or decoding.  We just want to make sure that we don't crash.
        if (codec) {
            SkBitmap bm;
            bm.allocPixels(codec->getInfo());
            codec->getPixels(codec->getInfo(), bm.getPixels(),
                    bm.rowBytes());
        }
    }
}
开发者ID:aseprite,项目名称:skia,代码行数:29,代码来源:BadIcoTest.cpp


示例18: codec

TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText, QString *errorString)
{
    d->m_readResult =
        Utils::TextFileFormat::readFile(fileName, codec(),
                                        plainText, &d->m_format, errorString, &d->m_decodingErrorSample);
    return d->m_readResult;
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:7,代码来源:textfile.cpp


示例19: DEF_TEST

// SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder.
// It required the second byte to be zero. But SkImageDecoder allowed a couple
// of bits to be 1 (so long as they do not overlap with 0x9F). Test that
// SkCodec now supports an image with these bits set.
DEF_TEST(Codec_wbmp, r) {
    const char* path = "mandrill.wbmp";
    SkAutoTDelete<SkStream> stream(resource(path));
    if (!stream) {
        SkDebugf("Missing resource '%s'\n", path);
        return;
    }

    // Modify the stream to contain a second byte with some bits set.
    SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
    uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data());
    writeableData[1] = static_cast<uint8_t>(~0x9F);

    // SkImageDecoder supports this.
    SkBitmap bitmap;
    REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap));

    // So SkCodec should, too.
    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
    REPORTER_ASSERT(r, codec);
    if (!codec) {
        return;
    }
    test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr);
}
开发者ID:atyenoria,项目名称:skia,代码行数:29,代码来源:CodexTest.cpp


示例20: emulateSingleFrameBroadcastTransfer

static inline void emulateSingleFrameBroadcastTransfer(CanDriver& can, uavcan::NodeID node_id,
                                                       const MessageType& message, uavcan::TransferID tid)
{
    uavcan::StaticTransferBuffer<100> buffer;
    uavcan::BitStream bitstream(buffer);
    uavcan::ScalarCodec codec(bitstream);

    // Manual message publication
    ASSERT_LT(0, MessageType::encode(message, codec));
    ASSERT_GE(8, buffer.getMaxWritePos());

    // DataTypeID data_type_id, TransferType transfer_type, NodeID src_node_id, NodeID dst_node_id,
    // uint_fast8_t frame_index, TransferID transfer_id, bool last_frame
    uavcan::Frame frame(MessageType::DefaultDataTypeID, uavcan::TransferTypeMessageBroadcast,
                        node_id, uavcan::NodeID::Broadcast, tid);
    frame.setStartOfTransfer(true);
    frame.setEndOfTransfer(true);

    ASSERT_EQ(buffer.getMaxWritePos(), frame.setPayload(buffer.getRawPtr(), buffer.getMaxWritePos()));

    uavcan::CanFrame can_frame;
    ASSERT_TRUE(frame.compile(can_frame));

    can.pushRxToAllIfaces(can_frame);
}
开发者ID:UAVCAN,项目名称:libuavcan,代码行数:25,代码来源:helpers.hpp



注:本文中的codec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ codec_init函数代码示例发布时间:2022-05-30
下一篇:
C++ codeBlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap