Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pacp - Send Data
Forum Updated to NodeBB v4.3 + New Features

Pacp - Send Data

Scheduled Pinned Locked Moved Unsolved General and Desktop
pcapc++ qt
12 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @neda said in Pacp - Send Data:

    fprintf( stderr,"\nError sending the packet: \n", pcap_geterr( adhandle ));

    What does this line print out?
    And I'm not sure what this has to do with Qt.

    N Offline
    N Offline
    neda
    wrote on last edited by neda
    #3

    @jsulm said in Pacp - Send Data:

    What does this line print out?

    PacketSendPacket failed

    And I'm not sure what this has to do with Qt.

    I did not find a document or a good sample to use "pcap" in Qt.

    mrjjM 1 Reply Last reply
    0
    • N neda

      @jsulm said in Pacp - Send Data:

      What does this line print out?

      PacketSendPacket failed

      And I'm not sure what this has to do with Qt.

      I did not find a document or a good sample to use "pcap" in Qt.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @neda
      Hi
      And you did install winpcap/Win10Pcap so the driver is running?
      Also, you are using visual studio compiler ?
      Im not sure it works with mingw.

      N 1 Reply Last reply
      0
      • mrjjM mrjj

        @neda
        Hi
        And you did install winpcap/Win10Pcap so the driver is running?
        Also, you are using visual studio compiler ?
        Im not sure it works with mingw.

        N Offline
        N Offline
        neda
        wrote on last edited by neda
        #5

        @mrjj said in Pacp - Send Data:

        Also, you are using visual studio compiler ?

        Qt 5.12.5 MSVC2017 32bit

        And you did install winpcap/Win10Pcap so the driver is running?

        I installed "http://www.win10pcap.org/download/Win10Pcap-v10.2-5002.msi".

        Now "pcap_sendpacket" return 0, It's OK.
        But I do not have a correct answer from the device.

        I have a "QByteArray" Data for send such as:

        "\x02\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        

        I don't know this code is true or not.

        void PCAPNetwork::sendData(const QByteArray &data)
        {
        const u_char* p= reinterpret_cast<const uchar *>(data.constData());
        //std::memcpy(&p,data.constData(),data.size());
        pcap_sendpacket(adhandle, 
                                                p, 
                                                sizeof(p)
                                                );
        
        mrjjM 1 Reply Last reply
        0
        • N neda

          @mrjj said in Pacp - Send Data:

          Also, you are using visual studio compiler ?

          Qt 5.12.5 MSVC2017 32bit

          And you did install winpcap/Win10Pcap so the driver is running?

          I installed "http://www.win10pcap.org/download/Win10Pcap-v10.2-5002.msi".

          Now "pcap_sendpacket" return 0, It's OK.
          But I do not have a correct answer from the device.

          I have a "QByteArray" Data for send such as:

          "\x02\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
          

          I don't know this code is true or not.

          void PCAPNetwork::sendData(const QByteArray &data)
          {
          const u_char* p= reinterpret_cast<const uchar *>(data.constData());
          //std::memcpy(&p,data.constData(),data.size());
          pcap_sendpacket(adhandle, 
                                                  p, 
                                                  sizeof(p)
                                                  );
          
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @neda
          Hi
          from a quick glance - it looks ok.
          Should not truncate values.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            neda
            wrote on last edited by neda
            #7

            I think I was wrong in reading data.
            The device sends a lot of data in real-time.
            I read them by this code.

            void PCAPNetwork::packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
            {
            

            How can I convert "pkt_data" to decimal?

            mrjjM 1 Reply Last reply
            0
            • N neda

              I think I was wrong in reading data.
              The device sends a lot of data in real-time.
              I read them by this code.

              void PCAPNetwork::packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
              {
              

              How can I convert "pkt_data" to decimal?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @neda said in Pacp - Send Data:

              u_char

              But is this not a byte already ?

              If you place cursor on u_char and press F2, what is it then defined as?

              N 1 Reply Last reply
              0
              • mrjjM mrjj

                @neda said in Pacp - Send Data:

                u_char

                But is this not a byte already ?

                If you place cursor on u_char and press F2, what is it then defined as?

                N Offline
                N Offline
                neda
                wrote on last edited by
                #9

                @mrjj

                u_char = unsigned char

                qDebug()<<"data: "<<pkt_data;
                

                output:

                data:  0x46c16bc
                

                I don't know how can I convert it to decimal.

                mrjjM 1 Reply Last reply
                0
                • N neda

                  @mrjj

                  u_char = unsigned char

                  qDebug()<<"data: "<<pkt_data;
                  

                  output:

                  data:  0x46c16bc
                  

                  I don't know how can I convert it to decimal.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #10

                  @neda
                  Is it zero terminated ?

                  That is the address it writes out. Not the actual data i think.

                  You can convert it to bytearray
                  QByteArray databuf = QByteArray(reinterpret_cast<char*>(pkt_data), header->len);
                  (i think but not 100% sure header->len is data len. check docs)

                  N 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @neda
                    Is it zero terminated ?

                    That is the address it writes out. Not the actual data i think.

                    You can convert it to bytearray
                    QByteArray databuf = QByteArray(reinterpret_cast<char*>(pkt_data), header->len);
                    (i think but not 100% sure header->len is data len. check docs)

                    N Offline
                    N Offline
                    neda
                    wrote on last edited by
                    #11

                    @mrjj said in Pacp - Send Data:

                    Not the actual data i think.

                    You right.
                    The device sends a lot of data in real-time.
                    How can I read the actual data?

                    mrjjM 1 Reply Last reply
                    0
                    • N neda

                      @mrjj said in Pacp - Send Data:

                      Not the actual data i think.

                      You right.
                      The device sends a lot of data in real-time.
                      How can I read the actual data?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @neda
                      The data is in pkt_data as far as i can see from docs
                      so try
                      QByteArray databuf = QByteArray(reinterpret_cast<char*>(pkt_data), header->len);
                      qDebug()<<"data: "<<databuf ;

                      1 Reply Last reply
                      3

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved