Floating

Member
  • Content count

    390
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Floating

  • Rank
    Member
  1. Thanks again Outrider for taking the time to answer. I use the multimedia timer in a little different manner: 1. I arm the timer to fire in x ms 2. When inside the callback (x ms later) I write a request to the serial port and read it directly after (with a timeout of 15 ms) 3. The microcontroller checks the serial port every 10ms. When it got a request, it replies directly with some data 4. The PC receives the data on the serial port and rearms the callback to fire in x ms. 5. we are back at point 2. Timing is performed by the microcontroller which will respond only once every 10ms. x has to be choosen small enough (now typically 2ms). The multimedia timer isn't making the timing, I just use it because I first thought my timing was bad because of the Sleep I used in my previous routine (which was a thread with PRIORITY_TIME_CRITICAL): 1. I write a request on the serial port 2. I read data on the serial port with a timeout of 15 ms 3. I sleep x ms (x=2) 4. I go to point 1 Both above routines give me bad timings at start-up and when the media player is running for instance. If I skip point 1 and 2 in above routine, my timing is perfect! (+- 1ms perfect). So I concluded the bottleneck is the serial port. Is that reasoning wrong? Marc
  2. Thanks for your quick reply. My application runs under Windows XP Embedded with EWF enabled (caching disk accesses to ram). The application is a console application programmed in C++. I use a serial communication class called CSerial from Ramon de Klein. Operation is asynchronous. I perform a write operation followed by a read operation in a callback routine from a multimedia timer. The timer is armed for a one-shot callback and is rearmed appropriately once a reply was obtained from the microcontroller. The multimedia timer has a very good timing, the only bottleneck seems to be the serial port. Can some priority be set for the port? The delay happens just after boot-up for a few seconds (delay for up to 1 second sometimes), then becomes less frequent. When I run Window mediaplayer the delay becomes much more frequent. EDIT: before using a multimedia timer for my write/read routine, I used a normal thread with the Sleep instruction. Setting the priority to "TIME_CRITICAL" did not change a lot, I still had similar delays. The problem really seems to be linked to the serial port.
  3. Hi I am working on an application that communicates with a microcontroller through serial communication. The PC send a request to the microcontroller which responds within 10 ms. When the response has arrived, the PC sends another request and so on. Communication goes back and forth every 10ms. For some reasons, it seems that reading (or maybe sending data off) the com-port gets delayed some times (especially just after boot-up) and my timings are lost. What could be the reason? Thanks
  4. Regular timings with Sleep?

    Hi Again, I just tried to use a multimedia timer to get what I want: I arm a timer event for a one-shot callback, inside the callback I get synchronized with the microcontroller then re-arm the timer event with a duration that is smaller than: (period duration on microcontroller) - (time the callback needed to execute) - (some margin) I get what I want but I still have my original problem: not regular timings shortly after boot-up! (however the timings are a little bit better than before) What else can I try?
  5. Regular timings with Sleep?

    Thanks for your reply, The time period with Sleep(1) is mostly around 1ms, except at start-up (I checked). Also I can't really use a periodic multimedia timer since my thread gets synchronized by an external microcontroller which main loop is at 10 ms. Every 10 ms there is a data exchange through RS-232.
  6. Hello, I have an application that runs several threads, one of which needs to be "visited" at least once every 10 ms. I set the task-swapping resolution to 1ms with following command: timeBeginPeriod(1); Once the thread was visited it goes to sleep for 1ms at a time until approximately 10ms passed. That works fine only if the application is run about 2 minutes after boot-up. If not, the thread gets sometimes more than 1 second no processing time!! How can I guarantee my thread to be "visited" at least once every 10 ms even shortly after boot-up? Thanks EDIT: I forgot to precise that I tried giving higher priorities to my thread, however even with priority "TIME_CRITICAL" I still get about 50ms of no visiting time shortly after boot-up!
  7. sizeof(Class)

    Thanks. I see. So will the table always be allocated at the beginning of the object?
  8. sizeof(Class)

    Thanks for your reply! Yes it is!! How come?
  9. Hello, For following Class, I was very surprised to get a sizeof(C4Vector) of 20. I was expecting 16. Where are the additional 4 bytes allocated?? I can only see the float data[4] class C4Vector { public: //------------------- Construction/destruction --------------- C4Vector(); C4Vector(float v0,float v1,float v2,float v3); C4Vector(float v[4]); C4Vector(const C3Vector& v); C4Vector(const C4Vector& q); C4Vector(float a,float b,float g); C4Vector(float angle,const C3Vector& axis); C4Vector(const C3Vector& startV,const C3Vector& endV); virtual ~C4Vector(); //------------------------------------------------------------ //------------------- Various functions ---------------------- // void serialize(CSer& ar); void clear(); void setIdentity(); void setEulerAngles(const C3Vector& v); void setEulerAngles(float a,float b,float g); void setAngleAndAxis(float angle,const C3Vector& axis); void setVectorMapping(const C3Vector& startV,const C3Vector& endV); void buildInterpolation(const C4Vector& fromThis,const C4Vector& toThat,float t); C4Vector getAngleAndAxis() const; C3Vector getEulerAngles() const; C4Vector getInverse() const; void inverse(); C3X3Matrix getMatrix() const; void normalize(); C3Vector getAxis(int index) const; //------------------------------------------------------------ //------------------- Operator overloading ------------------- C4Vector operator/ (float d) const; C4Vector operator* (float d) const; C4Vector operator+ (const C4Vector& v) const; C4Vector operator* (const C4Vector& v) const; void operator/= (float d); void operator*= (float d); void operator+= (const C4Vector& v); void operator*= (const C4Vector& v); float& operator() (unsigned i); const float& operator() (unsigned i) const; C4Vector& operator= (const C4Vector& v); C3Vector operator* (const C3Vector& v) const; // Rotation of a vector //------------------------------------------------------------ //------------------- Private variables ---------------------- private: float data[4]; //------------------------------------------------------------ }; //------------------- Inlined functions ---------------------- inline float& C4Vector::operator() (unsigned i) { SIM_ASSERT(i<4); return(data[i]); } inline const float& C4Vector::operator() (unsigned i) const { SIM_ASSERT(i<4); return(data[i]); }
  10. Quote:Original post by Colin Jeanne If the code from the thread1 function is being run then you're in that first thread. If the code from the thread2 function is being run then you're in the second thread. That's really all you have to go by - if you're not in that function then you're not in that thread. Yes, but what if both threads call a common function?? Then from within that function I can't know which thread called it! Thanks LessBread, that's what I was looking for :)
  11. Commenting Style

    Quote:Original post by supagu using /* */ is evil! a true story: one day i was getting a crash in the SDL library, so i d'led the source, compiled it and got it working, with the crash still. So i had to find the bug, which could have been any where, so the only way to isolate the problem was to comment out blocks of code. now when every line, and every function has a /* */ style comment, and you want to use do do a /* */ to comment out slabs of code, your life becomes hell! it took me many hours to remove thier comments. Eventually found the problem and vouewd only to use /* */ for commenting out blocks temporary! Same here. And what I do quite often with code blocks that need to be commented in/out often: /* code... //*/ By doing so I don't need to add/remove the closing */ at the end. That is particularly useful when the code block to be commented out is long.
  12. Hi, How can I find out about which thread I am currently in? I start my threads like: AfxBeginThread(thread1,NULL,THREAD_PRIORITY_NORMAL); AfxBeginThread(thread2,NULL,THREAD_PRIORITY_NORMAL); Is there some global variable that I could maybe check? Or some function that I can call? Thanks
  13. Array of vectors

    Thank you all for your replies :)
  14. Hi, I need to build an array of vectors and I did as follow: std::vector<float> myArray[5]; Is this way of doing ok or do I need to construct each vector individually like: std::vector<float>* myArray[5]; for (int i=0;i<5;i++) myArray[i]=new std::vector<float>; I have been using the first way of doing but get some weird effect sometimes. Or to put the question in another way: does the first instruction create 5 instances of vectors or just reserves the space for them? Can someone enlighten me? Thanks
  15. OpenGL Two windows with OpenGL

    Thank you for your replies. Sorry about not giving enough information about my problem. It is as following: I am not using display lists and notinh is displayed in my windows. The windows appear and behave correctly, but the content is never displayed nor actualized (it's like empty frames where the content is what was displayed on the screen before the windows were created). First off, when I create only one window following two lines work fine: if (wglGetCurrentContext()==NULL) wglMakeCurrent(hDC,hRC); But following doesn't work: wglMakeCurrent(hDC,hRC); How is that? And if I have two windows, how should I handle that piece of code?