Pacp - Send Data
-
@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. -
@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) );
-
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?
-
@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?
-
@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)