
Zitat von
schorsch_76
Ich kann heut Abend ein kleines Sample schreiben
EDIT:
Das mit dem Subprozess kann sicher auch nach einem wegbrechen des ttys wieder starten. Wenn der tty einfach nicht mehr zu öffnen ist, dann wird auch das nichts werden.
Um das Arduino Protokol wieder zu syncen, muss halt das Protokoll "syncbar" sein. Der Arduino hat ja nichts davon mitbekommen.
Wie schaut denn das Protokoll aus?
dankeschön!
das Arduino-Prog iat hier: https://www.roboternetz.de/community...l=1#post652616
- - - Aktualisiert - - -

Zitat von
HaWe
meine grobe Idee war (der heart beat ist noch nicht ausformuliert, nur der thread kill):
Code:
void* WATCHER_thr(void*) // very high priority: thread watcher
{
while(_TASKS_ACTIVE_) {
// to do: UART_HEARTBEAT auswerten!
if (!UART_HEARTBEAT) { // delays sind nur grobe Ideen, als yield für andere threads!
pthread_kill(thread2, SIGKILL); // does not erase handle!
delay(10); // zusätzlich weitere Wartebedingung für kill?
pthread_join(thread2, NULL); // join, erase handle
delay(10);
serialClose( Serial); // close UART, fd=Serial
delay(10);
Serial = serialOpen (uart, UARTclock); // re-open Serial
delay(1);
pthread_create(&thread2, NULL, UART_thr, NULL); // restart UART by medium
param.sched_priority = 40;
pthread_setschedparam(thread2, SCHED_RR, ¶m);
delay(10);
}
delay(100); // long yield
}
return NULL;
}
// andere treads siehe Link oben!
//==================================================================
//==================================================================
int main() {
// threads
pthread_t thread0, thread1, thread2;
struct sched_param param;
printf("starting ..."); printf("\n");
// open UART Serial com port
Serial = serialOpen (uart, UARTclock);
// start multithreading
pthread_create(&thread0, NULL, WATCHER_thr, NULL); // very high priority: thread watcher
param.sched_priority = 80;
pthread_setschedparam(thread0, SCHED_RR, ¶m);
pthread_create(&thread1, NULL, KBD_thr, NULL); // low priority: keyboard monitor
param.sched_priority = 40;
pthread_setschedparam(thread1, SCHED_RR, ¶m);
pthread_create(&thread2, NULL, UART_thr, NULL); // medium priority: UART
param.sched_priority = 40;
pthread_setschedparam(thread2, SCHED_RR, ¶m);
while(_TASKS_ACTIVE_) { delay(10); }
// wait for threads to join before exiting
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
pthread_join(thread3, NULL);
serialClose( Serial);
exit(0);
}
Lesezeichen