master/fsm.c
changeset 461 b9eda9235173
parent 459 f0da52cf6b5b
child 462 e6fac0c8bc92
equal deleted inserted replaced
460:719ba8ccc509 461:b9eda9235173
   490 
   490 
   491     // did the slave not respond to its station address?
   491     // did the slave not respond to its station address?
   492     if (datagram->working_counter != 1) {
   492     if (datagram->working_counter != 1) {
   493         if (slave->online) {
   493         if (slave->online) {
   494             slave->online = 0;
   494             slave->online = 0;
   495             if (master->debug_level)
   495             if (slave->master->debug_level)
   496                 EC_DBG("Slave %i: offline.\n", slave->ring_position);
   496                 EC_DBG("Slave %i: offline.\n", slave->ring_position);
   497         }
   497         }
   498         ec_fsm_master_action_next_slave_state(fsm);
   498         ec_fsm_master_action_next_slave_state(fsm);
   499         return;
   499         return;
   500     }
   500     }
   503     new_state = EC_READ_U8(datagram->data);
   503     new_state = EC_READ_U8(datagram->data);
   504     if (!slave->online) { // slave was offline before
   504     if (!slave->online) { // slave was offline before
   505         slave->online = 1;
   505         slave->online = 1;
   506         slave->error_flag = 0; // clear error flag
   506         slave->error_flag = 0; // clear error flag
   507         slave->current_state = new_state;
   507         slave->current_state = new_state;
   508         if (master->debug_level) {
   508         if (slave->master->debug_level) {
   509             char cur_state[EC_STATE_STRING_SIZE];
   509             char cur_state[EC_STATE_STRING_SIZE];
   510             ec_state_string(slave->current_state, cur_state);
   510             ec_state_string(slave->current_state, cur_state);
   511             EC_DBG("Slave %i: online (%s).\n",
   511             EC_DBG("Slave %i: online (%s).\n",
   512                    slave->ring_position, cur_state);
   512                    slave->ring_position, cur_state);
   513         }
   513         }
   514     }
   514     }
   515     else if (new_state != slave->current_state) {
   515     else if (new_state != slave->current_state) {
   516         if (master->debug_level) {
   516         if (slave->master->debug_level) {
   517             char old_state[EC_STATE_STRING_SIZE],
   517             char old_state[EC_STATE_STRING_SIZE],
   518                 cur_state[EC_STATE_STRING_SIZE];
   518                 cur_state[EC_STATE_STRING_SIZE];
   519             ec_state_string(slave->current_state, old_state);
   519             ec_state_string(slave->current_state, old_state);
   520             ec_state_string(new_state, cur_state);
   520             ec_state_string(new_state, cur_state);
   521             EC_DBG("Slave %i: %s -> %s.\n",
   521             EC_DBG("Slave %i: %s -> %s.\n",
  1186                 if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2),
  1186                 if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2),
  1187                                        cat_size, EC_RX_PDO))
  1187                                        cat_size, EC_RX_PDO))
  1188                     goto end;
  1188                     goto end;
  1189                 break;
  1189                 break;
  1190             default:
  1190             default:
  1191                 EC_WARN("Unknown category type 0x%04X in slave %i.\n",
  1191                 if (fsm->master->debug_level)
  1192                         cat_type, slave->ring_position);
  1192                     EC_WARN("Unknown category type 0x%04X in slave %i.\n",
       
  1193                             cat_type, slave->ring_position);
  1193         }
  1194         }
  1194 
  1195 
  1195         cat_word += cat_size + 2;
  1196         cat_word += cat_size + 2;
  1196     }
  1197     }
  1197 
  1198