--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
Olivier BARTHELEMY Software development engineer Geovariances, 49bis avenue Franklin Roosevelt - 77215 AVON CEDEX - FRANCE | www.geovariances.com |
****************** 363,368 ****--- 366,435 ---- tv.tv_usec = ctx->response_timeout.tv_usec; p_tv = &tv; }+ + /******** MODIF **************************/+ /* First loop to ignore bytes before what could be a valid master or slave number */+ while(slave_number_found == 0){+ rc = ctx->backend->select(ctx, &rfds, p_tv, 1);+ if (rc == -1) {+ _error_print(ctx, "select");+ if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) {+ int saved_errno = errno;+ + if (errno == ETIMEDOUT) {+ _sleep_and_flush(ctx);+ } else if (errno == EBADF) {+ modbus_close(ctx);+ modbus_connect(ctx);+ }+ errno = saved_errno;+ }+ return -1;+ }+ rc = ctx->backend->recv(ctx, msg, 1);+ if (rc == 0) {+ errno = ECONNRESET;+ rc = -1;+ }+ if (rc == -1) {+ _error_print(ctx, "read");+ if ((ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) &&+ (errno == ECONNRESET || errno == ECONNREFUSED ||+ errno == EBADF)) {+ int saved_errno = errno;+ modbus_close(ctx);+ modbus_connect(ctx);+ /* Could be removed by previous calls */+ errno = saved_errno;+ }+ return -1;+ }+ if(msg[0]==ctx->slave || msg[0]==0x80 || msg[0]==ctx->slave+0x80){+ //slave number found+ slave_number_found = 1;+ //1 less byte to read later+ msg_length++;+ length_to_read--;+ //The DSP sometimes returns 0x80 or 0x80+slavenumber in the first byte,+ //but this 0x80 is not counted for the crc of the frame, so replace it before CRC calculation by the slave number+ if(msg[0] >= 0x80)+ msg[0] = ctx->slave;+ if(ctx->debug)+ printf("<%.2X>", msg[0]);+ //get out of the loop+ break;+ }else{+ if (ctx->debug)+ printf("(%.2X)",msg[0]);+ }+ }+ /* if we have not exited, slave found */+ + /******** END OF MODIF **************************/ while (length_to_read != 0) { rc = ctx->backend->select(ctx, &rfds, p_tv, length_to_read);