+
+ time_wait_ms(250);
+ cobroller_on(side);
+
+ /* check that cob is correctly in place */
+ if (WAIT_COND_OR_TIMEOUT(state_cob_inside(), 750) == 0) {
+ if (state_no_cob_inside()) {
+ STMCH_DEBUG("no cob");
+ return;
+ }
+ STMCH_DEBUG("bad cob state");
+
+ /* while cob is not correctly placed try to extract
+ * it as much as we can */
+ while (state_cob_inside() == 0 &&
+ state_no_cob_inside() == 0) {
+ uint8_t cpt = 0;
+ if (cpt == 0)
+ cobroller_reverse(side);
+ else if (cpt == 1)
+ cobroller_off(side);
+ else if (cpt == 2)
+ cobroller_on(side);
+ cpt ++;
+ cpt %= 3;
+ shovel_mid();
+ time_wait_ms(250);
+ shovel_down();
+ time_wait_ms(250);
+ }
+
+ STMCH_DEBUG("cob removed");
+ if (state_no_cob_inside()) {
+ STMCH_DEBUG("no cob");
+ return;
+ }
+ }
+
+ /* cob is inside, switch off roller */
+ cobroller_off(side);
+ cob_count ++;
+
+ /* last cob, nothing to do */
+ if (cob_count == 5)
+ return;