#include #include #include #include int VelSelReading(Ascon *a) { int ret; char chr=0; ret = AsconReadChar(a->fd, &chr); if (chr == 0) { if (a->timeout > 0) { if (DoubleTime() - a->start > a->timeout) { AsconError(a, "read timeout", 0); } } return 0; } DynStringConcatChar(a->rdBuffer, chr); while ((ret = AsconReadChar(a->fd, &chr)) > 0) { DynStringConcatChar(a->rdBuffer, chr); } a->state = AsconReadDone; DynStringConcatChar(a->rdBuffer, '\0'); return 0; } int VelSelProtHandler(Ascon *a) { int ret; switch(a->state){ case AsconReading: return VelSelReading(a); break; default: return AsconStdHandler(a); } } void AddVelSelProtocol() { AsconProtocol *prot = NULL; prot = calloc(sizeof(AsconProtocol), 1); prot->name = strdup("astvelsel"); prot->init = AsconStdInit; prot->handler = VelSelProtHandler; AsconInsertProtocol(prot); }