- Reworked the connection object and the IO system

- Reworked the support for TRICS
- Added a second generation motor
This commit is contained in:
koennecke
2009-02-03 08:05:39 +00:00
parent f6d595665e
commit 361ee9ebea
119 changed files with 16455 additions and 3674 deletions

18
ascon.c
View File

@ -305,7 +305,9 @@ int AsconStdHandler(Ascon *a) {
l = GetDynStringLength(a->wrBuffer) - a->wrPos;
ret = AsconWriteChars(a->fd, GetCharArray(a->wrBuffer) + a->wrPos, l);
if (ret < 0) {
AsconError(a, "send failed:", errno);
if(errno != EINTR && errno != EAGAIN){
AsconError(a, "send failed:", errno);
}
/*
* Ooops: which state shall we go to after a write fail?
* This seems to retry.
@ -352,7 +354,10 @@ int AsconStdHandler(Ascon *a) {
ret = AsconReadChar(a->fd, &chr);
}
if (ret < 0) {
AsconError(a, "AsconReadChar failed:", errno);
/* EINTR means we shall retry */
if(errno != EINTR && errno != EAGAIN){
AsconError(a, "AsconReadChar failed:", errno);
}
return 1;
}
if (a->state == AsconReadDone) {
@ -453,6 +458,13 @@ void AsconKill(Ascon *a) {
}
free(a);
}
void AsconDisconnect(Ascon *a){
if(a->fd > 0){
close(a->fd);
}
a->fd = -1;
a->state = AsconConnectStart;
}
AsconStatus AsconTask(Ascon *a) {
double now;
@ -491,6 +503,8 @@ AsconStatus AsconTask(Ascon *a) {
if (now > a->lastReconnect + a->reconnectInterval) {
a->lastReconnect = now;
close(a->fd);
/* allow the system to cleanup the socket, otherwise a reconnect will fail*/
sleep(1);
a->fd = -1;
a->state = AsconConnectStart;
}