master/mailbox.c
changeset 986 a486591ba86b
parent 834 0791aac03180
child 1217 e8a9785e63c3
child 1685 399ef727bf62
equal deleted inserted replaced
985:90bcaf9ce3d5 986:a486591ba86b
    59                                     )
    59                                     )
    60 {
    60 {
    61     size_t total_size;
    61     size_t total_size;
    62 
    62 
    63     if (unlikely(!slave->sii.mailbox_protocols)) {
    63     if (unlikely(!slave->sii.mailbox_protocols)) {
    64         EC_ERR("Slave %i does not support mailbox communication!\n",
    64         EC_ERR("Slave %u does not support mailbox communication!\n",
    65                slave->ring_position);
    65                slave->ring_position);
    66         return NULL;
    66         return NULL;
    67     }
    67     }
    68 
    68 
    69     total_size = size + 6;
    69     total_size = size + 6;
   166     size_t data_size;
   166     size_t data_size;
   167 
   167 
   168     data_size = EC_READ_U16(datagram->data);
   168     data_size = EC_READ_U16(datagram->data);
   169 
   169 
   170     if (data_size > slave->sii.tx_mailbox_size - 6) {
   170     if (data_size > slave->sii.tx_mailbox_size - 6) {
   171         EC_ERR("Corrupt mailbox response received from slave %i!\n",
   171         EC_ERR("Corrupt mailbox response received from slave %u!\n",
   172                slave->ring_position);
   172                slave->ring_position);
   173         ec_print_data(datagram->data, slave->sii.tx_mailbox_size);
   173         ec_print_data(datagram->data, slave->sii.tx_mailbox_size);
   174         return NULL;
   174         return NULL;
   175     }
   175     }
   176 
   176 
   179 
   179 
   180     if (*type == 0x00) {
   180     if (*type == 0x00) {
   181         const ec_code_msg_t *mbox_msg;
   181         const ec_code_msg_t *mbox_msg;
   182 	uint16_t code = EC_READ_U16(datagram->data + 8);
   182 	uint16_t code = EC_READ_U16(datagram->data + 8);
   183 
   183 
   184         EC_ERR("Mailbox error response received from slave %i - ",
   184         EC_ERR("Mailbox error response received from slave %u - ",
   185                slave->ring_position);
   185                slave->ring_position);
   186 
   186 
   187 	for (mbox_msg = mbox_error_messages; mbox_msg->code; mbox_msg++) {
   187 	for (mbox_msg = mbox_error_messages; mbox_msg->code; mbox_msg++) {
   188             if (mbox_msg->code != code) continue;
   188             if (mbox_msg->code != code) continue;
   189             printk("Code 0x%04X: \"%s\".\n",
   189             printk("Code 0x%04X: \"%s\".\n",