53 int handle =
dll_->tx(frame);
56 return dll_->rx(frame, handle);
61 return dll_->txandrx(frame);
73 pthread_mutexattr_t mutex_attr;
74 int error = pthread_mutexattr_init(&mutex_attr);
76 fprintf(stderr,
"%s : Initializing mutex attr failed : %d\n", __func__, error);
79 error = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK_NP);
81 fprintf(stderr,
"%s : Setting type of mutex attr failed : %d\n", __func__, error);
84 error = pthread_mutex_init(&
mutex_, &mutex_attr);
86 fprintf(stderr,
"%s : Initializing mutex failed : %d\n", __func__, error);
91 fprintf(stderr,
"%s : Initializing share condition failed : %d\n", __func__, error);
96 fprintf(stderr,
"%s : Initializing busy condition failed : %d\n", __func__, error);
110 if (0 != (error = pthread_mutex_lock(&
mutex_))) {
111 fprintf(stderr,
"%s : lock %d at %d\n", __func__, error, line);
121 if (0 != (error = pthread_mutex_trylock(&
mutex_))) {
122 if (error != EBUSY) {
123 fprintf(stderr,
"%s : lock %d at %d\n", __func__, error, line);
135 if (0 != (error = pthread_mutex_unlock(&
mutex_))) {
136 fprintf(stderr,
"%s : unlock %d at %d\n", __func__, error, line);
148 assert(frame != NULL);
166 bool success =
false;
184 static const unsigned MAX_TRIES=10;
185 for (
unsigned tries=0; tries<MAX_TRIES; ++tries) {
bool trylock(unsigned line)
EthercatDirectCom(EtherCAT_DataLinkLayer *dll)
bool txandrx_once(struct EtherCAT_Frame *frame)
EtherCAT_DataLinkLayer * dll_
bool txandrx(struct EtherCAT_Frame *frame)
pthread_cond_t busy_cond_
EthercatOobCom(struct netif *ni)
pthread_cond_t share_cond_
enum EthercatOobCom::@1 state_
bool unlock(unsigned line)
bool txandrx(struct EtherCAT_Frame *frame)
bool txandrx_once(struct EtherCAT_Frame *frame)