update:
hab meinen ursprünglichen NXC Code jetzt soweit fü gpp portiert und entlaust, dass er (bis auf ein paar Warnings) fehlerfrei compiliert.
Ich bn mir noch unklar darüber, wo das pthread_join hinmuss, wenn man es den Tasks überlässt, dass sie bis zur Selbstterminierung laufen, um hier keine Karteileichen im Scheduler zu hinterlassen.
Ist das richtig: direkt hinter dem Aufruf von pthread im RotatePID Wrapper?
oder muss hier evtl auch noch eine zusätzliche while Abfrage dazwischen, denn der Task soll ja nicht unmittelbar nachdem er gestartet wurde schon wieder beendt/gejoint werden?Code:void RotatePID(uint8_t port, long Target, float RotatSpeed, int8_t cont) { motor[port].runstate=1; // set runstate: PID active // custom init PID [port] motor[port].target =Target; // assign target motor[port].tarpwm =RotatSpeed; // assign rotation speed motor[port].cont=cont; // cont vs. hit once // Reset PID control defaults motor[port].outp =0; // PID control output value motor[port].maxout =100; // absolute max possible output (max pwr) motor[port].read =0; // current reading motor[port].err =0; // current error motor[port].integr =0; // integral of errors motor[port].speed =0; // current speed pthread_create( & motor[port].tid, // id speichern in dem dazugehörigen Array-Element 0, // Default Attribute (threads cancelbar) PID_calc, // Name der PID-Kalkulationsroutinge (void*)port); // der Index des Array-Elements für eine PID Struktur, // die mit dem Motorindex gleich ist. pthread_join(motor[port].tid, NULL); // <<<<<<<<<<<<<<<<<< ???? }
z.B.:
while(motor[port].tid);
![]()







Zitieren

Lesezeichen