Cannot send TRDP MD and PD messages

I am developing a TRDP based communication. I am using the TRDP project as a library in a QT project and it’s tested that it works. The idea is to init an object of class Trdp and call the methods sendPDMessage or sendMDMessage depending on the usage. But I do not receive any packets on the other side. Using Wireshark, I do not see any packets from the TRDP. If someone can help debugging this and finding the problem, I will be thankful!

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#include "trdp.h"
Trdp::Trdp ( QObject * parent ) : QObject ( parent ) {
ip[0] = 127;
ip[1] = 0;
ip[2] = 0;
ip[3] = 1;
comId = PD_COMID;
this->pubHandle = NULL;
mdConfiguration = {
NULL,
NULL,
{3, 64, 2},
TRDP_FLAGS_NONE,
1000000u,
1000000u,
1000000u,
1000000u,
17225u,
0,
5u,
};
pdConfiguration = {
NULL,
NULL,
TRDP_PD_DEFAULT_SEND_PARAM,
TRDP_FLAGS_NONE,
1000000u,
TRDP_TO_SET_TO_ZERO,
0u,
};
dynamicConfig = { NULL, RESERVED_MEMORY, { 0 } };
processConfig = {
"Me",
"",
"",
TRDP_PROCESS_DEFAULT_CYCLE_TIME,
0,
TRDP_OPTION_NONE
};
ownIP = vos_dottedIP("127.0.0.1");
dstIP = vos_dottedIP("127.0.0.1");
rv = 0;
if ( tlc_init ( &this->dbgOut, NULL, &dynamicConfig ) != TRDP_NO_ERR )
{
qDebug ( ) << "Init error!";
}
if ( tlc_openSession ( &appHandle,
ownIP,
0,
NULL,
&pdConfiguration,
&mdConfiguration,
&processConfig ) != TRDP_NO_ERR )
{
qDebug ( ) << "Init error! 2";
}
memset ( trdpBuffer, 0, sizeof ( trdpBuffer ) );
}
void Trdp::dbgOut (
void *pRefCon,
TRDP_LOG_T category,
const CHAR8 *pTime,
const CHAR8 *pFile,
UINT16 LineNumber,
const CHAR8 *pMsgStr)
{ }
// Add this method to initialize a publisher for PD messages
void Trdp::initPDPublisher() {
TRDP_PUB_T pubHandle = NULL;
TRDP_ERR_T err = tlp_publish(
this->appHandle, // Application session handle
&pubHandle, // Publisher handle to be initialized
NULL, // User reference
NULL, // Callback function for receiving data (not needed for publishing)
0, // Service ID (0 for default)
comId, // Communication ID
0, // etbTopoCnt (0 for default)
0, // etbConfigCnt (0 for default)
ownIP, // Source IP address
dstIP, // Destination IP address
1000000u, // Interval
0u, // Packet time-to-live
TRDP_FLAGS_NONE, // Flags
NULL, // Marshalling function
NULL, // Data pointer (NULL for initialization)
0 // Data size (0 for initialization)
);
if (err != TRDP_NO_ERR) {
qDebug() << "Error initializing PD publisher: " << err;
} else {
this->pubHandle = pubHandle; // Store the initialized pubHandle for later use
qDebug() << "PD Publisher initialized successfully.";
}
}
TRDP_ERR_T Trdp::sendPDMessage(const void *pData, UINT32 dataSize) {
qDebug() << "Sending PD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize;
const UINT8* data = reinterpret_cast<const UINT8 *>(pData);
// Ensure pubHandle is initialized; call initPDPublisher() before this if not already done
if (this->pubHandle == NULL) {
qDebug() << "Publisher not initialized. Initializing now.";
initPDPublisher();
if (this->pubHandle == NULL) {
qDebug() << "Failed to initialize publisher. Cannot send PD message.";
return TRDP_INIT_ERR;
}
}
TRDP_ERR_T err = tlp_put(
this->appHandle, // Use class member appHandle
this->pubHandle, // Use the initialized publisher handle
data, // Data to send
dataSize // Size of the data to send
);
if (err != TRDP_NO_ERR) {
qDebug() << "Error sending PD message: " << err;
}
return err;
}
// Method for sending MD messages
TRDP_ERR_T Trdp::sendMDMessage(const void *pData, UINT32 dataSize) {
qDebug() << "Sending MD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize;
const UINT8* data = reinterpret_cast<const UINT8 *>(pData);
TRDP_ERR_T err = tlm_request(
this->appHandle, // Application session handle
NULL, // Message handle (NULL for auto)
NULL, // User reference
NULL, // Callback function (NULL for no callback)
1, // Service ID (1 for default)
PD_COMID + 1, // ComId (0 for default)
0, // etbTopoCnt (0 for default)
0, // etbConfigCnt (0 for default)
vos_dottedIP("127.0.0.1"), // Destination IP address
TRDP_FLAGS_DEFAULT, // Flags
0, // Priority (0 for default)
1000000u, // Timeout (in microseconds)
NULL, // Marshalling function
data, // Data pointer
dataSize, // Data size
NULL, // Response timeout (NULL for no response)
NULL // Response callback (NULL for no callback)
);
if (err != TRDP_NO_ERR) {
qDebug() << "Error sending MD message: " << err;
} else {
qDebug() << "MD message sent successfully.";
}
return err;
}
</code>
<code>#include "trdp.h" Trdp::Trdp ( QObject * parent ) : QObject ( parent ) { ip[0] = 127; ip[1] = 0; ip[2] = 0; ip[3] = 1; comId = PD_COMID; this->pubHandle = NULL; mdConfiguration = { NULL, NULL, {3, 64, 2}, TRDP_FLAGS_NONE, 1000000u, 1000000u, 1000000u, 1000000u, 17225u, 0, 5u, }; pdConfiguration = { NULL, NULL, TRDP_PD_DEFAULT_SEND_PARAM, TRDP_FLAGS_NONE, 1000000u, TRDP_TO_SET_TO_ZERO, 0u, }; dynamicConfig = { NULL, RESERVED_MEMORY, { 0 } }; processConfig = { "Me", "", "", TRDP_PROCESS_DEFAULT_CYCLE_TIME, 0, TRDP_OPTION_NONE }; ownIP = vos_dottedIP("127.0.0.1"); dstIP = vos_dottedIP("127.0.0.1"); rv = 0; if ( tlc_init ( &this->dbgOut, NULL, &dynamicConfig ) != TRDP_NO_ERR ) { qDebug ( ) << "Init error!"; } if ( tlc_openSession ( &appHandle, ownIP, 0, NULL, &pdConfiguration, &mdConfiguration, &processConfig ) != TRDP_NO_ERR ) { qDebug ( ) << "Init error! 2"; } memset ( trdpBuffer, 0, sizeof ( trdpBuffer ) ); } void Trdp::dbgOut ( void *pRefCon, TRDP_LOG_T category, const CHAR8 *pTime, const CHAR8 *pFile, UINT16 LineNumber, const CHAR8 *pMsgStr) { } // Add this method to initialize a publisher for PD messages void Trdp::initPDPublisher() { TRDP_PUB_T pubHandle = NULL; TRDP_ERR_T err = tlp_publish( this->appHandle, // Application session handle &pubHandle, // Publisher handle to be initialized NULL, // User reference NULL, // Callback function for receiving data (not needed for publishing) 0, // Service ID (0 for default) comId, // Communication ID 0, // etbTopoCnt (0 for default) 0, // etbConfigCnt (0 for default) ownIP, // Source IP address dstIP, // Destination IP address 1000000u, // Interval 0u, // Packet time-to-live TRDP_FLAGS_NONE, // Flags NULL, // Marshalling function NULL, // Data pointer (NULL for initialization) 0 // Data size (0 for initialization) ); if (err != TRDP_NO_ERR) { qDebug() << "Error initializing PD publisher: " << err; } else { this->pubHandle = pubHandle; // Store the initialized pubHandle for later use qDebug() << "PD Publisher initialized successfully."; } } TRDP_ERR_T Trdp::sendPDMessage(const void *pData, UINT32 dataSize) { qDebug() << "Sending PD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize; const UINT8* data = reinterpret_cast<const UINT8 *>(pData); // Ensure pubHandle is initialized; call initPDPublisher() before this if not already done if (this->pubHandle == NULL) { qDebug() << "Publisher not initialized. Initializing now."; initPDPublisher(); if (this->pubHandle == NULL) { qDebug() << "Failed to initialize publisher. Cannot send PD message."; return TRDP_INIT_ERR; } } TRDP_ERR_T err = tlp_put( this->appHandle, // Use class member appHandle this->pubHandle, // Use the initialized publisher handle data, // Data to send dataSize // Size of the data to send ); if (err != TRDP_NO_ERR) { qDebug() << "Error sending PD message: " << err; } return err; } // Method for sending MD messages TRDP_ERR_T Trdp::sendMDMessage(const void *pData, UINT32 dataSize) { qDebug() << "Sending MD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize; const UINT8* data = reinterpret_cast<const UINT8 *>(pData); TRDP_ERR_T err = tlm_request( this->appHandle, // Application session handle NULL, // Message handle (NULL for auto) NULL, // User reference NULL, // Callback function (NULL for no callback) 1, // Service ID (1 for default) PD_COMID + 1, // ComId (0 for default) 0, // etbTopoCnt (0 for default) 0, // etbConfigCnt (0 for default) vos_dottedIP("127.0.0.1"), // Destination IP address TRDP_FLAGS_DEFAULT, // Flags 0, // Priority (0 for default) 1000000u, // Timeout (in microseconds) NULL, // Marshalling function data, // Data pointer dataSize, // Data size NULL, // Response timeout (NULL for no response) NULL // Response callback (NULL for no callback) ); if (err != TRDP_NO_ERR) { qDebug() << "Error sending MD message: " << err; } else { qDebug() << "MD message sent successfully."; } return err; } </code>
#include "trdp.h"

Trdp::Trdp ( QObject * parent ) : QObject ( parent ) {
    ip[0] = 127;
    ip[1] = 0;
    ip[2] = 0;
    ip[3] = 1;
    comId = PD_COMID;
    this->pubHandle = NULL;

    mdConfiguration = {
        NULL, 
        NULL, 
        {3, 64, 2},
        TRDP_FLAGS_NONE,
        1000000u, 
        1000000u, 
        1000000u, 
        1000000u,  
        17225u, 
        0, 
        5u,
    };

    pdConfiguration = {
        NULL, 
        NULL,
        TRDP_PD_DEFAULT_SEND_PARAM, 
        TRDP_FLAGS_NONE,
        1000000u,
        TRDP_TO_SET_TO_ZERO,
        0u,
    };

    dynamicConfig = { NULL, RESERVED_MEMORY, { 0 } };
    processConfig = {
        "Me", 
        "",
        "",
        TRDP_PROCESS_DEFAULT_CYCLE_TIME, 
        0,
        TRDP_OPTION_NONE
    };
    ownIP = vos_dottedIP("127.0.0.1");
    dstIP = vos_dottedIP("127.0.0.1");
    rv = 0;

    if ( tlc_init ( &this->dbgOut, NULL, &dynamicConfig ) != TRDP_NO_ERR )
    {
        qDebug (  ) << "Init error!"; 
    }

    if ( tlc_openSession ( &appHandle,
                            ownIP,
                            0,
                            NULL,
                            &pdConfiguration,
                            &mdConfiguration,
                            &processConfig ) != TRDP_NO_ERR )
    {
        qDebug (  ) << "Init error! 2";
    }

    memset ( trdpBuffer, 0, sizeof ( trdpBuffer ) );
}

void Trdp::dbgOut (
    void        *pRefCon,
    TRDP_LOG_T  category,
    const CHAR8 *pTime,
    const CHAR8 *pFile,
    UINT16      LineNumber,
    const CHAR8 *pMsgStr)
{  }

// Add this method to initialize a publisher for PD messages
void Trdp::initPDPublisher() {
    TRDP_PUB_T pubHandle = NULL;
    TRDP_ERR_T err = tlp_publish(
        this->appHandle,    // Application session handle
        &pubHandle,         // Publisher handle to be initialized
        NULL,               // User reference
        NULL,               // Callback function for receiving data (not needed for publishing)
        0,                  // Service ID (0 for default) 
        comId,              // Communication ID
        0,                  // etbTopoCnt (0 for default)
        0,                  // etbConfigCnt (0 for default)
        ownIP,              // Source IP address
        dstIP,              // Destination IP address
        1000000u,           // Interval
        0u,                 // Packet time-to-live
        TRDP_FLAGS_NONE,    // Flags
        NULL,               // Marshalling function
        NULL,               // Data pointer (NULL for initialization)
        0                   // Data size (0 for initialization)
    );

    if (err != TRDP_NO_ERR) {
        qDebug() << "Error initializing PD publisher: " << err;
    } else {
        this->pubHandle = pubHandle; // Store the initialized pubHandle for later use
        qDebug() << "PD Publisher initialized successfully.";
    }
}


TRDP_ERR_T Trdp::sendPDMessage(const void *pData, UINT32 dataSize) {
    qDebug() << "Sending PD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize;
    const UINT8* data = reinterpret_cast<const UINT8 *>(pData);
    
    // Ensure pubHandle is initialized; call initPDPublisher() before this if not already done
    if (this->pubHandle == NULL) {
        qDebug() << "Publisher not initialized. Initializing now.";
        initPDPublisher();
        if (this->pubHandle == NULL) {
            qDebug() << "Failed to initialize publisher. Cannot send PD message.";
            return TRDP_INIT_ERR;
        }
    }

    TRDP_ERR_T err = tlp_put(
        this->appHandle,    // Use class member appHandle
        this->pubHandle,    // Use the initialized publisher handle
        data,               // Data to send
        dataSize            // Size of the data to send
    );

    if (err != TRDP_NO_ERR) {
        qDebug() << "Error sending PD message: " << err;
    }

    return err;
}

// Method for sending MD messages
TRDP_ERR_T Trdp::sendMDMessage(const void *pData, UINT32 dataSize) {
    qDebug() << "Sending MD message" << reinterpret_cast<const UINT8 *>(pData) << "with size" << dataSize;
    const UINT8* data = reinterpret_cast<const UINT8 *>(pData);

    TRDP_ERR_T err = tlm_request(
        this->appHandle,    // Application session handle
        NULL,               // Message handle (NULL for auto)
        NULL,               // User reference
        NULL,               // Callback function (NULL for no callback)
        1,                  // Service ID (1 for default)
        PD_COMID + 1,                  // ComId (0 for default)
        0,                  // etbTopoCnt (0 for default)
        0,                  // etbConfigCnt (0 for default)
        vos_dottedIP("127.0.0.1"), // Destination IP address
        TRDP_FLAGS_DEFAULT, // Flags
        0,                  // Priority (0 for default)
        1000000u,           // Timeout (in microseconds)
        NULL,               // Marshalling function
        data,               // Data pointer
        dataSize,           // Data size
        NULL,               // Response timeout (NULL for no response)
        NULL                // Response callback (NULL for no callback)
    );

    if (err != TRDP_NO_ERR) {
        qDebug() << "Error sending MD message: " << err;
    } else {
        qDebug() << "MD message sent successfully.";
    }

    return err;
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật