master/fsm_coe.c
changeset 1931 831f2d34664c
parent 1923 712d04506f12
child 1948 fa1c4fb0a8da
equal deleted inserted replaced
1930:59a50053ccc6 1931:831f2d34664c
  1223 
  1223 
  1224     if (datagram->working_counter != 1) {
  1224     if (datagram->working_counter != 1) {
  1225         if (!datagram->working_counter) {
  1225         if (!datagram->working_counter) {
  1226             if (diff_ms < fsm->request->response_timeout) {
  1226             if (diff_ms < fsm->request->response_timeout) {
  1227 #if DEBUG_RETRIES
  1227 #if DEBUG_RETRIES
  1228                 EC_SLAVE_DBG(slave, 1, "Slave did not respond to"
  1228                 EC_SLAVE_DBG(slave, 1, "Slave did not respond to SDO"
  1229                         " SDO download request. Retrying after %u ms...\n",
  1229                         " download request. Retrying after %lu ms...\n",
  1230                         (u32) diff_ms);
  1230                         diff_ms);
  1231 #endif
  1231 #endif
  1232                 // no response; send request datagram again
  1232                 // no response; send request datagram again
  1233                 return;
  1233                 return;
  1234             }
  1234             }
  1235         }
  1235         }
  1236         fsm->state = ec_fsm_coe_error;
  1236         fsm->state = ec_fsm_coe_error;
  1237         EC_SLAVE_ERR(slave, "Reception of CoE download request"
  1237         EC_SLAVE_ERR(slave, "Reception of CoE download request"
  1238                 " for SDO 0x%04x:%x failed with timeout after %u ms: ",
  1238                 " for SDO 0x%04x:%x failed with timeout after %lu ms: ",
  1239                 fsm->request->index, fsm->request->subindex, (u32) diff_ms);
  1239                 fsm->request->index, fsm->request->subindex, diff_ms);
  1240         ec_datagram_print_wc_error(datagram);
  1240         ec_datagram_print_wc_error(datagram);
  1241         return;
  1241         return;
  1242     }
  1242     }
  1243 
  1243 
  1244 #if DEBUG_LONG
  1244 #if DEBUG_LONG
  1245     if (diff_ms > 200) {
  1245     if (diff_ms > 200) {
  1246         EC_SLAVE_WARN(slave, "SDO 0x%04x:%x download took %u ms.\n",
  1246         EC_SLAVE_WARN(slave, "SDO 0x%04x:%x download took %lu ms.\n",
  1247                 fsm->request->index, fsm->request->subindex, (u32) diff_ms);
  1247                 fsm->request->index, fsm->request->subindex, diff_ms);
  1248     }
  1248     }
  1249 #endif
  1249 #endif
  1250 
  1250 
  1251     fsm->jiffies_start = datagram->jiffies_sent;
  1251     fsm->jiffies_start = datagram->jiffies_sent;
  1252 
  1252 
  1286     if (!ec_slave_mbox_check(datagram)) {
  1286     if (!ec_slave_mbox_check(datagram)) {
  1287         unsigned long diff_ms =
  1287         unsigned long diff_ms =
  1288             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
  1288             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
  1289         if (diff_ms >= fsm->request->response_timeout) {
  1289         if (diff_ms >= fsm->request->response_timeout) {
  1290             fsm->state = ec_fsm_coe_error;
  1290             fsm->state = ec_fsm_coe_error;
  1291             EC_SLAVE_ERR(slave, "Timeout after %u ms while waiting"
  1291             EC_SLAVE_ERR(slave, "Timeout after %lu ms while waiting"
  1292                     " for SDO 0x%04x:%x download response.\n", (u32) diff_ms,
  1292                     " for SDO 0x%04x:%x download response.\n", diff_ms,
  1293                     fsm->request->index, fsm->request->subindex);
  1293                     fsm->request->index, fsm->request->subindex);
  1294             return;
  1294             return;
  1295         }
  1295         }
  1296 
  1296 
  1297         ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
  1297         ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
  1725     if (datagram->working_counter != 1) {
  1725     if (datagram->working_counter != 1) {
  1726         if (!datagram->working_counter) {
  1726         if (!datagram->working_counter) {
  1727             if (diff_ms < fsm->request->response_timeout) {
  1727             if (diff_ms < fsm->request->response_timeout) {
  1728 #if DEBUG_RETRIES
  1728 #if DEBUG_RETRIES
  1729                 EC_SLAVE_DBG(slave, 1, "Slave did not respond to"
  1729                 EC_SLAVE_DBG(slave, 1, "Slave did not respond to"
  1730                         " SDO upload request. Retrying after %u ms...\n",
  1730                         " SDO upload request. Retrying after %lu ms...\n",
  1731                         (u32) diff_ms);
  1731                         diff_ms);
  1732 #endif
  1732 #endif
  1733                 // no response; send request datagram again
  1733                 // no response; send request datagram again
  1734                 return;
  1734                 return;
  1735             }
  1735             }
  1736         }
  1736         }
  1737         fsm->state = ec_fsm_coe_error;
  1737         fsm->state = ec_fsm_coe_error;
  1738         EC_SLAVE_ERR(slave, "Reception of CoE upload request for"
  1738         EC_SLAVE_ERR(slave, "Reception of CoE upload request for"
  1739                 " SDO 0x%04x:%x failed with timeout after %u ms: ",
  1739                 " SDO 0x%04x:%x failed with timeout after %lu ms: ",
  1740                 fsm->request->index, fsm->request->subindex, (u32) diff_ms);
  1740                 fsm->request->index, fsm->request->subindex, diff_ms);
  1741         ec_datagram_print_wc_error(datagram);
  1741         ec_datagram_print_wc_error(datagram);
  1742         return;
  1742         return;
  1743     }
  1743     }
  1744 
  1744 
  1745 #if DEBUG_LONG
  1745 #if DEBUG_LONG
  1746     if (diff_ms > 200) {
  1746     if (diff_ms > 200) {
  1747         EC_SLAVE_WARN(slave, "SDO 0x%04x:%x upload took %u ms.\n",
  1747         EC_SLAVE_WARN(slave, "SDO 0x%04x:%x upload took %lu ms.\n",
  1748                 fsm->request->index, fsm->request->subindex, (u32) diff_ms);
  1748                 fsm->request->index, fsm->request->subindex, diff_ms);
  1749     }
  1749     }
  1750 #endif
  1750 #endif
  1751 
  1751 
  1752     fsm->jiffies_start = datagram->jiffies_sent;
  1752     fsm->jiffies_start = datagram->jiffies_sent;
  1753 
  1753 
  1788     if (!ec_slave_mbox_check(datagram)) {
  1788     if (!ec_slave_mbox_check(datagram)) {
  1789         unsigned long diff_ms =
  1789         unsigned long diff_ms =
  1790             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
  1790             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
  1791         if (diff_ms >= fsm->request->response_timeout) {
  1791         if (diff_ms >= fsm->request->response_timeout) {
  1792             fsm->state = ec_fsm_coe_error;
  1792             fsm->state = ec_fsm_coe_error;
  1793             EC_SLAVE_ERR(slave, "Timeout after %u ms while waiting for"
  1793             EC_SLAVE_ERR(slave, "Timeout after %lu ms while waiting for"
  1794                     " SDO 0x%04x:%x upload response.\n", (u32) diff_ms,
  1794                     " SDO 0x%04x:%x upload response.\n", diff_ms,
  1795                     fsm->request->index, fsm->request->subindex);
  1795                     fsm->request->index, fsm->request->subindex);
  1796             return;
  1796             return;
  1797         }
  1797         }
  1798 
  1798 
  1799         ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
  1799         ec_slave_mbox_prepare_check(slave, datagram); // can not fail.