Search Results

Search found 5 results on 1 pages for 'user269037'.

Page 1/1 | 1 

  • Is there a way to receive receive data as unsugned char over UDP on QT

    - by user269037
    I need to send floating point numbers using UDP connection to a QT application. Now in QT the only function available is qint64 readDatagram ( char * data, qint64 maxSize, QHostAddress * address = 0, quint16 * port = 0 ) which accepts data in the form of signed character buffer. I can convert my float into a string and send it but it will obviously not be very efficient converting a 4 byte float into a much longer sized character buffer. I got hold of these 2 functions to convert a 4 byte float into an unsinged 32 bit integer to transfer over network which works fine for a simple c++ udp program but for QT I need to receive the data as unsigned char. Is it possible to avoid converting the floatinf point data into a string and then sending it ?? uint32_t htonf(float f) { uint32_t p; uint32_t sign; if (f < 0) { sign = 1; f = -f; } else { sign = 0; } p = ((((uint32_t)f)&0x7fff)<<16) | (sign<<31); // whole part and sign p |= (uint32_t)(((f - (int)f) * 65536.0f))&0xffff; // fraction return p; } float ntohf(uint32_t p) { float f = ((p16)&0x7fff); // whole part f += (p&0xffff) / 65536.0f; // fraction if (((p>>31)&0x1) == 0x1) { f = -f; } // sign bit set return f; }

    Read the article

  • wats SIGSEGV, Segmentation fault in QT

    - by user269037
    I have a QT program which displays the data it receives over UDP. It works fine for around 30 seconds but after a while it gives Segmentation Fault and crashes. This 30 seconds is also not fixed. I used the debugger and got this Program received signal SIGSEGV, Segmentation fault. 0x003c6fd4 in ?? () from /usr/lib/libQtGui.so.4 Can anyone tell me where the error might be

    Read the article

  • Is there a way to receive data as unsigned char over UDP on Qt?

    - by user269037
    I need to send floating point numbers using a UDP connection to a Qt application. Now in Qt the only function available is qint64 readDatagram ( char * data, qint64 maxSize, QHostAddress * address = 0, quint16 * port = 0 ) which accepts data in the form of signed character buffer. I can convert my float into a string and send it but it will obviously not be very efficient converting a 4 byte float into a much longer sized character buffer. I got hold of these 2 functions to convert a 4 byte float into an unsinged 32 bit integer to transfer over network which works fine for a simple C++ UDP program but for Qt I need to receive the data as unsigned char. Is it possible to avoid converting the floatinf point data into a string and then sending it? uint32_t htonf(float f) { uint32_t p; uint32_t sign; if (f < 0) { sign = 1; f = -f; } else { sign = 0; } p = ((((uint32_t)f)&0x7fff)<<16) | (sign<<31); // Whole part and sign. p |= (uint32_t)(((f - (int)f) * 65536.0f))&0xffff; // Fraction. return p; } float ntohf(uint32_t p) { float f = ((p>>16)&0x7fff); // Whole part. f += (p&0xffff) / 65536.0f; // Fraction. if (((p>>31)&0x1) == 0x1) { f = -f; } // Sign bit set. return f; }

    Read the article

  • Header files in C++

    - by user269037
    Hi, I am making a simulator and have written lots of files and headers. The problem is whenever I include a file I give the relative path of the particular file. For example a typical code in my application would begin like ifndef AI_H define AI_H include include "../world/world.h" include "pathPlan.h" include "skills/tryskill.h" include "../info/condition.h" include "dataStructures/destination.h" include "../params/gamePlay.h" include "../modules/controlModule.h" class ai { public: etc etc I want to avoid using the relative paths. For example I want to directly include "tryskill.h" and "destination.h" without giving the absolute paths. That way I wont need to bother if I change the location of any particular file. I am using Ubuntu 9.10. Any help would be highly appreciated.

    Read the article

  • How can I avoid explicitly declaring directory paths in C or C++ #include directives?

    - by user269037
    Hi, I am making a simulator and have written lots of files and headers. The problem is whenever I include a file I give the relative path of the particular file. For example a typical code in my application would begin like #ifndef AI_H #define AI_H #include <cstdlib> #include "../world/world.h" #include "pathPlan.h" #include "skills/tryskill.h" #include "../info/condition.h" #include "dataStructures/destination.h" #include "../params/gamePlay.h" #include "../modules/controlModule.h" class ai { public: etc etc I want to avoid using the relative paths. For example I want to directly include "tryskill.h" and "destination.h" without giving the absolute paths. That way I wont need to bother if I change the location of any particular file. I am using Ubuntu 9.10. Any help would be highly appreciated.

    Read the article

1