OpenEtherCATsociety / SOES

Simple Open Source EtherCAT Slave
Other
581 stars 250 forks source link

byte_offset data type change #26

Closed KwonTae-young closed 7 years ago

KwonTae-young commented 7 years ago

uint8_t byte_offset range(0~255) can not be expressed when process data length is 255 or more.

I have declared 200 UNSIGNED16 data types in Inputs and Outputs, respectively. At this time, address is incorrectly reflected because of data type of byte_offset in ESC_write_pram() and ESC_read_pram() function.

The attached file(byte_offset.txt) is a log obtained by printing printf() from ESC_read_pram() as shown below.

   while(len > 0)
   {
      temp_len = (len > 4) ? 4: len;
      /* Always read 4 byte */
      read (lan9252, (temp_buf + byte_offset), sizeof(uint32_t));

      fifo_cnt--;
      len -= temp_len;
      byte_offset += temp_len;
      printf("address=0x%x temp_buf=0x%x byte_offset=%d\n", address+byte_offset, temp, byte_offset);
   }

byte_offset.txt

On line 64, the range of byte_offset is exceeded and address is initialized.