equal
deleted
inserted
replaced
212 size_t remaining_size, current_size; |
212 size_t remaining_size, current_size; |
213 uint8_t* data; |
213 uint8_t* data; |
214 |
214 |
215 remaining_size = fsm->tx_buffer_size - fsm->tx_buffer_offset; |
215 remaining_size = fsm->tx_buffer_size - fsm->tx_buffer_offset; |
216 |
216 |
217 if (remaining_size < fsm->slave->sii.tx_mailbox_size - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE) { |
217 if (remaining_size < fsm->slave->sii.std_tx_mailbox_size |
|
218 - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE) { |
218 current_size = remaining_size; |
219 current_size = remaining_size; |
219 fsm->tx_last_packet = 1; |
220 fsm->tx_last_packet = 1; |
220 } |
221 } else { |
221 else { |
222 current_size = fsm->slave->sii.std_tx_mailbox_size |
222 current_size = fsm->slave->sii.tx_mailbox_size - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
223 - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
223 } |
224 } |
224 |
225 |
225 if (!(data = ec_slave_mbox_prepare_send(fsm->slave, fsm->datagram, |
226 if (!(data = ec_slave_mbox_prepare_send(fsm->slave, fsm->datagram, |
226 EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE))) |
227 EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE))) |
227 return -1; |
228 return -1; |
786 fsm->rx_buffer_offset += rec_size; |
787 fsm->rx_buffer_offset += rec_size; |
787 } |
788 } |
788 |
789 |
789 fsm->rx_last_packet = |
790 fsm->rx_last_packet = |
790 (rec_size + EC_MBOX_HEADER_SIZE + EC_FOE_HEADER_SIZE |
791 (rec_size + EC_MBOX_HEADER_SIZE + EC_FOE_HEADER_SIZE |
791 != fsm->slave->sii.rx_mailbox_size); |
792 != fsm->slave->sii.std_rx_mailbox_size); |
792 |
793 |
793 if (fsm->rx_last_packet || |
794 if (fsm->rx_last_packet || |
794 (slave->sii.rx_mailbox_size - EC_MBOX_HEADER_SIZE |
795 (slave->sii.std_rx_mailbox_size - EC_MBOX_HEADER_SIZE |
795 - EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) <= fsm->rx_buffer_size) { |
796 - EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) <= fsm->rx_buffer_size) { |
796 // either it was the last packet or a new packet will fit into the delivered buffer |
797 // either it was the last packet or a new packet will fit into the delivered buffer |
797 #ifdef myDEBUG |
798 #ifdef myDEBUG |
798 printk ("last_packet=true\n"); |
799 printk ("last_packet=true\n"); |
799 #endif |
800 #endif |
800 if (ec_foe_prepare_send_ack(fsm)) { |
801 if (ec_foe_prepare_send_ack(fsm)) { |
801 ec_foe_set_rx_error(fsm, FOE_RX_DATA_ACK_ERROR); |
802 ec_foe_set_rx_error(fsm, FOE_RX_DATA_ACK_ERROR); |
809 // ... wait for new read request |
810 // ... wait for new read request |
810 printk ("ERROR: data doesn't fit in receive buffer\n"); |
811 printk ("ERROR: data doesn't fit in receive buffer\n"); |
811 printk (" rx_buffer_size = %d\n", fsm->rx_buffer_size); |
812 printk (" rx_buffer_size = %d\n", fsm->rx_buffer_size); |
812 printk (" rx_buffer_offset= %d\n", fsm->rx_buffer_offset); |
813 printk (" rx_buffer_offset= %d\n", fsm->rx_buffer_offset); |
813 printk (" rec_size = %d\n", rec_size); |
814 printk (" rec_size = %d\n", rec_size); |
814 printk (" rx_mailbox_size = %d\n", slave->sii.rx_mailbox_size); |
815 printk (" rx_mailbox_size = %d\n", slave->sii.std_rx_mailbox_size); |
815 printk (" rx_last_packet = %d\n", fsm->rx_last_packet); |
816 printk (" rx_last_packet = %d\n", fsm->rx_last_packet); |
816 // fsm->state = ec_fsm_state_wait_next_read; |
817 // fsm->state = ec_fsm_state_wait_next_read; |
817 fsm->request->result = FOE_READY; |
818 fsm->request->result = FOE_READY; |
818 } |
819 } |
819 } |
820 } |