master/fsm_foe.c
branchstable-1.5
changeset 2378 ca345abf0565
parent 2257 a2a675601c98
child 2498 9cdd7669dc0b
equal deleted inserted replaced
2377:aa0f6f939cb3 2378:ca345abf0565
   620  */
   620  */
   621 void ec_fsm_foe_read_start(
   621 void ec_fsm_foe_read_start(
   622         ec_fsm_foe_t *fsm /**< FoE statemachine. */
   622         ec_fsm_foe_t *fsm /**< FoE statemachine. */
   623         )
   623         )
   624 {
   624 {
   625     size_t current_size;
       
   626     ec_slave_t *slave = fsm->slave;
   625     ec_slave_t *slave = fsm->slave;
   627 
   626 
   628     fsm->rx_buffer_offset = 0;
   627     fsm->rx_buffer_offset = 0;
   629     fsm->rx_expected_packet_no = 1;
   628     fsm->rx_expected_packet_no = 1;
   630     fsm->rx_last_packet = 0;
   629     fsm->rx_last_packet = 0;
   631 
       
   632     current_size = fsm->rx_filename_len;
       
   633 
   630 
   634 #ifdef DEBUG_FOE
   631 #ifdef DEBUG_FOE
   635     printk("ec_fsm_foe_read_start()\n");
   632     printk("ec_fsm_foe_read_start()\n");
   636 #endif
   633 #endif
   637 
   634 
   730         EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: ");
   727         EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: ");
   731         ec_datagram_print_wc_error(datagram);
   728         ec_datagram_print_wc_error(datagram);
   732         return;
   729         return;
   733     }
   730     }
   734 
   731 
   735     if (!(data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size))) {
   732     if (!(data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot,
       
   733                     &rec_size))) {
   736         ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR);
   734         ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR);
   737         return;
   735         return;
   738     }
   736     }
   739 
   737 
   740     if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE
   738     if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE
   756     if (opCode == EC_FOE_OPCODE_ERR) {
   754     if (opCode == EC_FOE_OPCODE_ERR) {
   757         fsm->request->error_code = EC_READ_U32(data + 2);
   755         fsm->request->error_code = EC_READ_U32(data + 2);
   758         EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n",
   756         EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n",
   759                 fsm->request->error_code);
   757                 fsm->request->error_code);
   760         if (rec_size > 6) {
   758         if (rec_size > 6) {
   761             uint8_t text[1024];
   759             uint8_t text[256];
   762             strncpy(text, data + 6, min(rec_size - 6, sizeof(text)));
   760             strncpy(text, data + 6, min(rec_size - 6, sizeof(text)));
   763             EC_SLAVE_ERR(slave, "FoE Error Text: %s\n", text);
   761             EC_SLAVE_ERR(slave, "FoE Error Text: %s\n", text);
   764         }
   762         }
   765         ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR);
   763         ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR);
   766         return;
   764         return;